예제 #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());
   }
 }
예제 #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()));
   }
 }
예제 #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);
   }
 }
예제 #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);
    }