cascading.tuple.TupleEntry.setLong()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(2.8k)|赞(0)|评价(0)|浏览(86)

本文整理了Java中cascading.tuple.TupleEntry.setLong()方法的一些代码示例,展示了TupleEntry.setLong()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TupleEntry.setLong()方法的具体详情如下:
包路径:cascading.tuple.TupleEntry
类名称:TupleEntry
方法名:setLong

TupleEntry.setLong介绍

[英]Method setLong sets the value in the given field or position.
[中]方法setLong设置给定字段或位置中的值。

代码示例

代码示例来源: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 )
 {
 TupleEntry output = functionCall.getContext().getRhs();
 try
  {
  String value = functionCall.getArguments().getString( 0 );
  if( value == null ) // if null, return null for the field
   {
   output.setObject( 0, null ); // safe to call set, tuple is size of 1
   functionCall.getOutputCollector().add( output );
   return;
   }
  Date date = functionCall.getContext().getLhs().parse( value );
  if( calendarFields == null )
   output.setLong( 0, date.getTime() ); // safe to call set, tuple is size of 1
  else
   makeCalendarFields( output, date );
  }
 catch( ParseException exception )
  {
  throw new OperationException( "unable to parse input value: " + functionCall.getArguments().getObject( 0 ), exception );
  }
 functionCall.getOutputCollector().add( output );
 }

代码示例来源: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.setLong( 0, date.getTime() );
results.setString( 1, stringDate );
results.setObject( 2, date );

相关文章