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

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

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

TupleEntry.set介绍

[英]Method set sets the values from the given tupleEntry into this TupleEntry instance based on the given tupleEntry field names.

If type information is given, each incoming value will be coerced from its canonical type to the current type.
[中]方法集基于给定的tupleEntry字段名,将给定tupleEntry中的值设置到此tupleEntry实例中。
如果给出了类型信息,每个传入值都将从其规范类型强制为当前类型。

代码示例

代码示例来源:origin: LiveRamp/cascading_ext

/**
  * Sets values for selectorFields from the inputTupleEntry into the outputTupleEntry.
  * We do this instead of using inputTupleEntry.selectTuple() so that it doesn't
  * create a new Tuple instance.
  * Caches selectorFieldsPos the first time for optimization.
  *
  * @param outputTupleEntry
  * @param selectorFields
  * @param inputTupleEntry
  */
 public static void setTupleEntry(TupleEntry outputTupleEntry,
   ArrayList<Integer> selectorFieldsPos,
   Fields selectorFields,
   TupleEntry inputTupleEntry) {
  if (selectorFieldsPos.size() == 0) {
   for (int i = 0; i < selectorFields.size(); i++) {
    selectorFieldsPos.add(inputTupleEntry.getFields().getPos(selectorFields.get(i)));
   }
  }

  for (int i = 0; i < selectorFieldsPos.size(); i++) {
   outputTupleEntry.set(i, inputTupleEntry.getObject(selectorFieldsPos.get(i)));
  }
 }
}

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

@Test
public void testSet()
 {
 TupleEntry entryA = new TupleEntry( new Fields( "a", "b", "c" ), new Tuple( "a", "b", "c" ) );
 TupleEntry entryB = new TupleEntry( new Fields( "c", "b" ), new Tuple( "C", "B" ) );
 entryA.set( entryB );
 Tuple tuple = entryA.getTuple();
 assertEquals( "wrong size", 3, tuple.size() );
 assertEquals( "not equal: tuple.get(0)", "a", tuple.getObject( 0 ) );
 assertEquals( "not equal: tuple.get(1)", "B", tuple.getObject( 1 ) );
 assertEquals( "not equal: tuple.get(2)", "C", tuple.getObject( 2 ) );
 }

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

@Test
public void testSetCoerce()
 {
 Fields fieldsA = new Fields( "a", "b", "c" ).applyTypes( String.class, String.class, String.class );
 TupleEntry entryA = new TupleEntry( fieldsA, new Tuple( "0", "1", "2" ) );
 Fields fieldsB = new Fields( "c", "b" ).applyTypes( Integer.class, Integer.class );
 TupleEntry entryB = new TupleEntry( fieldsB, new Tuple( -2, -1 ) );
 entryA.set( entryB );
 Tuple tuple = entryA.getTuple();
 assertEquals( "wrong size", 3, tuple.size() );
 assertEquals( "not equal: tuple.get(0)", "0", tuple.getObject( 0 ) );
 assertEquals( "not equal: tuple.get(1)", "-1", tuple.getObject( 1 ) );
 assertEquals( "not equal: tuple.get(2)", "-2", tuple.getObject( 2 ) );
 }
}

相关文章