示例#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 TaggedUnion<T1, T2> deserialize(DataInputView source) throws IOException {
   byte tag = source.readByte();
   if (tag == 1) {
     return TaggedUnion.one(oneSerializer.deserialize(source));
   } else {
     return TaggedUnion.two(twoSerializer.deserialize(source));
   }
 }
示例#4
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);
   }
 }
示例#5
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);
    }
示例#6
0
 @Override
 public TaggedUnion<T1, T2> map(T2 value) throws Exception {
   return TaggedUnion.two(value);
 }