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

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

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

TupleEntry.setCanonicalTuple介绍

[英]Method setCanonicalTuple replaces each value of the current tuple with the given tuple elements after they are coerced.

This method will modify the existing Tuple wrapped by this TupleEntry instance even if it is marked as unmodifiable.

If tuple argument is null, the current tuple will be set to null.
[中]方法setCanonicalTuple在强制当前元组的每个值之后,用给定的元组元素替换它们。
此方法将修改此TupleEntry实例包装的现有元组,即使它被标记为不可修改。
如果元组参数为null,则当前元组将设置为null。

代码示例

代码示例来源:origin: cwensel/cascading

@Override
public boolean source( FlowProcess<? extends Configuration> flowProcess, SourceCall<Object[], RecordReader> sourceCall ) throws IOException
 {
 Tuple key = (Tuple) sourceCall.getContext()[ 0 ];
 Tuple value = (Tuple) sourceCall.getContext()[ 1 ];
 boolean result = sourceCall.getInput().next( key, value );
 if( !result )
  return false;
 TupleEntry entry = sourceCall.getIncomingEntry();
 if( entry.hasTypes() )
  entry.setCanonicalTuple( value );
 else
  entry.setTuple( value );
 return true;
 }

代码示例来源:origin: cascading/cascading-hadoop2-io

@Override
public boolean source( FlowProcess<? extends Configuration> flowProcess, SourceCall<Object[], RecordReader> sourceCall ) throws IOException
 {
 Tuple key = (Tuple) sourceCall.getContext()[ 0 ];
 Tuple value = (Tuple) sourceCall.getContext()[ 1 ];
 boolean result = sourceCall.getInput().next( key, value );
 if( !result )
  return false;
 TupleEntry entry = sourceCall.getIncomingEntry();
 if( entry.hasTypes() )
  entry.setCanonicalTuple( value );
 else
  entry.setTuple( value );
 return true;
 }

代码示例来源:origin: cwensel/cascading

@Test
public void testSetCanonicalNull()
 {
 TupleEntry entryA = new TupleEntry( new Fields( "a", "b", "c" ), new Tuple( "a", "b", "c" ) );
 entryA.setCanonicalTuple( null );
 assertTrue( entryA.getTuple() == null );
 }

代码示例来源:origin: cwensel/cascading

public void complete( FlowProcess flowProcess, AggregatorCall aggregatorCall )
 {
 TupleEntry result;
 if( aggregatorCall.getDeclaredFields().isUnknown() )
  result = new TupleEntry( Fields.size( value[ 0 ].size() ), Tuple.size( value[ 0 ].size() ) );
 else
  result = new TupleEntry( aggregatorCall.getDeclaredFields(), Tuple.size( aggregatorCall.getDeclaredFields().size() ) );
 for( int i = 0; i < duplicates; i++ )
  {
  for( Tuple tuple : value )
   {
   try
    {
    result.setCanonicalTuple( tuple );
    }
   catch( Exception exception )
    {
    // value is a string, but the the test declared a numeric type
    result.setCanonicalTuple( Tuple.size( value[ 0 ].size(), -99 ) );
    }
   aggregatorCall.getOutputCollector().add( result );
   }
  }
 }
}

代码示例来源:origin: cwensel/cascading

expected.setString( 4, Long.toString( date.getTime() ) );
results.setCanonicalTuple( expected );

代码示例来源:origin: cwensel/cascading

public void operate( FlowProcess flowProcess, FunctionCall<Integer> functionCall )
 {
 if( value == null )
  throwIntentionalException();
 try
  {
  if( functionCall.getContext() == failon )
   throw new RuntimeException( "function failed intentionally on tuple number: " + failon );
  }
 finally
  {
  functionCall.setContext( functionCall.getContext() + 1 );
  }
 TupleEntry result;
 if( functionCall.getDeclaredFields().isUnknown() )
  result = new TupleEntry( Fields.size( value.size() ), Tuple.size( value.size() ) );
 else
  result = new TupleEntry( functionCall.getDeclaredFields(), Tuple.size( functionCall.getDeclaredFields().size() ) );
 try
  {
  result.setCanonicalTuple( value );
  }
 catch( Exception exception )
  {
  // value is a string, but the the test declared a numeric type
  result.setCanonicalTuple( Tuple.size( value.size(), -99 ) );
  }
 functionCall.getOutputCollector().add( result );
 }

相关文章