本文整理了Java中cascading.tuple.Tuple.toString()
方法的一些代码示例,展示了Tuple.toString()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Tuple.toString()
方法的具体详情如下:
包路径:cascading.tuple.Tuple
类名称:Tuple
方法名:toString
[英]Method toString writes this Tuple instance values out to a String delimited by the given String value.
[中]方法toString将此元组实例值写入由给定字符串值分隔的字符串。
代码示例来源:origin: cwensel/cascading
private boolean matchWholeTuple( Tuple input, Pattern pattern )
{
if( patternString == null )
return true;
Matcher matcher = pattern.matcher( input.toString( "\t", false ) );
LOG.debug( "pattern: {}, matches: {}", pattern, matcher.matches() );
return matcher.matches();
}
代码示例来源:origin: cwensel/cascading
@Override
public void sink( FlowProcess<? extends Properties> flowProcess, SinkCall<PrintWriter, OutputStream> sinkCall ) throws IOException
{
sinkCall.getContext().println( sinkCall.getOutgoingEntry().getTuple().toString() );
}
代码示例来源:origin: cwensel/cascading
@Override
public void sink( FlowProcess<? extends Configuration> flowProcess, SinkCall<Object[], OutputCollector> sinkCall ) throws IOException
{
Text text = (Text) sinkCall.getContext()[ 0 ];
Charset charset = (Charset) sinkCall.getContext()[ 1 ];
String line = sinkCall.getOutgoingEntry().getTuple().toString();
text.set( line.getBytes( charset ) );
// it's ok to use NULL here so the collector does not write anything
sinkCall.getOutput().collect( null, text );
}
代码示例来源:origin: cascading/cascading-hadoop2-io
@Override
public void sink( FlowProcess<? extends Configuration> flowProcess, SinkCall<Object[], OutputCollector> sinkCall ) throws IOException
{
Text text = (Text) sinkCall.getContext()[ 0 ];
Charset charset = (Charset) sinkCall.getContext()[ 1 ];
String line = sinkCall.getOutgoingEntry().getTuple().toString();
text.set( line.getBytes( charset ) );
// it's ok to use NULL here so the collector does not write anything
sinkCall.getOutput().collect( null, text );
}
代码示例来源:origin: cwensel/cascading
@Override
public void operate( FlowProcess flowProcess, FunctionCall<Tuple> functionCall )
{
functionCall.getContext().set( 0, functionCall.getArguments().getTuple().toString( delimiter, false ) );
functionCall.getOutputCollector().add( functionCall.getContext() );
}
代码示例来源:origin: cascading/pattern-core
throw new ComparisonFailure( "tuples not equal", lhsTuple.toString(), rhsTuple.toString() );
代码示例来源:origin: cwensel/cascading
public static void validateLength( TupleEntryIterator iterator, int numTuples, int tupleSize, Pattern regex )
{
int count = 0;
while( iterator.hasNext() )
{
TupleEntry tupleEntry = iterator.next();
if( tupleSize != -1 )
assertEquals( "wrong number of elements", tupleSize, tupleEntry.size() );
if( regex != null )
assertTrue( "regex: " + regex + " does not match: " + tupleEntry.getTuple().toString(), regex.matcher( tupleEntry.getTuple().toString() ).matches() );
count++;
}
try
{
iterator.close();
}
catch( IOException exception )
{
throw new RuntimeException( exception );
}
assertEquals( "wrong number of lines", numTuples, count );
}
代码示例来源:origin: cwensel/cascading
@Test
public void testSinkUnknown() throws IOException
{
getPlatform().copyFromLocal( inputFileCross );
Tap source = getPlatform().getTextFile( new Fields( "line" ), inputFileCross );
Pipe pipe = new Pipe( "test" );
pipe = new Each( pipe, new RegexSplitter( new Fields( "first", "second", "third" ), "\\s" ), Fields.RESULTS );
Tap sink = getPlatform().getTabDelimitedFile( Fields.UNKNOWN, getOutputPath( "unknownsinks" ), SinkMode.REPLACE );
Flow flow = getPlatform().getFlowConnector().connect( source, sink, pipe );
flow.complete();
validateLength( flow, 37, null );
TupleEntryIterator iterator = flow.openSink();
String line = iterator.next().getTuple().toString();
assertTrue( "not equal: wrong values: " + line, line.matches( "[0-9]\t[a-z]\t[A-Z]" ) );
iterator.close();
}
代码示例来源:origin: cascading/cascading-platform
@Test
public void testSinkUnknown() throws IOException
{
getPlatform().copyFromLocal( inputFileCross );
Tap source = getPlatform().getTextFile( new Fields( "line" ), inputFileCross );
Pipe pipe = new Pipe( "test" );
pipe = new Each( pipe, new RegexSplitter( new Fields( "first", "second", "third" ), "\\s" ), Fields.RESULTS );
Tap sink = getPlatform().getTabDelimitedFile( Fields.UNKNOWN, getOutputPath( "unknownsinks" ), SinkMode.REPLACE );
Flow flow = getPlatform().getFlowConnector().connect( source, sink, pipe );
flow.complete();
validateLength( flow, 37, null );
TupleEntryIterator iterator = flow.openSink();
String line = iterator.next().getTuple().toString();
assertTrue( "not equal: wrong values: " + line, line.matches( "[0-9]\t[a-z]\t[A-Z]" ) );
iterator.close();
}
代码示例来源:origin: cwensel/cascading
assertEquals( "not equal: ", resultTuple.toString(), result );
else if( resultTuple == null )
fail( "no result assertion made for:" + getName() + " with result: " + result );
代码示例来源:origin: cascading/cascading-platform
assertEquals( "not equal: ", resultTuple.toString(), result );
else if( resultTuple == null )
fail( "no result assertion made for:" + getName() + " with result: " + result );
内容来源于网络,如有侵权,请联系作者删除!