本文整理了Java中cascading.tuple.TupleEntry.setString()
方法的一些代码示例,展示了TupleEntry.setString()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TupleEntry.setString()
方法的具体详情如下:
包路径:cascading.tuple.TupleEntry
类名称:TupleEntry
方法名:setString
[英]Method setString sets the value in the given field or position.
[中]方法setString设置给定字段或位置中的值。
代码示例来源:origin: cwensel/cascading
private void onGivenGroups( FunctionCall<Pair<Matcher, TupleEntry>> functionCall, Matcher matcher, TupleEntry output )
{
for( int i = 0; i < groups.length; i++ )
output.setString( i, matcher.group( groups[ i ] ) );
functionCall.getOutputCollector().add( output );
}
代码示例来源:origin: stackoverflow.com
result.setString("F1Output", DEFAULT_VALUE);
result.setString("F2Output", DEFAULT_VALUE);
代码示例来源:origin: cwensel/cascading
@Override
public void operate( FlowProcess flowProcess, FunctionCall<Pair<Matcher, TupleEntry>> functionCall )
{
// coerce to string
String value = functionCall.getArguments().getString( 0 );
// make safe
if( value == null )
value = "";
TupleEntry output = functionCall.getContext().getRhs();
Matcher matcher = functionCall.getContext().getLhs().reset( value );
if( replaceAll )
output.setString( 0, matcher.replaceAll( replacement ) );
else
output.setString( 0, matcher.replaceFirst( replacement ) );
functionCall.getOutputCollector().add( output );
}
代码示例来源:origin: cwensel/cascading
private void setGroupsOnTuple( Matcher matcher, TupleEntry output, int count )
{
if( count == 0 )
{
try
{
output.setString( 0, matcher.group( 0 ) );
}
catch( Exception exception )
{
throw new CascadingException( "unable to set tuple value at field: " + output.getFields().get( 0 ) + ", from regex group: 0", exception );
}
}
else
{
for( int i = 0; i < count; i++ )
{
try
{
output.setString( i, matcher.group( i + 1 ) ); // skip group 0
}
catch( Exception exception )
{
throw new CascadingException( "unable to set tuple value at field: " + output.getFields().get( i ) + ", from regex group: " + ( i + 1 ), exception );
}
}
}
}
代码示例来源:origin: cwensel/cascading
protected void sourceHandleInput( SourceCall<Object[], RecordReader> sourceCall ) throws IOException
{
TupleEntry result = sourceCall.getIncomingEntry();
int index = 0;
Object[] context = sourceCall.getContext();
// coerce into canonical forms
if( getSourceFields().size() == 2 )
result.setLong( index++, ( (LongWritable) context[ 0 ] ).get() );
result.setString( index, makeEncodedString( context ) );
}
代码示例来源:origin: cascading/cascading-hadoop2-io
protected void sourceHandleInput( SourceCall<Object[], RecordReader> sourceCall ) throws IOException
{
TupleEntry result = sourceCall.getIncomingEntry();
int index = 0;
Object[] context = sourceCall.getContext();
// coerce into canonical forms
if( getSourceFields().size() == 2 )
result.setLong( index++, ( (LongWritable) context[ 0 ] ).get() );
result.setString( index, makeEncodedString( context ) );
}
代码示例来源:origin: cwensel/cascading
@Override
public void operate( FlowProcess flowProcess, FunctionCall<Pair<SimpleDateFormat, TupleEntry>> functionCall )
{
long ts = functionCall.getArguments().getLong( 0 );
Calendar calendar = getCalendar();
calendar.setTimeInMillis( ts );
String formatted = functionCall.getContext().getLhs().format( calendar.getTime() );
functionCall.getContext().getRhs().setString( 0, formatted );
functionCall.getOutputCollector().add( functionCall.getContext().getRhs() );
}
}
代码示例来源:origin: cwensel/cascading
@Override
public void operate( FlowProcess flowProcess, FunctionCall<Pair<Matcher, TupleEntry>> functionCall )
{
String value = functionCall.getArguments().getString( 0 );
if( value == null )
value = "";
Matcher matcher = functionCall.getContext().getLhs().reset( value );
while( matcher.find() )
{
functionCall.getContext().getRhs().setString( 0, matcher.group() );
functionCall.getOutputCollector().add( functionCall.getContext().getRhs() );
}
}
}
代码示例来源:origin: cwensel/cascading
@Override
public boolean source( FlowProcess<? extends Properties> flowProcess, SourceCall<LineNumberReader, InputStream> sourceCall ) throws IOException
{
// first line is 0, this matches offset being zero, so when throwing out the first line for comments
int lineNumber = sourceCall.getContext().getLineNumber();
String line = sourceCall.getContext().readLine();
if( line == null )
return false;
TupleEntry incomingEntry = sourceCall.getIncomingEntry();
if( getSourceFields().size() == 1 )
{
incomingEntry.setObject( 0, line );
}
else
{
incomingEntry.setInteger( 0, lineNumber );
incomingEntry.setString( 1, line );
}
return true;
}
代码示例来源:origin: cwensel/cascading
@Override
public void operate( FlowProcess flowProcess, FunctionCall<Pair<Pattern, TupleEntry>> functionCall )
{
String value = functionCall.getArguments().getString( 0 );
if( value == null )
value = "";
String[] split = functionCall.getContext().getLhs().split( value );
for( String string : split )
{
TupleEntry tupleEntry = functionCall.getContext().getRhs();
tupleEntry.setString( 0, string );
functionCall.getOutputCollector().add( tupleEntry );
}
}
}
代码示例来源:origin: cwensel/cascading
@Test
public void testCoerceIterable()
{
final SimpleDateFormat dateFormat = new SimpleDateFormat( "dd/MMM/yyyy:HH:mm:ss:SSS Z" );
CoercibleType coercible = new DateType( "dd/MMM/yyyy:HH:mm:ss:SSS Z", TimeZone.getDefault() );
Date date = new Date();
String stringDate = dateFormat.format( date );
Tuple tuple = Tuple.size( 4 );
Fields fields = Fields.size( 4 ).applyTypes( coercible, coercible, coercible, String.class );
TupleEntry results = new TupleEntry( fields, tuple );
results.setObject( 0, date );
results.setLong( 1, date.getTime() );
results.setString( 2, stringDate );
results.setString( 3, stringDate );
Iterable<String> iterable = results.asIterableOf( String.class );
int count = 0;
for( String s : iterable )
{
assertEquals( stringDate, s );
count++;
}
assertEquals( count, results.size() );
}
代码示例来源:origin: cwensel/cascading
results.setString( 1, stringDate );
results.setObject( 2, date );
results.setRaw( 3, date ); // performs no coercion
results.setString( 4, Long.toString( date.getTime() ) );
内容来源于网络,如有侵权,请联系作者删除!