@Test public void testCoderIsSerializableWithWellKnownCoderType() throws Exception { CoderProperties.coderSerializable(SetCoder.of(GlobalWindow.Coder.INSTANCE)); }
/** Produces a {@link SetCoder} with the given {@code elementCoder}. */ public static <T> SetCoder<T> of(Coder<T> elementCoder) { return new SetCoder<>(elementCoder); }
@Override public TypeDescriptor<Set<T>> getEncodedTypeDescriptor() { return new TypeDescriptor<Set<T>>() {}.where( new TypeParameter<T>() {}, getElemCoder().getEncodedTypeDescriptor()); }
@Test public void testParameterizedDefaultNestedSetCoder() throws Exception { CoderRegistry registry = CoderRegistry.createDefault(); TypeDescriptor<Set<Set<Integer>>> setToken = new TypeDescriptor<Set<Set<Integer>>>() {}; assertEquals(SetCoder.of(SetCoder.of(VarIntCoder.of())), registry.getCoder(setToken)); }
@Test public void testParameterizedDefaultSetCoder() throws Exception { CoderRegistry registry = CoderRegistry.createDefault(); TypeDescriptor<Set<Integer>> setToken = new TypeDescriptor<Set<Integer>>() {}; assertEquals(SetCoder.of(VarIntCoder.of()), registry.getCoder(setToken)); }
public MergingActiveWindowSet(WindowFn<Object, W> windowFn, StateInternals state) { this.windowFn = windowFn; StateTag<ValueState<Map<W, Set<W>>>> tag = StateTags.makeSystemTagInternal( StateTags.value( "tree", MapCoder.of(windowFn.windowCoder(), SetCoder.of(windowFn.windowCoder())))); valueState = state.state(StateNamespaces.global(), tag); // Little use trying to prefetch this state since the ReduceFnRunner // is stymied until it is available. activeWindowToStateAddressWindows = emptyIfNull(valueState.read()); originalActiveWindowToStateAddressWindows = deepCopy(activeWindowToStateAddressWindows); }
StateTags.combiningValue( "side-input-available-windows-" + sideInput.getTagInternal().getId(), SetCoder.of(windowCoder), new WindowSetCombineFn());
return ListCoder.of(inferCoderFromObjects(coderRegistry, schemaRegistry, ((Iterable) o))); } else if (o instanceof Set) { return SetCoder.of(inferCoderFromObjects(coderRegistry, schemaRegistry, ((Iterable) o))); } else if (o instanceof Collection) { return CollectionCoder.of(
@Test public void registerCoderEqualsNotSame() throws IOException { Coder<?> coder = KvCoder.of(StringUtf8Coder.of(), IterableCoder.of(SetCoder.of(ByteArrayCoder.of()))); Coder<?> otherCoder = KvCoder.of(StringUtf8Coder.of(), IterableCoder.of(SetCoder.of(ByteArrayCoder.of()))); assertThat(coder, equalTo(otherCoder)); String id = components.registerCoder(coder); String otherId = components.registerCoder(otherCoder); assertThat(otherId, not(equalTo(id))); components.toComponents().getCodersOrThrow(id); components.toComponents().getCodersOrThrow(otherId); }
@Test public void registerCoder() throws IOException { Coder<?> coder = KvCoder.of(StringUtf8Coder.of(), IterableCoder.of(SetCoder.of(ByteArrayCoder.of()))); String id = components.registerCoder(coder); assertThat(components.registerCoder(coder), equalTo(id)); assertThat(id, not(isEmptyOrNullString())); VarLongCoder otherCoder = VarLongCoder.of(); assertThat(components.registerCoder(otherCoder), not(equalTo(id))); components.toComponents().getCodersOrThrow(id); components.toComponents().getCodersOrThrow(components.registerCoder(otherCoder)); }
@Test @Category(ValidatesRunner.class) public void testFlattenIterablesSets() { Set<String> linesSet = ImmutableSet.copyOf(LINES); PCollection<Set<String>> input = p.apply(Create.<Set<String>>of(linesSet).withCoder(SetCoder.of(StringUtf8Coder.of()))); PCollection<String> output = input.apply(Flatten.iterables()); PAssert.that(output).containsInAnyOrder(LINES_ARRAY); p.run(); }
KV.of("hello", 97), KV.of("hello", 42), KV.of("hello", 42), KV.of("hello", 12))) .apply(ParDo.of(fn)) .setCoder(SetCoder.of(myIntegerCoder));
KV.of("hello", 12))) .apply(ParDo.of(fn)) .setCoder(SetCoder.of(myIntegerCoder));
.add(CollectionCoder.of(VarLongCoder.of())) .add(ListCoder.of(VarLongCoder.of())) .add(SetCoder.of(VarLongCoder.of())) .add(MapCoder.of(VarLongCoder.of(), ByteArrayCoder.of())) .add(NullableCoder.of(IntervalWindow.getCoder()))