本文整理了Java中cascading.tuple.Tuple.getString()
方法的一些代码示例,展示了Tuple.getString()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Tuple.getString()
方法的具体详情如下:
包路径:cascading.tuple.Tuple
类名称:Tuple
方法名:getString
[英]Method getString returns the element at the given position as a String.
[中]方法getString将给定位置的元素作为字符串返回。
代码示例来源:origin: cwensel/cascading
private void validateCase( String test, Boolean[] testCase, Tap sink ) throws IOException
{
TupleEntryIterator iterator = sink.openForRead( getPlatform().getFlowProcess() );
LinkedHashMap<Long, List<String>> group = new LinkedHashMap<Long, List<String>>();
while( iterator.hasNext() )
{
Tuple tuple = iterator.next().getTuple();
if( !group.containsKey( tuple.getLong( 0 ) ) )
group.put( tuple.getLong( 0 ), new ArrayList<String>() );
group.get( tuple.getLong( 0 ) ).add( tuple.getString( 2 ) );
}
boolean groupIsReversed = testCase[ 0 ];
if( testCase[ 2 ] )
groupIsReversed = !groupIsReversed;
compare( "grouping+" + test, groupIsReversed, group.keySet() );
if( testCase[ 1 ] == null )
return;
boolean valueIsReversed = testCase[ 1 ];
if( testCase[ 2 ] )
valueIsReversed = !valueIsReversed;
for( Long grouping : group.keySet() )
compare( "values+" + test, valueIsReversed, group.get( grouping ) );
}
代码示例来源:origin: cascading/cascading-platform
private void validateCase( String test, Boolean[] testCase, Tap sink ) throws IOException
{
TupleEntryIterator iterator = sink.openForRead( getPlatform().getFlowProcess() );
LinkedHashMap<Long, List<String>> group = new LinkedHashMap<Long, List<String>>();
while( iterator.hasNext() )
{
Tuple tuple = iterator.next().getTuple();
if( !group.containsKey( tuple.getLong( 0 ) ) )
group.put( tuple.getLong( 0 ), new ArrayList<String>() );
group.get( tuple.getLong( 0 ) ).add( tuple.getString( 2 ) );
}
boolean groupIsReversed = testCase[ 0 ];
if( testCase[ 2 ] )
groupIsReversed = !groupIsReversed;
compare( "grouping+" + test, groupIsReversed, group.keySet() );
if( testCase[ 1 ] == null )
return;
boolean valueIsReversed = testCase[ 1 ];
if( testCase[ 2 ] )
valueIsReversed = !valueIsReversed;
for( Long grouping : group.keySet() )
compare( "values+" + test, valueIsReversed, group.get( grouping ) );
}
代码示例来源:origin: cwensel/cascading
private void validateFile( Tap tap, int length, int uniqueValues, boolean isReversed, int comparePosition ) throws IOException, ParseException
{
TupleEntryIterator iterator = tap.openForRead( getPlatform().getFlowProcess() );
Set<Long> values = new HashSet<Long>();
long lastValue = isReversed ? Long.MAX_VALUE : Long.MIN_VALUE;
int count = 0;
while( iterator.hasNext() )
{
Tuple tuple = iterator.next().getTuple();
count++;
tuple = new Tuple( (Object[]) tuple.getString( 1 ).split( "\t" ) );
long value = tuple.getLong( comparePosition );
values.add( value );
if( isReversed )
assertTrue( "out of order in " + tap, lastValue >= value );
else
assertTrue( "out of order in " + tap, lastValue <= value );
lastValue = value;
}
if( length != -1 )
assertEquals( "length of " + tap, length, count );
if( uniqueValues != -1 )
assertEquals( "unique values of " + tap, uniqueValues, values.size() );
}
}
代码示例来源:origin: cascading/cascading-platform
private void validateFile( Tap tap, int length, int uniqueValues, boolean isReversed, int comparePosition ) throws IOException, ParseException
{
TupleEntryIterator iterator = tap.openForRead( getPlatform().getFlowProcess() );
Set<Long> values = new HashSet<Long>();
long lastValue = isReversed ? Long.MAX_VALUE : Long.MIN_VALUE;
int count = 0;
while( iterator.hasNext() )
{
Tuple tuple = iterator.next().getTuple();
count++;
tuple = new Tuple( (Object[]) tuple.getString( 1 ).split( "\t" ) );
long value = tuple.getLong( comparePosition );
values.add( value );
if( isReversed )
assertTrue( "out of order in " + tap, lastValue >= value );
else
assertTrue( "out of order in " + tap, lastValue <= value );
lastValue = value;
}
if( length != -1 )
assertEquals( "length of " + tap, length, count );
if( uniqueValues != -1 )
assertEquals( "unique values of " + tap, uniqueValues, values.size() );
}
}
代码示例来源:origin: cwensel/cascading
throw new TapException( "unable to read fields from tap: " + tap + ", is empty" );
Object[] result = onlyParseLine( entry.getTuple().getString( 0 ) ); // don't coerce if type info is avail
内容来源于网络,如有侵权,请联系作者删除!