Ejemplo n.º 1
0
 @Override
 public KEY getKey(TaggedUnion<T1, T2> value) throws Exception {
   if (value.isOne()) {
     return keySelector1.getKey(value.getOne());
   } else {
     return keySelector2.getKey(value.getTwo());
   }
 }
Ejemplo n.º 2
0
 @Override
 public TaggedUnion<T1, T2> copy(TaggedUnion<T1, T2> from, TaggedUnion<T1, T2> reuse) {
   if (from.isOne()) {
     return TaggedUnion.one(oneSerializer.copy(from.getOne()));
   } else {
     return TaggedUnion.two(twoSerializer.copy(from.getTwo()));
   }
 }
Ejemplo n.º 3
0
 @Override
 public void serialize(TaggedUnion<T1, T2> record, DataOutputView target) throws IOException {
   if (record.isOne()) {
     target.writeByte(1);
     oneSerializer.serialize(record.getOne(), target);
   } else {
     target.writeByte(2);
     twoSerializer.serialize(record.getTwo(), target);
   }
 }
Ejemplo n.º 4
0
    @Override
    public void apply(KEY key, W window, Iterable<TaggedUnion<T1, T2>> values, Collector<T> out)
        throws Exception {

      List<T1> oneValues = new ArrayList<>();
      List<T2> twoValues = new ArrayList<>();

      for (TaggedUnion<T1, T2> val : values) {
        if (val.isOne()) {
          oneValues.add(val.getOne());
        } else {
          twoValues.add(val.getTwo());
        }
      }
      wrappedFunction.coGroup(oneValues, twoValues, out);
    }