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

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

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

TupleEntry.selectEntry介绍

[英]Method selectEntry selects the fields specified in the selector from this instance. If Fields#ALL or the same fields as declared are given, this will be returned.

The returned TupleEntry will be either modifiable or unmodifiable, depending on the state of this TupleEntry instance.

See #selectEntryCopy(Fields) to guarantee a copy suitable for modifying or caching/storing in a collection.

Note this is a bug fix and change from 2.0 and 2.1. In previous versions the modifiable state was dependent on the given selector.
[中]方法selectEntry从此实例中选择选择器中指定的字段。如果字段#给出了声明的所有或相同字段,将返回该字段。
返回的TupleEntry将是可修改或不可修改的,具体取决于此TupleEntry实例的状态。
请参阅#selectEntryCopy(字段),以确保副本适合在集合中修改或缓存/存储。
请注意,这是一个错误修复和2.0和2.1版本的更改。在以前的版本中,可修改状态取决于给定的选择器。

代码示例

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

/**
 * Method entryStream returns a {@link Stream} of {@link TupleEntry} instances from the given
 * Tap instance.
 * <p>
 * Also see {@link cascading.tuple.TupleEntryStream#entryStream(Tap, FlowProcess, Fields)}.
 * <p>
 * Note, the returned Stream instance must be closed in order to clean up underlying resources. This
 * is simply accomplished with a try-with-resources statement.
 *
 * @param flowProcess represents the current platform configuration
 * @param selector    the fields to select from the underlying TupleEntry
 * @return a Stream of TupleEntry instances
 */
public Stream<TupleEntry> entryStream( FlowProcess<? extends Config> flowProcess, Fields selector )
 {
 return entryStream( flowProcess ).map( tupleEntry -> tupleEntry.selectEntry( selector ) );
 }

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

boolean isRemove( FlowProcess flowProcess, TupleEntry partitionEntry )
 {
 return filter.isRemove( flowProcess, getFilterCallWith( partitionEntry.selectEntry( argumentFields ) ) );
 }

代码示例来源:origin: com.hotels/plunger

@Override
public boolean isRemove(@SuppressWarnings("rawtypes") FlowProcess flowProcess, FilterCall<Void> filterCall) {
 PrintStream stream = streamSupplier.getPrintStream();
 if (firstRecord) {
  stream.append(prefix);
  for (Comparable<?> value : filterCall.getArguments().getFields().select(fieldsOfInterest)) {
   stream.append(value.toString());
   stream.append('\t');
  }
  stream.append('\n');
  firstRecord = false;
 }
 stream.append(prefix);
 for (String value : filterCall.getArguments().selectEntry(fieldsOfInterest).asIterableOf(String.class)) {
  stream.append(value);
  stream.append('\t');
 }
 stream.append('\n');
 return false;
}

代码示例来源:origin: com.twitter/maple

@Override
public void sink(FlowProcess<JobConf> flowProcess, SinkCall<Object[], OutputCollector> sinkCall)
  throws IOException {
 TupleEntry tupleEntry = sinkCall.getOutgoingEntry();
 OutputCollector outputCollector = sinkCall.getOutput();
 Tuple key = tupleEntry.selectTuple(keyField);
 ImmutableBytesWritable keyBytes = (ImmutableBytesWritable) key.getObject(0);
 Put put = new Put(keyBytes.get());
 for (int i = 0; i < valueFields.length; i++) {
  Fields fieldSelector = valueFields[i];
  TupleEntry values = tupleEntry.selectEntry(fieldSelector);
  for (int j = 0; j < values.getFields().size(); j++) {
   Fields fields = values.getFields();
   Tuple tuple = values.getTuple();
   ImmutableBytesWritable valueBytes = (ImmutableBytesWritable) tuple.getObject(j);
   put.add(Bytes.toBytes(familyNames[i]), Bytes.toBytes((String) fields.get(j)), valueBytes.get());
  }
 }
 outputCollector.collect(null, put);
}

相关文章