@Override public PCollection<T> expand(PCollectionList<T> input) { return (PCollection) input.getPipeline().apply(Create.empty(VoidCoder.of())); } }
@Override public PCollection<Row> expand(PCollectionList<Row> input) { checkArgument( input.size() == 0, "Should not have received input for %s: %s", BeamIOSourceRel.class.getSimpleName(), input); return sqlTable.buildIOReader(input.getPipeline().begin()); } }
@Override public PCollection<T> expand(PCollectionList<T> input) { Map<PCollection<T>, Integer> instances = new HashMap<>(); for (PCollection<T> pCollection : input.getAll()) { int existing = instances.get(pCollection) == null ? 0 : instances.get(pCollection); instances.put(pCollection, existing + 1); } PCollectionList<T> output = PCollectionList.empty(input.getPipeline()); for (Map.Entry<PCollection<T>, Integer> instanceEntry : instances.entrySet()) { if (instanceEntry.getValue().equals(1)) { output = output.and(instanceEntry.getKey()); } else { String duplicationName = String.format("Multiply %s", instanceEntry.getKey().getName()); PCollection<T> duplicated = instanceEntry .getKey() .apply(duplicationName, ParDo.of(new DuplicateFn<>(instanceEntry.getValue()))); output = output.and(duplicated); } } return output.apply(Flatten.pCollections()); } }
@Override public PCollection<Row> expand(PCollectionList<Row> pinput) { checkArgument( pinput.size() == 0, "Should not have received input for %s: %s", BeamValuesRel.class.getSimpleName(), pinput); if (tuples.isEmpty()) { throw new IllegalStateException("Values with empty tuples!"); } Schema schema = CalciteUtils.toSchema(getRowType()); List<Row> rows = tuples.stream().map(tuple -> tupleToRow(schema, tuple)).collect(toList()); return pinput.getPipeline().begin().apply(Create.of(rows)).setRowSchema(schema); } }
inputs.getPipeline(), windowingStrategy, isBounded,