本文整理汇总了Java中cascading.tuple.TupleEntry类的典型用法代码示例。如果您正苦于以下问题:Java TupleEntry类的具体用法?Java TupleEntry怎么用?Java TupleEntry使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TupleEntry类属于cascading.tuple包,在下文中一共展示了TupleEntry类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: coerceToString
import cascading.tuple.TupleEntry; //导入依赖的package包/类
static Tuple coerceToString(SinkCall<?, ?> sinkCall) {
TupleEntry entry = sinkCall.getOutgoingEntry();
Fields fields = entry.getFields();
Tuple tuple = entry.getTuple();
if (fields.hasTypes()) {
Type types[] = new Type[fields.size()];
for (int index = 0; index < fields.size(); index++) {
Type type = fields.getType(index);
if (type instanceof CoercibleType<?>) {
types[index] = String.class;
}
else {
types[index] = type;
}
}
tuple = entry.getCoercedTuple(types);
}
return tuple;
}
示例2: SinkBoundaryInStage
import cascading.tuple.TupleEntry; //导入依赖的package包/类
public SinkBoundaryInStage(FlowProcess flowProcess, FlowElement flowElement, FlowNode node) {
super(flowProcess, flowElement);
this.nextStarted = false;
Scope inScope = node.getElementGraph().incomingEdgesOf(flowElement).iterator().next();
Fields inFields;
if(inScope.isEvery()) {
inFields = inScope.getOutGroupingFields();
}
else {
inFields = inScope.getOutValuesFields();
}
this.tupleEntry = new TupleEntry(inFields);
}
示例3: source
import cascading.tuple.TupleEntry; //导入依赖的package包/类
/**
* Populates the {@link Corc} with the next value from the {@link RecordReader}. Then copies the values into the
* incoming {@link TupleEntry}.
*/
@Override
public boolean source(FlowProcess<? extends Configuration> flowProcess, SourceCall<Corc, RecordReader> sourceCall)
throws IOException {
Corc corc = sourceCall.getContext();
@SuppressWarnings("unchecked")
boolean next = sourceCall.getInput().next(NullWritable.get(), corc);
if (!next) {
return false;
}
TupleEntry tupleEntry = sourceCall.getIncomingEntry();
for (Comparable<?> fieldName : tupleEntry.getFields()) {
if (ROW_ID_NAME.equals(fieldName)) {
tupleEntry.setObject(ROW_ID_NAME, corc.getRecordIdentifier());
} else {
tupleEntry.setObject(fieldName, corc.get(fieldName.toString()));
}
}
return true;
}
示例4: readTypical
import cascading.tuple.TupleEntry; //导入依赖的package包/类
@Test
public void readTypical() throws IOException {
try (OrcWriter writer = new OrcWriter.Builder(conf, new Path(path, "part-00000"))
.addField("a", TypeInfoFactory.stringTypeInfo)
.addField("b", TypeInfoFactory.stringTypeInfo)
.build()) {
writer.addRow("A1", "B1");
writer.addRow("A2", "B2");
}
List<TupleEntry> actual = Plunger.readDataFromTap(
new Hfs(OrcFile.source().declaredFields(FIELDS_AB).schemaFromFile().build(), path)).asTupleEntryList();
List<TupleEntry> expected = new DataBuilder(FIELDS_AB)
.addTuple("A1", "B1")
.addTuple("A2", "B2")
.build()
.asTupleEntryList();
assertThat(actual, is(tupleEntryList(expected)));
}
示例5: readMissing
import cascading.tuple.TupleEntry; //导入依赖的package包/类
@Test
public void readMissing() throws IOException {
try (OrcWriter writer = new OrcWriter.Builder(conf, new Path(path, "part-00000")).addField("a",
TypeInfoFactory.stringTypeInfo).build()) {
writer.addRow("A1");
writer.addRow("A2");
}
List<TupleEntry> actual = Plunger.readDataFromTap(
new Hfs(OrcFile.source().declaredFields(FIELDS_AB).schemaFromFile().build(), path)).asTupleEntryList();
List<TupleEntry> expected = new DataBuilder(FIELDS_AB)
.addTuple("A1", null)
.addTuple("A2", null)
.build()
.asTupleEntryList();
assertThat(actual, is(tupleEntryList(expected)));
}
示例6: write
import cascading.tuple.TupleEntry; //导入依赖的package包/类
@Override
public void write(TupleEntry record) {
recordConsumer.startMessage();
final List<Type> fields = rootSchema.getFields();
for (int i = 0; i < fields.size(); i++) {
Type field = fields.get(i);
if (record == null || record.getObject(field.getName()) == null) {
continue;
}
recordConsumer.startField(field.getName(), i);
if (field.isPrimitive()) {
writePrimitive(record, field.asPrimitiveType());
} else {
throw new UnsupportedOperationException("Complex type not implemented");
}
recordConsumer.endField(field.getName(), i);
}
recordConsumer.endMessage();
}
示例7: writeToHadoopPartitionTap
import cascading.tuple.TupleEntry; //导入依赖的package包/类
private void writeToHadoopPartitionTap(Tap<?, ?, ?> tap) throws IOException {
@SuppressWarnings("unchecked")
BasePartitionTap<JobConf, ?, ?> hadoopTap = (BasePartitionTap<JobConf, ?, ?>) tap;
JobConf conf = new JobConf();
// Avoids deletion of results when using a partition tap (close() will delete the _temporary before the copy has
// been done if not in a flow)
HadoopUtil.setIsInflow(conf);
HadoopFlowProcess flowProcess = new HadoopFlowProcess(conf);
hadoopTap.sinkConfInit(flowProcess, conf);
TupleEntryCollector collector = hadoopTap.openForWrite(flowProcess);
for (TupleEntry tuple : data.asTupleEntryList()) {
collector.add(tuple);
}
collector.close();
// We need to clean up the '_temporary' folder
BasePartitionTap<JobConf, ?, ?> partitionTap = hadoopTap;
@SuppressWarnings("unchecked")
String basePath = partitionTap.getParent().getFullIdentifier(flowProcess);
deleteTemporaryPath(new Path(basePath), FileSystem.get(conf));
}
示例8: writeToLocalTap
import cascading.tuple.TupleEntry; //导入依赖的package包/类
private void writeToLocalTap(Tap<?, ?, ?> tap) throws IOException {
@SuppressWarnings("unchecked")
Tap<Properties, ?, ?> localTap = (Tap<Properties, ?, ?>) tap;
Properties conf = new Properties();
LocalFlowProcess flowProcess = new LocalFlowProcess(conf);
flowProcess.setStepStats(new LocalStepStats(new NullFlowStep(), NullClientState.INSTANCE));
localTap.sinkConfInit(flowProcess, conf);
TupleEntryCollector collector = localTap.openForWrite(flowProcess);
for (TupleEntry tuple : data.asTupleEntryList()) {
collector.add(tuple);
}
collector.close();
localTap.commitResource(conf);
}
示例9: asTupleEntryListWithFieldsOrdering
import cascading.tuple.TupleEntry; //导入依赖的package包/类
@Test
public void asTupleEntryListWithFieldsOrdering() throws Exception {
Fields fields = new Fields("A", "B");
List<Tuple> tuples = new ArrayList<Tuple>();
tuples.add(new Tuple(1, 100));
tuples.add(new Tuple(2, 200));
List<TupleEntry> entryList = new Data(fields, tuples).withFields(new Fields("B", "A")).asTupleEntryList();
assertThat(entryList.size(), is(2));
assertThat(entryList.get(0).size(), is(2));
assertThat(entryList.get(0).getFields(), is(new Fields("B", "A")));
assertThat(entryList.get(0).getInteger(0), is(100));
assertThat(entryList.get(0).getInteger(1), is(1));
assertThat(entryList.get(1).size(), is(2));
assertThat(entryList.get(1).getFields(), is(new Fields("B", "A")));
assertThat(entryList.get(1).getInteger(0), is(200));
assertThat(entryList.get(1).getInteger(1), is(2));
}
示例10: addTupleEntryWithFields
import cascading.tuple.TupleEntry; //导入依赖的package包/类
@Test
public void addTupleEntryWithFields() {
Fields fields = new Fields("A", "B");
DataBuilder builder = new DataBuilder(fields);
Fields subFields = new Fields("B");
builder
.withFields(subFields)
.addTupleEntry(new TupleEntry(subFields, new Tuple(1)))
.addTupleEntry(new TupleEntry(subFields, new Tuple(3)));
Data source = builder.build();
List<Tuple> tuples = source.getTuples();
assertThat(tuples.size(), is(2));
assertThat(tuples.get(0), is(new Tuple(null, 1)));
assertThat(tuples.get(1), is(new Tuple(null, 3)));
}
示例11: addMultipleTupleEntriesIterable
import cascading.tuple.TupleEntry; //导入依赖的package包/类
@Test
public void addMultipleTupleEntriesIterable() {
Fields fields = new Fields("A", "B");
DataBuilder builder = new DataBuilder(fields);
List<TupleEntry> tupleEntries = Arrays.asList(new TupleEntry(fields, new Tuple(1, 2)), new TupleEntry(fields,
new Tuple(3, 4)));
builder.addTupleEntries(tupleEntries);
Data source = builder.build();
List<Tuple> tuples = source.getTuples();
assertThat(tuples.size(), is(2));
assertThat(tuples.get(0), is(new Tuple(1, 2)));
assertThat(tuples.get(1), is(new Tuple(3, 4)));
}
示例12: addMultipleTupleEntriesIterableWithFields
import cascading.tuple.TupleEntry; //导入依赖的package包/类
@Test
public void addMultipleTupleEntriesIterableWithFields() {
Fields fields = new Fields("A", "B");
DataBuilder builder = new DataBuilder(fields);
Fields subFields = new Fields("B");
List<TupleEntry> tupleEntries = Arrays.asList(new TupleEntry(subFields, new Tuple(1)), new TupleEntry(subFields,
new Tuple(3)));
builder.withFields(subFields).addTupleEntries(tupleEntries);
Data source = builder.build();
List<Tuple> tuples = source.getTuples();
assertThat(tuples.size(), is(2));
assertThat(tuples.get(0), is(new Tuple(null, 1)));
assertThat(tuples.get(1), is(new Tuple(null, 3)));
}
示例13: selectFieldsToSetUsingMultipleEntriesIterableInsert
import cascading.tuple.TupleEntry; //导入依赖的package包/类
@Test
public void selectFieldsToSetUsingMultipleEntriesIterableInsert() {
Fields fields = new Fields("A", "B", "C", "D");
DataBuilder builder = new DataBuilder(fields);
Fields subFields = new Fields("B", "D");
List<TupleEntry> tupleEntries = Arrays.asList(new TupleEntry(subFields, new Tuple(1, 2)), new TupleEntry(subFields,
new Tuple(3, 4)));
builder.withFields(subFields).addTupleEntries(tupleEntries);
Data source = builder.build();
List<Tuple> tuples = source.getTuples();
assertThat(tuples.size(), is(2));
assertThat(tuples.get(0), is(new Tuple(null, 1, null, 2)));
assertThat(tuples.get(1), is(new Tuple(null, 3, null, 4)));
}
示例14: complete
import cascading.tuple.TupleEntry; //导入依赖的package包/类
@Test
public void complete() {
@SuppressWarnings("unchecked")
List<TupleEntry> actual = new BufferCallStub.Builder<Void>(GROUP_FIELDS, NON_GROUP_FIELDS)
.newGroup(1)
.addTuple("a")
.addTuple("b")
.newGroup(2)
.addTuple("c")
.addTuple("d")
.build()
.complete(mock(FlowProcess.class), new FirstNBuffer(1))
.result()
.asTupleEntryList();
assertThat(actual.size(), is(2));
assertThat(actual.get(0), tupleEntry(NON_GROUP_FIELDS, "a"));
assertThat(actual.get(1), tupleEntry(NON_GROUP_FIELDS, "c"));
}
示例15: completeDifferentOutputFields
import cascading.tuple.TupleEntry; //导入依赖的package包/类
@Test
public void completeDifferentOutputFields() {
List<TupleEntry> actual = new BufferCallStub.Builder<Void>(GROUP_FIELDS, NON_GROUP_FIELDS)
.outputFields(OUTPUT)
.newGroup(1)
.addTuple("a")
.addTuple("b")
.newGroup(2)
.addTuple("c")
.addTuple("d")
.build()
.complete(mock(FlowProcess.class), new CountBuffer())
.result()
.asTupleEntryList();
assertThat(actual.size(), is(4));
assertThat(actual.get(0), tupleEntry(OUTPUT, 1));
assertThat(actual.get(1), tupleEntry(OUTPUT, 2));
assertThat(actual.get(2), tupleEntry(OUTPUT, 1));
assertThat(actual.get(3), tupleEntry(OUTPUT, 2));
}