src_fm_fc_ms_ff
stringlengths 43
86.8k
| target
stringlengths 20
276k
|
|---|---|
WindowKeySchema implements RocksDBSegmentedBytesStore.KeySchema { @Override public Bytes lowerRange(final Bytes key, final long from) { return OrderedBytes.lowerRange(key, MIN_SUFFIX); } @Override void init(final String topic); @Override Bytes upperRange(final Bytes key, final long to); @Override Bytes lowerRange(final Bytes key, final long from); @Override Bytes lowerRangeFixedSize(final Bytes key, final long from); @Override Bytes upperRangeFixedSize(final Bytes key, final long to); @Override long segmentTimestamp(final Bytes key); @Override HasNextCondition hasNextCondition(final Bytes binaryKeyFrom, final Bytes binaryKeyTo, final long from, final long to); @Override List<Segment> segmentsToSearch(final Segments segments, final long from, final long to); }
|
@Test public void testLowerBoundWithZeroTimestamp() throws Exception { Bytes lower = windowKeySchema.lowerRange(Bytes.wrap(new byte[]{0xA, 0xB, 0xC}), 0); assertThat(lower, equalTo(WindowStoreUtils.toBinaryKey(new byte[]{0xA, 0xB, 0xC}, 0, 0))); }
@Test public void testLowerBoundWithMonZeroTimestamp() throws Exception { Bytes lower = windowKeySchema.lowerRange(Bytes.wrap(new byte[]{0xA, 0xB, 0xC}), 42); assertThat(lower, equalTo(WindowStoreUtils.toBinaryKey(new byte[]{0xA, 0xB, 0xC}, 0, 0))); }
@Test public void testLowerBoundMatchesTrailingZeros() throws Exception { Bytes lower = windowKeySchema.lowerRange(Bytes.wrap(new byte[]{0xA, 0xB, 0xC}), Long.MAX_VALUE - 1); assertThat( "appending zeros to key should still be in range", lower.compareTo( WindowStoreUtils.toBinaryKey( new byte[]{0xA, 0xB, 0xC, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, Long.MAX_VALUE - 1, 0 ) ) < 0 ); assertThat(lower, equalTo(WindowStoreUtils.toBinaryKey(new byte[]{0xA, 0xB, 0xC}, 0, 0))); }
|
DelegatingPeekingKeyValueIterator implements KeyValueIterator<K, V>, PeekingKeyValueIterator<K, V> { @Override public synchronized KeyValue<K, V> next() { if (!hasNext()) { throw new NoSuchElementException(); } final KeyValue<K, V> result = next; next = null; return result; } DelegatingPeekingKeyValueIterator(final String storeName, final KeyValueIterator<K, V> underlying); @Override synchronized K peekNextKey(); @Override synchronized void close(); @Override synchronized boolean hasNext(); @Override synchronized KeyValue<K, V> next(); @Override void remove(); @Override KeyValue<K, V> peekNext(); }
|
@Test(expected = NoSuchElementException.class) public void shouldThrowNoSuchElementWhenNoMoreItemsLeftAndNextCalled() throws Exception { final DelegatingPeekingKeyValueIterator<String, String> peekingIterator = new DelegatingPeekingKeyValueIterator<>(name, store.all()); peekingIterator.next(); }
|
DelegatingPeekingKeyValueIterator implements KeyValueIterator<K, V>, PeekingKeyValueIterator<K, V> { @Override public synchronized K peekNextKey() { if (!hasNext()) { throw new NoSuchElementException(); } return next.key; } DelegatingPeekingKeyValueIterator(final String storeName, final KeyValueIterator<K, V> underlying); @Override synchronized K peekNextKey(); @Override synchronized void close(); @Override synchronized boolean hasNext(); @Override synchronized KeyValue<K, V> next(); @Override void remove(); @Override KeyValue<K, V> peekNext(); }
|
@Test(expected = NoSuchElementException.class) public void shouldThrowNoSuchElementWhenNoMoreItemsLeftAndPeekNextCalled() throws Exception { final DelegatingPeekingKeyValueIterator<String, String> peekingIterator = new DelegatingPeekingKeyValueIterator<>(name, store.all()); peekingIterator.peekNextKey(); }
|
CompositeReadOnlyKeyValueStore implements ReadOnlyKeyValueStore<K, V> { @Override public V get(final K key) { final List<ReadOnlyKeyValueStore<K, V>> stores = storeProvider.stores(storeName, storeType); for (ReadOnlyKeyValueStore<K, V> store : stores) { try { final V result = store.get(key); if (result != null) { return result; } } catch (InvalidStateStoreException e) { throw new InvalidStateStoreException("State store is not available anymore and may have been migrated to another instance; please re-discover its location from the state metadata."); } } return null; } CompositeReadOnlyKeyValueStore(final StateStoreProvider storeProvider,
final QueryableStoreType<ReadOnlyKeyValueStore<K, V>> storeType,
final String storeName); @Override V get(final K key); @Override KeyValueIterator<K, V> range(final K from, final K to); @Override KeyValueIterator<K, V> all(); @Override long approximateNumEntries(); }
|
@Test public void shouldReturnNullIfKeyDoesntExist() throws Exception { assertNull(theStore.get("whatever")); }
@Test public void shouldReturnValueIfExists() throws Exception { stubOneUnderlying.put("key", "value"); assertEquals("value", theStore.get("key")); }
@Test public void shouldNotGetValuesFromOtherStores() throws Exception { otherUnderlyingStore.put("otherKey", "otherValue"); assertNull(theStore.get("otherKey")); }
@SuppressWarnings("unchecked") @Test public void shouldFindValueForKeyWhenMultiStores() throws Exception { final KeyValueStore<String, String> cache = newStoreInstance(); stubProviderTwo.addStore(storeName, cache); cache.put("key-two", "key-two-value"); stubOneUnderlying.put("key-one", "key-one-value"); assertEquals("key-two-value", theStore.get("key-two")); assertEquals("key-one-value", theStore.get("key-one")); }
@Test(expected = InvalidStateStoreException.class) public void shouldThrowInvalidStoreExceptionDuringRebalance() throws Exception { rebalancing().get("anything"); }
|
CompositeReadOnlyKeyValueStore implements ReadOnlyKeyValueStore<K, V> { @Override public KeyValueIterator<K, V> range(final K from, final K to) { final NextIteratorFunction<K, V> nextIteratorFunction = new NextIteratorFunction<K, V>() { @Override public KeyValueIterator<K, V> apply(final ReadOnlyKeyValueStore<K, V> store) { try { return store.range(from, to); } catch (InvalidStateStoreException e) { throw new InvalidStateStoreException("State store is not available anymore and may have been migrated to another instance; please re-discover its location from the state metadata."); } } }; final List<ReadOnlyKeyValueStore<K, V>> stores = storeProvider.stores(storeName, storeType); return new DelegatingPeekingKeyValueIterator<>(storeName, new CompositeKeyValueIterator(stores.iterator(), nextIteratorFunction)); } CompositeReadOnlyKeyValueStore(final StateStoreProvider storeProvider,
final QueryableStoreType<ReadOnlyKeyValueStore<K, V>> storeType,
final String storeName); @Override V get(final K key); @Override KeyValueIterator<K, V> range(final K from, final K to); @Override KeyValueIterator<K, V> all(); @Override long approximateNumEntries(); }
|
@Test public void shouldSupportRange() throws Exception { stubOneUnderlying.put("a", "a"); stubOneUnderlying.put("b", "b"); stubOneUnderlying.put("c", "c"); final List<KeyValue<String, String>> results = toList(theStore.range("a", "b")); assertTrue(results.contains(new KeyValue<>("a", "a"))); assertTrue(results.contains(new KeyValue<>("b", "b"))); assertEquals(2, results.size()); }
@SuppressWarnings("unchecked") @Test public void shouldSupportRangeAcrossMultipleKVStores() throws Exception { final KeyValueStore<String, String> cache = newStoreInstance(); stubProviderTwo.addStore(storeName, cache); stubOneUnderlying.put("a", "a"); stubOneUnderlying.put("b", "b"); stubOneUnderlying.put("z", "z"); cache.put("c", "c"); cache.put("d", "d"); cache.put("x", "x"); final List<KeyValue<String, String>> results = toList(theStore.range("a", "e")); assertTrue(results.contains(new KeyValue<>("a", "a"))); assertTrue(results.contains(new KeyValue<>("b", "b"))); assertTrue(results.contains(new KeyValue<>("c", "c"))); assertTrue(results.contains(new KeyValue<>("d", "d"))); assertEquals(4, results.size()); }
@Test(expected = InvalidStateStoreException.class) public void shouldThrowInvalidStoreExceptionOnRangeDuringRebalance() throws Exception { rebalancing().range("anything", "something"); }
|
CompositeReadOnlyKeyValueStore implements ReadOnlyKeyValueStore<K, V> { @Override public KeyValueIterator<K, V> all() { final NextIteratorFunction<K, V> nextIteratorFunction = new NextIteratorFunction<K, V>() { @Override public KeyValueIterator<K, V> apply(final ReadOnlyKeyValueStore<K, V> store) { try { return store.all(); } catch (InvalidStateStoreException e) { throw new InvalidStateStoreException("State store is not available anymore and may have been migrated to another instance; please re-discover its location from the state metadata."); } } }; final List<ReadOnlyKeyValueStore<K, V>> stores = storeProvider.stores(storeName, storeType); return new DelegatingPeekingKeyValueIterator<>(storeName, new CompositeKeyValueIterator(stores.iterator(), nextIteratorFunction)); } CompositeReadOnlyKeyValueStore(final StateStoreProvider storeProvider,
final QueryableStoreType<ReadOnlyKeyValueStore<K, V>> storeType,
final String storeName); @Override V get(final K key); @Override KeyValueIterator<K, V> range(final K from, final K to); @Override KeyValueIterator<K, V> all(); @Override long approximateNumEntries(); }
|
@Test public void shouldSupportAllAcrossMultipleStores() throws Exception { final KeyValueStore<String, String> cache = newStoreInstance(); stubProviderTwo.addStore(storeName, cache); stubOneUnderlying.put("a", "a"); stubOneUnderlying.put("b", "b"); stubOneUnderlying.put("z", "z"); cache.put("c", "c"); cache.put("d", "d"); cache.put("x", "x"); final List<KeyValue<String, String>> results = toList(theStore.all()); assertTrue(results.contains(new KeyValue<>("a", "a"))); assertTrue(results.contains(new KeyValue<>("b", "b"))); assertTrue(results.contains(new KeyValue<>("c", "c"))); assertTrue(results.contains(new KeyValue<>("d", "d"))); assertTrue(results.contains(new KeyValue<>("x", "x"))); assertTrue(results.contains(new KeyValue<>("z", "z"))); assertEquals(6, results.size()); }
@Test(expected = InvalidStateStoreException.class) public void shouldThrowInvalidStoreExceptionOnAllDuringRebalance() throws Exception { rebalancing().all(); }
|
CompositeReadOnlyKeyValueStore implements ReadOnlyKeyValueStore<K, V> { @Override public long approximateNumEntries() { final List<ReadOnlyKeyValueStore<K, V>> stores = storeProvider.stores(storeName, storeType); long total = 0; for (ReadOnlyKeyValueStore<K, V> store : stores) { total += store.approximateNumEntries(); } return total < 0 ? Long.MAX_VALUE : total; } CompositeReadOnlyKeyValueStore(final StateStoreProvider storeProvider,
final QueryableStoreType<ReadOnlyKeyValueStore<K, V>> storeType,
final String storeName); @Override V get(final K key); @Override KeyValueIterator<K, V> range(final K from, final K to); @Override KeyValueIterator<K, V> all(); @Override long approximateNumEntries(); }
|
@Test public void shouldGetApproximateEntriesAcrossAllStores() throws Exception { final KeyValueStore<String, String> cache = newStoreInstance(); stubProviderTwo.addStore(storeName, cache); stubOneUnderlying.put("a", "a"); stubOneUnderlying.put("b", "b"); stubOneUnderlying.put("z", "z"); cache.put("c", "c"); cache.put("d", "d"); cache.put("x", "x"); assertEquals(6, theStore.approximateNumEntries()); }
@Test public void shouldReturnLongMaxValueOnOverflow() throws Exception { stubProviderTwo.addStore(storeName, new NoOpReadOnlyStore<Object, Object>() { @Override public long approximateNumEntries() { return Long.MAX_VALUE; } }); stubOneUnderlying.put("overflow", "me"); assertEquals(Long.MAX_VALUE, theStore.approximateNumEntries()); }
|
ChangeLoggingKeyValueStore extends WrappedStateStore.AbstractStateStore implements KeyValueStore<K, V> { @Override public void put(final K key, final V value) { final Bytes bytesKey = Bytes.wrap(serdes.rawKey(key)); final byte[] bytesValue = serdes.rawValue(value); innerBytes.put(bytesKey, bytesValue); } ChangeLoggingKeyValueStore(final KeyValueStore<Bytes, byte[]> bytesStore,
final Serde keySerde,
final Serde valueSerde); private ChangeLoggingKeyValueStore(final ChangeLoggingKeyValueBytesStore bytesStore,
final Serde keySerde,
final Serde valueSerde); @SuppressWarnings("unchecked") @Override void init(final ProcessorContext context, final StateStore root); @Override long approximateNumEntries(); @Override void put(final K key, final V value); @Override V putIfAbsent(final K key, final V value); @Override void putAll(final List<KeyValue<K, V>> entries); @Override V delete(final K key); @Override V get(final K key); @Override KeyValueIterator<K, V> range(final K from, final K to); @Override KeyValueIterator<K, V> all(); }
|
@Test public void shouldWriteKeyValueBytesToInnerStoreOnPut() throws Exception { store.put(hi, there); assertThat(deserializedValueFromInner(hi), equalTo(there)); }
@Test public void shouldWriteKeyValueBytesToInnerStoreOnPut() { store.put(hi, there); assertThat(deserializedValueFromInner(hi), equalTo(there)); }
|
ChangeLoggingKeyValueStore extends WrappedStateStore.AbstractStateStore implements KeyValueStore<K, V> { @Override public void putAll(final List<KeyValue<K, V>> entries) { final List<KeyValue<Bytes, byte[]>> keyValues = new ArrayList<>(); for (final KeyValue<K, V> entry : entries) { keyValues.add(KeyValue.pair(Bytes.wrap(serdes.rawKey(entry.key)), serdes.rawValue(entry.value))); } innerBytes.putAll(keyValues); } ChangeLoggingKeyValueStore(final KeyValueStore<Bytes, byte[]> bytesStore,
final Serde keySerde,
final Serde valueSerde); private ChangeLoggingKeyValueStore(final ChangeLoggingKeyValueBytesStore bytesStore,
final Serde keySerde,
final Serde valueSerde); @SuppressWarnings("unchecked") @Override void init(final ProcessorContext context, final StateStore root); @Override long approximateNumEntries(); @Override void put(final K key, final V value); @Override V putIfAbsent(final K key, final V value); @Override void putAll(final List<KeyValue<K, V>> entries); @Override V delete(final K key); @Override V get(final K key); @Override KeyValueIterator<K, V> range(final K from, final K to); @Override KeyValueIterator<K, V> all(); }
|
@Test public void shouldWriteAllKeyValueToInnerStoreOnPutAll() throws Exception { store.putAll(Arrays.asList(KeyValue.pair(hello, world), KeyValue.pair(hi, there))); assertThat(deserializedValueFromInner(hello), equalTo(world)); assertThat(deserializedValueFromInner(hi), equalTo(there)); }
@Test public void shouldWriteAllKeyValueToInnerStoreOnPutAll() { store.putAll(Arrays.asList(KeyValue.pair(hello, world), KeyValue.pair(hi, there))); assertThat(deserializedValueFromInner(hello), equalTo(world)); assertThat(deserializedValueFromInner(hi), equalTo(there)); }
|
ChangeLoggingKeyValueStore extends WrappedStateStore.AbstractStateStore implements KeyValueStore<K, V> { @Override public V delete(final K key) { final byte[] oldValue = innerBytes.delete(Bytes.wrap(serdes.rawKey(key))); if (oldValue == null) { return null; } return serdes.valueFrom(oldValue); } ChangeLoggingKeyValueStore(final KeyValueStore<Bytes, byte[]> bytesStore,
final Serde keySerde,
final Serde valueSerde); private ChangeLoggingKeyValueStore(final ChangeLoggingKeyValueBytesStore bytesStore,
final Serde keySerde,
final Serde valueSerde); @SuppressWarnings("unchecked") @Override void init(final ProcessorContext context, final StateStore root); @Override long approximateNumEntries(); @Override void put(final K key, final V value); @Override V putIfAbsent(final K key, final V value); @Override void putAll(final List<KeyValue<K, V>> entries); @Override V delete(final K key); @Override V get(final K key); @Override KeyValueIterator<K, V> range(final K from, final K to); @Override KeyValueIterator<K, V> all(); }
|
@Test public void shouldReturnNullOnDeleteIfNoOldValue() throws Exception { assertThat(store.delete(hi), is(nullValue())); }
@Test public void shouldReturnNullOnDeleteIfNoOldValue() { assertThat(store.delete(hi), is(nullValue())); }
|
ChangeLoggingKeyValueStore extends WrappedStateStore.AbstractStateStore implements KeyValueStore<K, V> { @Override public V putIfAbsent(final K key, final V value) { final V v = get(key); if (v == null) { put(key, value); } return v; } ChangeLoggingKeyValueStore(final KeyValueStore<Bytes, byte[]> bytesStore,
final Serde keySerde,
final Serde valueSerde); private ChangeLoggingKeyValueStore(final ChangeLoggingKeyValueBytesStore bytesStore,
final Serde keySerde,
final Serde valueSerde); @SuppressWarnings("unchecked") @Override void init(final ProcessorContext context, final StateStore root); @Override long approximateNumEntries(); @Override void put(final K key, final V value); @Override V putIfAbsent(final K key, final V value); @Override void putAll(final List<KeyValue<K, V>> entries); @Override V delete(final K key); @Override V get(final K key); @Override KeyValueIterator<K, V> range(final K from, final K to); @Override KeyValueIterator<K, V> all(); }
|
@Test public void shouldReturnNullOnPutIfAbsentWhenNoPreviousValue() throws Exception { assertThat(store.putIfAbsent(hi, there), is(nullValue())); }
@Test public void shouldReturnNullOnPutIfAbsentWhenNoPreviousValue() { assertThat(store.putIfAbsent(hi, there), is(nullValue())); }
|
TimestampConverter implements Transformation<R> { @Override public void configure(Map<String, ?> configs) { final SimpleConfig simpleConfig = new SimpleConfig(CONFIG_DEF, configs); final String field = simpleConfig.getString(FIELD_CONFIG); final String type = simpleConfig.getString(TARGET_TYPE_CONFIG); String formatPattern = simpleConfig.getString(FORMAT_CONFIG); schemaUpdateCache = new SynchronizedCache<>(new LRUCache<Schema, Schema>(16)); if (!VALID_TYPES.contains(type)) { throw new ConfigException("Unknown timestamp type in TimestampConverter: " + type + ". Valid values are " + Utils.join(VALID_TYPES, ", ") + "."); } if (type.equals(TYPE_STRING) && formatPattern.trim().isEmpty()) { throw new ConfigException("TimestampConverter requires format option to be specified when using string timestamps"); } SimpleDateFormat format = null; if (formatPattern != null && !formatPattern.trim().isEmpty()) { try { format = new SimpleDateFormat(formatPattern); format.setTimeZone(UTC); } catch (IllegalArgumentException e) { throw new ConfigException("TimestampConverter requires a SimpleDateFormat-compatible pattern for string timestamps: " + formatPattern, e); } } config = new Config(field, type, format); } @Override void configure(Map<String, ?> configs); @Override R apply(R record); @Override ConfigDef config(); @Override void close(); static final String OVERVIEW_DOC; static final String FIELD_CONFIG; static final String TARGET_TYPE_CONFIG; static final String FORMAT_CONFIG; static final ConfigDef CONFIG_DEF; }
|
@Test(expected = ConfigException.class) public void testConfigNoTargetType() { TimestampConverter<SourceRecord> xform = new TimestampConverter.Value<>(); xform.configure(Collections.<String, String>emptyMap()); }
@Test(expected = ConfigException.class) public void testConfigInvalidTargetType() { TimestampConverter<SourceRecord> xform = new TimestampConverter.Value<>(); xform.configure(Collections.singletonMap(TimestampConverter.TARGET_TYPE_CONFIG, "invalid")); }
@Test(expected = ConfigException.class) public void testConfigMissingFormat() { TimestampConverter<SourceRecord> xform = new TimestampConverter.Value<>(); xform.configure(Collections.singletonMap(TimestampConverter.TARGET_TYPE_CONFIG, "string")); }
@Test(expected = ConfigException.class) public void testConfigInvalidFormat() { TimestampConverter<SourceRecord> xform = new TimestampConverter.Value<>(); Map<String, String> config = new HashMap<>(); config.put(TimestampConverter.TARGET_TYPE_CONFIG, "string"); config.put(TimestampConverter.FORMAT_CONFIG, "bad-format"); xform.configure(config); }
|
ChangeLoggingKeyValueStore extends WrappedStateStore.AbstractStateStore implements KeyValueStore<K, V> { @Override public V get(final K key) { final byte[] rawValue = innerBytes.get(Bytes.wrap(serdes.rawKey(key))); if (rawValue == null) { return null; } return serdes.valueFrom(rawValue); } ChangeLoggingKeyValueStore(final KeyValueStore<Bytes, byte[]> bytesStore,
final Serde keySerde,
final Serde valueSerde); private ChangeLoggingKeyValueStore(final ChangeLoggingKeyValueBytesStore bytesStore,
final Serde keySerde,
final Serde valueSerde); @SuppressWarnings("unchecked") @Override void init(final ProcessorContext context, final StateStore root); @Override long approximateNumEntries(); @Override void put(final K key, final V value); @Override V putIfAbsent(final K key, final V value); @Override void putAll(final List<KeyValue<K, V>> entries); @Override V delete(final K key); @Override V get(final K key); @Override KeyValueIterator<K, V> range(final K from, final K to); @Override KeyValueIterator<K, V> all(); }
|
@Test public void shouldReturnNullOnGetWhenDoesntExist() throws Exception { assertThat(store.get(hello), is(nullValue())); }
@Test public void shouldReturnNullOnGetWhenDoesntExist() { assertThat(store.get(hello), is(nullValue())); }
|
QueryableStoreProvider { public <T> T getStore(final String storeName, final QueryableStoreType<T> queryableStoreType) { final List<T> globalStore = globalStoreProvider.stores(storeName, queryableStoreType); if (!globalStore.isEmpty()) { return queryableStoreType.create(new WrappingStoreProvider(Collections.<StateStoreProvider>singletonList(globalStoreProvider)), storeName); } final List<T> allStores = new ArrayList<>(); for (StateStoreProvider storeProvider : storeProviders) { allStores.addAll(storeProvider.stores(storeName, queryableStoreType)); } if (allStores.isEmpty()) { throw new InvalidStateStoreException("the state store, " + storeName + ", may have migrated to another instance."); } return queryableStoreType.create( new WrappingStoreProvider(storeProviders), storeName); } QueryableStoreProvider(final List<StateStoreProvider> storeProviders,
final GlobalStateStoreProvider globalStateStoreProvider); T getStore(final String storeName, final QueryableStoreType<T> queryableStoreType); }
|
@Test(expected = InvalidStateStoreException.class) public void shouldThrowExceptionIfKVStoreDoesntExist() throws Exception { storeProvider.getStore("not-a-store", QueryableStoreTypes.keyValueStore()); }
@Test(expected = InvalidStateStoreException.class) public void shouldThrowExceptionIfWindowStoreDoesntExist() throws Exception { storeProvider.getStore("not-a-store", QueryableStoreTypes.windowStore()); }
@Test public void shouldReturnKVStoreWhenItExists() throws Exception { assertNotNull(storeProvider.getStore(keyValueStore, QueryableStoreTypes.keyValueStore())); }
@Test public void shouldReturnWindowStoreWhenItExists() throws Exception { assertNotNull(storeProvider.getStore(windowStore, QueryableStoreTypes.windowStore())); }
@Test(expected = InvalidStateStoreException.class) public void shouldThrowExceptionWhenLookingForWindowStoreWithDifferentType() throws Exception { storeProvider.getStore(windowStore, QueryableStoreTypes.keyValueStore()); }
@Test(expected = InvalidStateStoreException.class) public void shouldThrowExceptionWhenLookingForKVStoreWithDifferentType() throws Exception { storeProvider.getStore(keyValueStore, QueryableStoreTypes.windowStore()); }
@Test public void shouldFindGlobalStores() throws Exception { globalStateStores.put("global", new NoOpReadOnlyStore<>()); assertNotNull(storeProvider.getStore("global", QueryableStoreTypes.keyValueStore())); }
|
StoreChangeLogger { void logChange(final K key, final V value) { if (collector != null) { final Serializer<K> keySerializer = serialization.keySerializer(); final Serializer<V> valueSerializer = serialization.valueSerializer(); collector.send(this.topic, key, value, this.partition, context.timestamp(), keySerializer, valueSerializer); } } StoreChangeLogger(String storeName, ProcessorContext context, StateSerdes<K, V> serialization); private StoreChangeLogger(String storeName, ProcessorContext context, int partition, StateSerdes<K, V> serialization); }
|
@SuppressWarnings("unchecked") @Test public void testAddRemove() throws Exception { context.setTime(1); changeLogger.logChange(0, "zero"); changeLogger.logChange(1, "one"); changeLogger.logChange(2, "two"); assertEquals("zero", logged.get(0)); assertEquals("one", logged.get(1)); assertEquals("two", logged.get(2)); changeLogger.logChange(0, null); assertNull(logged.get(0)); }
|
KafkaStreams { public void close() { close(DEFAULT_CLOSE_TIMEOUT, TimeUnit.SECONDS); } KafkaStreams(final TopologyBuilder builder, final Properties props); KafkaStreams(final TopologyBuilder builder, final StreamsConfig config); KafkaStreams(final TopologyBuilder builder,
final StreamsConfig config,
final KafkaClientSupplier clientSupplier); void setStateListener(final KafkaStreams.StateListener listener); synchronized State state(); Map<MetricName, ? extends Metric> metrics(); synchronized void start(); void close(); synchronized boolean close(final long timeout, final TimeUnit timeUnit); @Override String toString(); String toString(final String indent); void cleanUp(); void setUncaughtExceptionHandler(final Thread.UncaughtExceptionHandler eh); Collection<StreamsMetadata> allMetadata(); Collection<StreamsMetadata> allMetadataForStore(final String storeName); StreamsMetadata metadataForKey(final String storeName,
final K key,
final Serializer<K> keySerializer); StreamsMetadata metadataForKey(final String storeName,
final K key,
final StreamPartitioner<? super K, ?> partitioner); T store(final String storeName, final QueryableStoreType<T> queryableStoreType); }
|
@Test public void testCloseIsIdempotent() throws Exception { streams.close(); final int closeCount = MockMetricsReporter.CLOSE_COUNT.get(); streams.close(); Assert.assertEquals("subsequent close() calls should do nothing", closeCount, MockMetricsReporter.CLOSE_COUNT.get()); }
|
KafkaStreams { public Map<MetricName, ? extends Metric> metrics() { return Collections.unmodifiableMap(metrics.metrics()); } KafkaStreams(final TopologyBuilder builder, final Properties props); KafkaStreams(final TopologyBuilder builder, final StreamsConfig config); KafkaStreams(final TopologyBuilder builder,
final StreamsConfig config,
final KafkaClientSupplier clientSupplier); void setStateListener(final KafkaStreams.StateListener listener); synchronized State state(); Map<MetricName, ? extends Metric> metrics(); synchronized void start(); void close(); synchronized boolean close(final long timeout, final TimeUnit timeUnit); @Override String toString(); String toString(final String indent); void cleanUp(); void setUncaughtExceptionHandler(final Thread.UncaughtExceptionHandler eh); Collection<StreamsMetadata> allMetadata(); Collection<StreamsMetadata> allMetadataForStore(final String storeName); StreamsMetadata metadataForKey(final String storeName,
final K key,
final Serializer<K> keySerializer); StreamsMetadata metadataForKey(final String storeName,
final K key,
final StreamPartitioner<? super K, ?> partitioner); T store(final String storeName, final QueryableStoreType<T> queryableStoreType); }
|
@Test public void testNumberDefaultMetrics() { final KafkaStreams streams = createKafkaStreams(); final Map<MetricName, ? extends Metric> metrics = streams.metrics(); assertEquals(metrics.size(), 16); }
|
KafkaStreams { public Collection<StreamsMetadata> allMetadata() { validateIsRunning(); return streamsMetadataState.getAllMetadata(); } KafkaStreams(final TopologyBuilder builder, final Properties props); KafkaStreams(final TopologyBuilder builder, final StreamsConfig config); KafkaStreams(final TopologyBuilder builder,
final StreamsConfig config,
final KafkaClientSupplier clientSupplier); void setStateListener(final KafkaStreams.StateListener listener); synchronized State state(); Map<MetricName, ? extends Metric> metrics(); synchronized void start(); void close(); synchronized boolean close(final long timeout, final TimeUnit timeUnit); @Override String toString(); String toString(final String indent); void cleanUp(); void setUncaughtExceptionHandler(final Thread.UncaughtExceptionHandler eh); Collection<StreamsMetadata> allMetadata(); Collection<StreamsMetadata> allMetadataForStore(final String storeName); StreamsMetadata metadataForKey(final String storeName,
final K key,
final Serializer<K> keySerializer); StreamsMetadata metadataForKey(final String storeName,
final K key,
final StreamPartitioner<? super K, ?> partitioner); T store(final String storeName, final QueryableStoreType<T> queryableStoreType); }
|
@Test(expected = IllegalStateException.class) public void shouldNotGetAllTasksWhenNotRunning() throws Exception { streams.allMetadata(); }
|
KafkaStreams { public Collection<StreamsMetadata> allMetadataForStore(final String storeName) { validateIsRunning(); return streamsMetadataState.getAllMetadataForStore(storeName); } KafkaStreams(final TopologyBuilder builder, final Properties props); KafkaStreams(final TopologyBuilder builder, final StreamsConfig config); KafkaStreams(final TopologyBuilder builder,
final StreamsConfig config,
final KafkaClientSupplier clientSupplier); void setStateListener(final KafkaStreams.StateListener listener); synchronized State state(); Map<MetricName, ? extends Metric> metrics(); synchronized void start(); void close(); synchronized boolean close(final long timeout, final TimeUnit timeUnit); @Override String toString(); String toString(final String indent); void cleanUp(); void setUncaughtExceptionHandler(final Thread.UncaughtExceptionHandler eh); Collection<StreamsMetadata> allMetadata(); Collection<StreamsMetadata> allMetadataForStore(final String storeName); StreamsMetadata metadataForKey(final String storeName,
final K key,
final Serializer<K> keySerializer); StreamsMetadata metadataForKey(final String storeName,
final K key,
final StreamPartitioner<? super K, ?> partitioner); T store(final String storeName, final QueryableStoreType<T> queryableStoreType); }
|
@Test(expected = IllegalStateException.class) public void shouldNotGetAllTasksWithStoreWhenNotRunning() throws Exception { streams.allMetadataForStore("store"); }
|
KafkaStreams { public <K> StreamsMetadata metadataForKey(final String storeName, final K key, final Serializer<K> keySerializer) { validateIsRunning(); return streamsMetadataState.getMetadataWithKey(storeName, key, keySerializer); } KafkaStreams(final TopologyBuilder builder, final Properties props); KafkaStreams(final TopologyBuilder builder, final StreamsConfig config); KafkaStreams(final TopologyBuilder builder,
final StreamsConfig config,
final KafkaClientSupplier clientSupplier); void setStateListener(final KafkaStreams.StateListener listener); synchronized State state(); Map<MetricName, ? extends Metric> metrics(); synchronized void start(); void close(); synchronized boolean close(final long timeout, final TimeUnit timeUnit); @Override String toString(); String toString(final String indent); void cleanUp(); void setUncaughtExceptionHandler(final Thread.UncaughtExceptionHandler eh); Collection<StreamsMetadata> allMetadata(); Collection<StreamsMetadata> allMetadataForStore(final String storeName); StreamsMetadata metadataForKey(final String storeName,
final K key,
final Serializer<K> keySerializer); StreamsMetadata metadataForKey(final String storeName,
final K key,
final StreamPartitioner<? super K, ?> partitioner); T store(final String storeName, final QueryableStoreType<T> queryableStoreType); }
|
@Test(expected = IllegalStateException.class) public void shouldNotGetTaskWithKeyAndSerializerWhenNotRunning() throws Exception { streams.metadataForKey("store", "key", Serdes.String().serializer()); }
@Test(expected = IllegalStateException.class) public void shouldNotGetTaskWithKeyAndPartitionerWhenNotRunning() throws Exception { streams.metadataForKey("store", "key", new StreamPartitioner<String, Object>() { @Override public Integer partition(final String key, final Object value, final int numPartitions) { return 0; } }); }
|
KafkaStreams { public void cleanUp() { if (state.isRunning()) { throw new IllegalStateException("Cannot clean up while running."); } final String appId = config.getString(StreamsConfig.APPLICATION_ID_CONFIG); final String stateDir = config.getString(StreamsConfig.STATE_DIR_CONFIG); final String localApplicationDir = stateDir + File.separator + appId; log.debug("{} Removing local Kafka Streams application data in {} for application {}.", logPrefix, localApplicationDir, appId); final StateDirectory stateDirectory = new StateDirectory(appId, "cleanup", stateDir, Time.SYSTEM); stateDirectory.cleanRemovedTasks(0); } KafkaStreams(final TopologyBuilder builder, final Properties props); KafkaStreams(final TopologyBuilder builder, final StreamsConfig config); KafkaStreams(final TopologyBuilder builder,
final StreamsConfig config,
final KafkaClientSupplier clientSupplier); void setStateListener(final KafkaStreams.StateListener listener); synchronized State state(); Map<MetricName, ? extends Metric> metrics(); synchronized void start(); void close(); synchronized boolean close(final long timeout, final TimeUnit timeUnit); @Override String toString(); String toString(final String indent); void cleanUp(); void setUncaughtExceptionHandler(final Thread.UncaughtExceptionHandler eh); Collection<StreamsMetadata> allMetadata(); Collection<StreamsMetadata> allMetadataForStore(final String storeName); StreamsMetadata metadataForKey(final String storeName,
final K key,
final Serializer<K> keySerializer); StreamsMetadata metadataForKey(final String storeName,
final K key,
final StreamPartitioner<? super K, ?> partitioner); T store(final String storeName, final QueryableStoreType<T> queryableStoreType); }
|
@Test public void testCleanup() throws Exception { final Properties props = new Properties(); props.setProperty(StreamsConfig.APPLICATION_ID_CONFIG, "testLocalCleanup"); props.setProperty(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, CLUSTER.bootstrapServers()); final KStreamBuilder builder = new KStreamBuilder(); final KafkaStreams streams = new KafkaStreams(builder, props); streams.cleanUp(); streams.start(); streams.close(); streams.cleanUp(); }
|
KafkaStreams { @Override public String toString() { return toString(""); } KafkaStreams(final TopologyBuilder builder, final Properties props); KafkaStreams(final TopologyBuilder builder, final StreamsConfig config); KafkaStreams(final TopologyBuilder builder,
final StreamsConfig config,
final KafkaClientSupplier clientSupplier); void setStateListener(final KafkaStreams.StateListener listener); synchronized State state(); Map<MetricName, ? extends Metric> metrics(); synchronized void start(); void close(); synchronized boolean close(final long timeout, final TimeUnit timeUnit); @Override String toString(); String toString(final String indent); void cleanUp(); void setUncaughtExceptionHandler(final Thread.UncaughtExceptionHandler eh); Collection<StreamsMetadata> allMetadata(); Collection<StreamsMetadata> allMetadataForStore(final String storeName); StreamsMetadata metadataForKey(final String storeName,
final K key,
final Serializer<K> keySerializer); StreamsMetadata metadataForKey(final String storeName,
final K key,
final StreamPartitioner<? super K, ?> partitioner); T store(final String storeName, final QueryableStoreType<T> queryableStoreType); }
|
@Test public void testToString() { streams.start(); String streamString = streams.toString(); streams.close(); String appId = streamString.split("\\n")[1].split(":")[1].trim(); Assert.assertNotEquals("streamString should not be empty", "", streamString); Assert.assertNotNull("streamString should not be null", streamString); Assert.assertNotEquals("streamString contains non-empty appId", "", appId); Assert.assertNotNull("streamString contains non-null appId", appId); }
|
Windows { protected Windows<W> segments(final int segments) throws IllegalArgumentException { if (segments < 2) { throw new IllegalArgumentException("Number of segments must be at least 2."); } this.segments = segments; return this; } protected Windows(); Windows<W> until(final long durationMs); long maintainMs(); abstract Map<Long, W> windowsFor(final long timestamp); abstract long size(); public int segments; }
|
@Test public void shouldSetNumberOfSegments() { final int anySegmentSizeLargerThanOne = 5; assertEquals(anySegmentSizeLargerThanOne, new TestWindows().segments(anySegmentSizeLargerThanOne).segments); }
@Test(expected = IllegalArgumentException.class) public void numberOfSegmentsMustBeAtLeastTwo() { new TestWindows().segments(1); }
|
Windows { public Windows<W> until(final long durationMs) throws IllegalArgumentException { if (durationMs < 0) { throw new IllegalArgumentException("Window retention time (durationMs) cannot be negative."); } maintainDurationMs = durationMs; return this; } protected Windows(); Windows<W> until(final long durationMs); long maintainMs(); abstract Map<Long, W> windowsFor(final long timestamp); abstract long size(); public int segments; }
|
@Test(expected = IllegalArgumentException.class) public void retentionTimeMustNotBeNegative() { new TestWindows().until(-1); }
|
KStreamBuilder extends TopologyBuilder { public <K, V> KStream<K, V> stream(final String... topics) { return stream(null, null, null, null, topics); } KStream<K, V> stream(final String... topics); KStream<K, V> stream(final AutoOffsetReset offsetReset,
final String... topics); KStream<K, V> stream(final Pattern topicPattern); KStream<K, V> stream(final AutoOffsetReset offsetReset, final Pattern topicPattern); KStream<K, V> stream(final Serde<K> keySerde, final Serde<V> valSerde, final String... topics); KStream<K, V> stream(final AutoOffsetReset offsetReset,
final Serde<K> keySerde,
final Serde<V> valSerde,
final String... topics); KStream<K, V> stream(final TimestampExtractor timestampExtractor,
final Serde<K> keySerde,
final Serde<V> valSerde,
final String... topics); KStream<K, V> stream(final AutoOffsetReset offsetReset,
final TimestampExtractor timestampExtractor,
final Serde<K> keySerde,
final Serde<V> valSerde,
final String... topics); KStream<K, V> stream(final Serde<K> keySerde,
final Serde<V> valSerde,
final Pattern topicPattern); KStream<K, V> stream(final AutoOffsetReset offsetReset,
final Serde<K> keySerde,
final Serde<V> valSerde,
final Pattern topicPattern); KStream<K, V> stream(final TimestampExtractor timestampExtractor,
final Serde<K> keySerde,
final Serde<V> valSerde,
final Pattern topicPattern); KStream<K, V> stream(final AutoOffsetReset offsetReset,
final TimestampExtractor timestampExtractor,
final Serde<K> keySerde,
final Serde<V> valSerde,
final Pattern topicPattern); KTable<K, V> table(final String topic,
final String queryableStoreName); KTable<K, V> table(final String topic,
final StateStoreSupplier<KeyValueStore> storeSupplier); KTable<K, V> table(final String topic); KTable<K, V> table(final AutoOffsetReset offsetReset,
final String topic,
final String queryableStoreName); KTable<K, V> table(final AutoOffsetReset offsetReset,
final String topic,
final StateStoreSupplier<KeyValueStore> storeSupplier); KTable<K, V> table(final AutoOffsetReset offsetReset,
final String topic); KTable<K, V> table(final TimestampExtractor timestampExtractor,
final String topic,
final String storeName); KTable<K, V> table(final AutoOffsetReset offsetReset,
final TimestampExtractor timestampExtractor,
final String topic,
final String storeName); KTable<K, V> table(final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic,
final String queryableStoreName); KTable<K, V> table(final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic,
final StateStoreSupplier<KeyValueStore> storeSupplier); KTable<K, V> table(final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic); KTable<K, V> table(final AutoOffsetReset offsetReset,
final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic,
final String queryableStoreName); KTable<K, V> table(final TimestampExtractor timestampExtractor,
final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic,
final String storeName); KTable<K, V> table(final AutoOffsetReset offsetReset,
final TimestampExtractor timestampExtractor,
final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic,
final String queryableStoreName); KTable<K, V> table(final AutoOffsetReset offsetReset,
final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic); KTable<K, V> table(final AutoOffsetReset offsetReset,
final TimestampExtractor timestampExtractor,
final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic,
final StateStoreSupplier<KeyValueStore> storeSupplier); GlobalKTable<K, V> globalTable(final String topic,
final String queryableStoreName); GlobalKTable<K, V> globalTable(final String topic); @SuppressWarnings("unchecked") GlobalKTable<K, V> globalTable(final Serde<K> keySerde,
final Serde<V> valSerde,
final TimestampExtractor timestampExtractor,
final String topic,
final String queryableStoreName); @SuppressWarnings("unchecked") GlobalKTable<K, V> globalTable(final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic,
final StateStoreSupplier<KeyValueStore> storeSupplier); @SuppressWarnings("unchecked") GlobalKTable<K, V> globalTable(final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic,
final String queryableStoreName); @SuppressWarnings("unchecked") GlobalKTable<K, V> globalTable(final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic); KStream<K, V> merge(final KStream<K, V>... streams); String newName(final String prefix); String newStoreName(final String prefix); }
|
@Test(expected = TopologyBuilderException.class) public void testFrom() { builder.stream("topic-1", "topic-2"); builder.addSource(KStreamImpl.SOURCE_NAME + "0000000000", "topic-3"); }
@Test public void shouldNotTryProcessingFromSinkTopic() { final KStream<String, String> source = builder.stream("topic-source"); source.to("topic-sink"); final MockProcessorSupplier<String, String> processorSupplier = new MockProcessorSupplier<>(); source.process(processorSupplier); driver = new KStreamTestDriver(builder); driver.setTime(0L); driver.process("topic-source", "A", "aa"); assertEquals(Utils.mkList("A:aa"), processorSupplier.processed); }
@Test public void shouldTryProcessingFromThoughTopic() { final KStream<String, String> source = builder.stream("topic-source"); final KStream<String, String> through = source.through("topic-sink"); final MockProcessorSupplier<String, String> sourceProcessorSupplier = new MockProcessorSupplier<>(); final MockProcessorSupplier<String, String> throughProcessorSupplier = new MockProcessorSupplier<>(); source.process(sourceProcessorSupplier); through.process(throughProcessorSupplier); driver = new KStreamTestDriver(builder); driver.setTime(0L); driver.process("topic-source", "A", "aa"); assertEquals(Utils.mkList("A:aa"), sourceProcessorSupplier.processed); assertEquals(Utils.mkList("A:aa"), throughProcessorSupplier.processed); }
@Test(expected = TopologyBuilderException.class) public void shouldThrowExceptionWhenNoTopicPresent() throws Exception { builder.stream(); }
@Test(expected = NullPointerException.class) public void shouldThrowExceptionWhenTopicNamesAreNull() throws Exception { builder.stream(Serdes.String(), Serdes.String(), null, null); }
@Test public void shouldAddTopicToEarliestAutoOffsetResetList() { final String topicName = "topic-1"; builder.stream(TopologyBuilder.AutoOffsetReset.EARLIEST, topicName); assertTrue(builder.earliestResetTopicsPattern().matcher(topicName).matches()); assertFalse(builder.latestResetTopicsPattern().matcher(topicName).matches()); }
@Test public void shouldAddTopicToLatestAutoOffsetResetList() { final String topicName = "topic-1"; builder.stream(TopologyBuilder.AutoOffsetReset.LATEST, topicName); assertTrue(builder.latestResetTopicsPattern().matcher(topicName).matches()); assertFalse(builder.earliestResetTopicsPattern().matcher(topicName).matches()); }
@Test public void shouldNotAddRegexTopicsToOffsetResetLists() { final Pattern topicPattern = Pattern.compile("topic-\\d"); final String topic = "topic-5"; builder.stream(topicPattern); assertFalse(builder.latestResetTopicsPattern().matcher(topic).matches()); assertFalse(builder.earliestResetTopicsPattern().matcher(topic).matches()); }
@Test public void shouldAddRegexTopicToEarliestAutoOffsetResetList() { final Pattern topicPattern = Pattern.compile("topic-\\d+"); final String topicTwo = "topic-500000"; builder.stream(TopologyBuilder.AutoOffsetReset.EARLIEST, topicPattern); assertTrue(builder.earliestResetTopicsPattern().matcher(topicTwo).matches()); assertFalse(builder.latestResetTopicsPattern().matcher(topicTwo).matches()); }
@Test public void shouldAddRegexTopicToLatestAutoOffsetResetList() { final Pattern topicPattern = Pattern.compile("topic-\\d+"); final String topicTwo = "topic-1000000"; builder.stream(TopologyBuilder.AutoOffsetReset.LATEST, topicPattern); assertTrue(builder.latestResetTopicsPattern().matcher(topicTwo).matches()); assertFalse(builder.earliestResetTopicsPattern().matcher(topicTwo).matches()); }
@SuppressWarnings("unchecked") @Test public void kStreamTimestampExtractorShouldBeNull() throws Exception { builder.stream("topic"); final ProcessorTopology processorTopology = builder.build(null); assertNull(processorTopology.source("topic").getTimestampExtractor()); }
@SuppressWarnings("unchecked") @Test public void shouldAddTimestampExtractorToStreamWithKeyValSerdePerSource() throws Exception { builder.stream(new MockTimestampExtractor(), null, null, "topic"); final ProcessorTopology processorTopology = builder.build(null); for (final SourceNode sourceNode: processorTopology.sources()) { assertThat(sourceNode.getTimestampExtractor(), instanceOf(MockTimestampExtractor.class)); } }
@SuppressWarnings("unchecked") @Test public void shouldAddTimestampExtractorToStreamWithOffsetResetPerSource() throws Exception { builder.stream(null, new MockTimestampExtractor(), null, null, "topic"); final ProcessorTopology processorTopology = builder.build(null); assertThat(processorTopology.source("topic").getTimestampExtractor(), instanceOf(MockTimestampExtractor.class)); }
|
KStreamBuilder extends TopologyBuilder { public String newName(final String prefix) { return prefix + String.format("%010d", index.getAndIncrement()); } KStream<K, V> stream(final String... topics); KStream<K, V> stream(final AutoOffsetReset offsetReset,
final String... topics); KStream<K, V> stream(final Pattern topicPattern); KStream<K, V> stream(final AutoOffsetReset offsetReset, final Pattern topicPattern); KStream<K, V> stream(final Serde<K> keySerde, final Serde<V> valSerde, final String... topics); KStream<K, V> stream(final AutoOffsetReset offsetReset,
final Serde<K> keySerde,
final Serde<V> valSerde,
final String... topics); KStream<K, V> stream(final TimestampExtractor timestampExtractor,
final Serde<K> keySerde,
final Serde<V> valSerde,
final String... topics); KStream<K, V> stream(final AutoOffsetReset offsetReset,
final TimestampExtractor timestampExtractor,
final Serde<K> keySerde,
final Serde<V> valSerde,
final String... topics); KStream<K, V> stream(final Serde<K> keySerde,
final Serde<V> valSerde,
final Pattern topicPattern); KStream<K, V> stream(final AutoOffsetReset offsetReset,
final Serde<K> keySerde,
final Serde<V> valSerde,
final Pattern topicPattern); KStream<K, V> stream(final TimestampExtractor timestampExtractor,
final Serde<K> keySerde,
final Serde<V> valSerde,
final Pattern topicPattern); KStream<K, V> stream(final AutoOffsetReset offsetReset,
final TimestampExtractor timestampExtractor,
final Serde<K> keySerde,
final Serde<V> valSerde,
final Pattern topicPattern); KTable<K, V> table(final String topic,
final String queryableStoreName); KTable<K, V> table(final String topic,
final StateStoreSupplier<KeyValueStore> storeSupplier); KTable<K, V> table(final String topic); KTable<K, V> table(final AutoOffsetReset offsetReset,
final String topic,
final String queryableStoreName); KTable<K, V> table(final AutoOffsetReset offsetReset,
final String topic,
final StateStoreSupplier<KeyValueStore> storeSupplier); KTable<K, V> table(final AutoOffsetReset offsetReset,
final String topic); KTable<K, V> table(final TimestampExtractor timestampExtractor,
final String topic,
final String storeName); KTable<K, V> table(final AutoOffsetReset offsetReset,
final TimestampExtractor timestampExtractor,
final String topic,
final String storeName); KTable<K, V> table(final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic,
final String queryableStoreName); KTable<K, V> table(final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic,
final StateStoreSupplier<KeyValueStore> storeSupplier); KTable<K, V> table(final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic); KTable<K, V> table(final AutoOffsetReset offsetReset,
final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic,
final String queryableStoreName); KTable<K, V> table(final TimestampExtractor timestampExtractor,
final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic,
final String storeName); KTable<K, V> table(final AutoOffsetReset offsetReset,
final TimestampExtractor timestampExtractor,
final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic,
final String queryableStoreName); KTable<K, V> table(final AutoOffsetReset offsetReset,
final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic); KTable<K, V> table(final AutoOffsetReset offsetReset,
final TimestampExtractor timestampExtractor,
final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic,
final StateStoreSupplier<KeyValueStore> storeSupplier); GlobalKTable<K, V> globalTable(final String topic,
final String queryableStoreName); GlobalKTable<K, V> globalTable(final String topic); @SuppressWarnings("unchecked") GlobalKTable<K, V> globalTable(final Serde<K> keySerde,
final Serde<V> valSerde,
final TimestampExtractor timestampExtractor,
final String topic,
final String queryableStoreName); @SuppressWarnings("unchecked") GlobalKTable<K, V> globalTable(final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic,
final StateStoreSupplier<KeyValueStore> storeSupplier); @SuppressWarnings("unchecked") GlobalKTable<K, V> globalTable(final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic,
final String queryableStoreName); @SuppressWarnings("unchecked") GlobalKTable<K, V> globalTable(final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic); KStream<K, V> merge(final KStream<K, V>... streams); String newName(final String prefix); String newStoreName(final String prefix); }
|
@Test public void testNewName() { assertEquals("X-0000000000", builder.newName("X-")); assertEquals("Y-0000000001", builder.newName("Y-")); assertEquals("Z-0000000002", builder.newName("Z-")); final KStreamBuilder newBuilder = new KStreamBuilder(); assertEquals("X-0000000000", newBuilder.newName("X-")); assertEquals("Y-0000000001", newBuilder.newName("Y-")); assertEquals("Z-0000000002", newBuilder.newName("Z-")); }
|
KStreamBuilder extends TopologyBuilder { public String newStoreName(final String prefix) { return prefix + String.format(KTableImpl.STATE_STORE_NAME + "%010d", index.getAndIncrement()); } KStream<K, V> stream(final String... topics); KStream<K, V> stream(final AutoOffsetReset offsetReset,
final String... topics); KStream<K, V> stream(final Pattern topicPattern); KStream<K, V> stream(final AutoOffsetReset offsetReset, final Pattern topicPattern); KStream<K, V> stream(final Serde<K> keySerde, final Serde<V> valSerde, final String... topics); KStream<K, V> stream(final AutoOffsetReset offsetReset,
final Serde<K> keySerde,
final Serde<V> valSerde,
final String... topics); KStream<K, V> stream(final TimestampExtractor timestampExtractor,
final Serde<K> keySerde,
final Serde<V> valSerde,
final String... topics); KStream<K, V> stream(final AutoOffsetReset offsetReset,
final TimestampExtractor timestampExtractor,
final Serde<K> keySerde,
final Serde<V> valSerde,
final String... topics); KStream<K, V> stream(final Serde<K> keySerde,
final Serde<V> valSerde,
final Pattern topicPattern); KStream<K, V> stream(final AutoOffsetReset offsetReset,
final Serde<K> keySerde,
final Serde<V> valSerde,
final Pattern topicPattern); KStream<K, V> stream(final TimestampExtractor timestampExtractor,
final Serde<K> keySerde,
final Serde<V> valSerde,
final Pattern topicPattern); KStream<K, V> stream(final AutoOffsetReset offsetReset,
final TimestampExtractor timestampExtractor,
final Serde<K> keySerde,
final Serde<V> valSerde,
final Pattern topicPattern); KTable<K, V> table(final String topic,
final String queryableStoreName); KTable<K, V> table(final String topic,
final StateStoreSupplier<KeyValueStore> storeSupplier); KTable<K, V> table(final String topic); KTable<K, V> table(final AutoOffsetReset offsetReset,
final String topic,
final String queryableStoreName); KTable<K, V> table(final AutoOffsetReset offsetReset,
final String topic,
final StateStoreSupplier<KeyValueStore> storeSupplier); KTable<K, V> table(final AutoOffsetReset offsetReset,
final String topic); KTable<K, V> table(final TimestampExtractor timestampExtractor,
final String topic,
final String storeName); KTable<K, V> table(final AutoOffsetReset offsetReset,
final TimestampExtractor timestampExtractor,
final String topic,
final String storeName); KTable<K, V> table(final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic,
final String queryableStoreName); KTable<K, V> table(final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic,
final StateStoreSupplier<KeyValueStore> storeSupplier); KTable<K, V> table(final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic); KTable<K, V> table(final AutoOffsetReset offsetReset,
final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic,
final String queryableStoreName); KTable<K, V> table(final TimestampExtractor timestampExtractor,
final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic,
final String storeName); KTable<K, V> table(final AutoOffsetReset offsetReset,
final TimestampExtractor timestampExtractor,
final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic,
final String queryableStoreName); KTable<K, V> table(final AutoOffsetReset offsetReset,
final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic); KTable<K, V> table(final AutoOffsetReset offsetReset,
final TimestampExtractor timestampExtractor,
final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic,
final StateStoreSupplier<KeyValueStore> storeSupplier); GlobalKTable<K, V> globalTable(final String topic,
final String queryableStoreName); GlobalKTable<K, V> globalTable(final String topic); @SuppressWarnings("unchecked") GlobalKTable<K, V> globalTable(final Serde<K> keySerde,
final Serde<V> valSerde,
final TimestampExtractor timestampExtractor,
final String topic,
final String queryableStoreName); @SuppressWarnings("unchecked") GlobalKTable<K, V> globalTable(final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic,
final StateStoreSupplier<KeyValueStore> storeSupplier); @SuppressWarnings("unchecked") GlobalKTable<K, V> globalTable(final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic,
final String queryableStoreName); @SuppressWarnings("unchecked") GlobalKTable<K, V> globalTable(final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic); KStream<K, V> merge(final KStream<K, V>... streams); String newName(final String prefix); String newStoreName(final String prefix); }
|
@Test public void testNewStoreName() { assertEquals("X-STATE-STORE-0000000000", builder.newStoreName("X-")); assertEquals("Y-STATE-STORE-0000000001", builder.newStoreName("Y-")); assertEquals("Z-STATE-STORE-0000000002", builder.newStoreName("Z-")); KStreamBuilder newBuilder = new KStreamBuilder(); assertEquals("X-STATE-STORE-0000000000", newBuilder.newStoreName("X-")); assertEquals("Y-STATE-STORE-0000000001", newBuilder.newStoreName("Y-")); assertEquals("Z-STATE-STORE-0000000002", newBuilder.newStoreName("Z-")); }
|
KStreamBuilder extends TopologyBuilder { public <K, V> KStream<K, V> merge(final KStream<K, V>... streams) { return KStreamImpl.merge(this, streams); } KStream<K, V> stream(final String... topics); KStream<K, V> stream(final AutoOffsetReset offsetReset,
final String... topics); KStream<K, V> stream(final Pattern topicPattern); KStream<K, V> stream(final AutoOffsetReset offsetReset, final Pattern topicPattern); KStream<K, V> stream(final Serde<K> keySerde, final Serde<V> valSerde, final String... topics); KStream<K, V> stream(final AutoOffsetReset offsetReset,
final Serde<K> keySerde,
final Serde<V> valSerde,
final String... topics); KStream<K, V> stream(final TimestampExtractor timestampExtractor,
final Serde<K> keySerde,
final Serde<V> valSerde,
final String... topics); KStream<K, V> stream(final AutoOffsetReset offsetReset,
final TimestampExtractor timestampExtractor,
final Serde<K> keySerde,
final Serde<V> valSerde,
final String... topics); KStream<K, V> stream(final Serde<K> keySerde,
final Serde<V> valSerde,
final Pattern topicPattern); KStream<K, V> stream(final AutoOffsetReset offsetReset,
final Serde<K> keySerde,
final Serde<V> valSerde,
final Pattern topicPattern); KStream<K, V> stream(final TimestampExtractor timestampExtractor,
final Serde<K> keySerde,
final Serde<V> valSerde,
final Pattern topicPattern); KStream<K, V> stream(final AutoOffsetReset offsetReset,
final TimestampExtractor timestampExtractor,
final Serde<K> keySerde,
final Serde<V> valSerde,
final Pattern topicPattern); KTable<K, V> table(final String topic,
final String queryableStoreName); KTable<K, V> table(final String topic,
final StateStoreSupplier<KeyValueStore> storeSupplier); KTable<K, V> table(final String topic); KTable<K, V> table(final AutoOffsetReset offsetReset,
final String topic,
final String queryableStoreName); KTable<K, V> table(final AutoOffsetReset offsetReset,
final String topic,
final StateStoreSupplier<KeyValueStore> storeSupplier); KTable<K, V> table(final AutoOffsetReset offsetReset,
final String topic); KTable<K, V> table(final TimestampExtractor timestampExtractor,
final String topic,
final String storeName); KTable<K, V> table(final AutoOffsetReset offsetReset,
final TimestampExtractor timestampExtractor,
final String topic,
final String storeName); KTable<K, V> table(final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic,
final String queryableStoreName); KTable<K, V> table(final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic,
final StateStoreSupplier<KeyValueStore> storeSupplier); KTable<K, V> table(final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic); KTable<K, V> table(final AutoOffsetReset offsetReset,
final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic,
final String queryableStoreName); KTable<K, V> table(final TimestampExtractor timestampExtractor,
final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic,
final String storeName); KTable<K, V> table(final AutoOffsetReset offsetReset,
final TimestampExtractor timestampExtractor,
final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic,
final String queryableStoreName); KTable<K, V> table(final AutoOffsetReset offsetReset,
final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic); KTable<K, V> table(final AutoOffsetReset offsetReset,
final TimestampExtractor timestampExtractor,
final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic,
final StateStoreSupplier<KeyValueStore> storeSupplier); GlobalKTable<K, V> globalTable(final String topic,
final String queryableStoreName); GlobalKTable<K, V> globalTable(final String topic); @SuppressWarnings("unchecked") GlobalKTable<K, V> globalTable(final Serde<K> keySerde,
final Serde<V> valSerde,
final TimestampExtractor timestampExtractor,
final String topic,
final String queryableStoreName); @SuppressWarnings("unchecked") GlobalKTable<K, V> globalTable(final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic,
final StateStoreSupplier<KeyValueStore> storeSupplier); @SuppressWarnings("unchecked") GlobalKTable<K, V> globalTable(final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic,
final String queryableStoreName); @SuppressWarnings("unchecked") GlobalKTable<K, V> globalTable(final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic); KStream<K, V> merge(final KStream<K, V>... streams); String newName(final String prefix); String newStoreName(final String prefix); }
|
@Test public void testMerge() { final String topic1 = "topic-1"; final String topic2 = "topic-2"; final KStream<String, String> source1 = builder.stream(topic1); final KStream<String, String> source2 = builder.stream(topic2); final KStream<String, String> merged = builder.merge(source1, source2); final MockProcessorSupplier<String, String> processorSupplier = new MockProcessorSupplier<>(); merged.process(processorSupplier); driver = new KStreamTestDriver(builder); driver.setTime(0L); driver.process(topic1, "A", "aa"); driver.process(topic2, "B", "bb"); driver.process(topic2, "C", "cc"); driver.process(topic1, "D", "dd"); assertEquals(Utils.mkList("A:aa", "B:bb", "C:cc", "D:dd"), processorSupplier.processed); }
|
KStreamBuilder extends TopologyBuilder { public <K, V> KTable<K, V> table(final String topic, final String queryableStoreName) { return table(null, null, null, null, topic, queryableStoreName); } KStream<K, V> stream(final String... topics); KStream<K, V> stream(final AutoOffsetReset offsetReset,
final String... topics); KStream<K, V> stream(final Pattern topicPattern); KStream<K, V> stream(final AutoOffsetReset offsetReset, final Pattern topicPattern); KStream<K, V> stream(final Serde<K> keySerde, final Serde<V> valSerde, final String... topics); KStream<K, V> stream(final AutoOffsetReset offsetReset,
final Serde<K> keySerde,
final Serde<V> valSerde,
final String... topics); KStream<K, V> stream(final TimestampExtractor timestampExtractor,
final Serde<K> keySerde,
final Serde<V> valSerde,
final String... topics); KStream<K, V> stream(final AutoOffsetReset offsetReset,
final TimestampExtractor timestampExtractor,
final Serde<K> keySerde,
final Serde<V> valSerde,
final String... topics); KStream<K, V> stream(final Serde<K> keySerde,
final Serde<V> valSerde,
final Pattern topicPattern); KStream<K, V> stream(final AutoOffsetReset offsetReset,
final Serde<K> keySerde,
final Serde<V> valSerde,
final Pattern topicPattern); KStream<K, V> stream(final TimestampExtractor timestampExtractor,
final Serde<K> keySerde,
final Serde<V> valSerde,
final Pattern topicPattern); KStream<K, V> stream(final AutoOffsetReset offsetReset,
final TimestampExtractor timestampExtractor,
final Serde<K> keySerde,
final Serde<V> valSerde,
final Pattern topicPattern); KTable<K, V> table(final String topic,
final String queryableStoreName); KTable<K, V> table(final String topic,
final StateStoreSupplier<KeyValueStore> storeSupplier); KTable<K, V> table(final String topic); KTable<K, V> table(final AutoOffsetReset offsetReset,
final String topic,
final String queryableStoreName); KTable<K, V> table(final AutoOffsetReset offsetReset,
final String topic,
final StateStoreSupplier<KeyValueStore> storeSupplier); KTable<K, V> table(final AutoOffsetReset offsetReset,
final String topic); KTable<K, V> table(final TimestampExtractor timestampExtractor,
final String topic,
final String storeName); KTable<K, V> table(final AutoOffsetReset offsetReset,
final TimestampExtractor timestampExtractor,
final String topic,
final String storeName); KTable<K, V> table(final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic,
final String queryableStoreName); KTable<K, V> table(final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic,
final StateStoreSupplier<KeyValueStore> storeSupplier); KTable<K, V> table(final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic); KTable<K, V> table(final AutoOffsetReset offsetReset,
final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic,
final String queryableStoreName); KTable<K, V> table(final TimestampExtractor timestampExtractor,
final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic,
final String storeName); KTable<K, V> table(final AutoOffsetReset offsetReset,
final TimestampExtractor timestampExtractor,
final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic,
final String queryableStoreName); KTable<K, V> table(final AutoOffsetReset offsetReset,
final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic); KTable<K, V> table(final AutoOffsetReset offsetReset,
final TimestampExtractor timestampExtractor,
final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic,
final StateStoreSupplier<KeyValueStore> storeSupplier); GlobalKTable<K, V> globalTable(final String topic,
final String queryableStoreName); GlobalKTable<K, V> globalTable(final String topic); @SuppressWarnings("unchecked") GlobalKTable<K, V> globalTable(final Serde<K> keySerde,
final Serde<V> valSerde,
final TimestampExtractor timestampExtractor,
final String topic,
final String queryableStoreName); @SuppressWarnings("unchecked") GlobalKTable<K, V> globalTable(final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic,
final StateStoreSupplier<KeyValueStore> storeSupplier); @SuppressWarnings("unchecked") GlobalKTable<K, V> globalTable(final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic,
final String queryableStoreName); @SuppressWarnings("unchecked") GlobalKTable<K, V> globalTable(final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic); KStream<K, V> merge(final KStream<K, V>... streams); String newName(final String prefix); String newStoreName(final String prefix); }
|
@Test public void shouldStillMaterializeSourceKTableIfStateNameNotSpecified() throws Exception { KTable table1 = builder.table("topic1", "table1"); KTable table2 = builder.table("topic2", (String) null); final ProcessorTopology topology = builder.build(null); assertEquals(2, topology.stateStores().size()); assertEquals("table1", topology.stateStores().get(0).name()); final String internalStoreName = topology.stateStores().get(1).name(); assertTrue(internalStoreName.contains(KTableImpl.STATE_STORE_NAME)); assertEquals(2, topology.storeToChangelogTopic().size()); assertEquals("topic1", topology.storeToChangelogTopic().get("table1")); assertEquals("topic2", topology.storeToChangelogTopic().get(internalStoreName)); assertEquals(table1.queryableStoreName(), "table1"); assertNull(table2.queryableStoreName()); }
@Test public void shouldAddTableToEarliestAutoOffsetResetList() { final String topicName = "topic-1"; final String storeName = "test-store"; builder.table(TopologyBuilder.AutoOffsetReset.EARLIEST, topicName, storeName); assertTrue(builder.earliestResetTopicsPattern().matcher(topicName).matches()); assertFalse(builder.latestResetTopicsPattern().matcher(topicName).matches()); }
@Test public void shouldAddTableToLatestAutoOffsetResetList() { final String topicName = "topic-1"; final String storeName = "test-store"; builder.table(TopologyBuilder.AutoOffsetReset.LATEST, topicName, storeName); assertTrue(builder.latestResetTopicsPattern().matcher(topicName).matches()); assertFalse(builder.earliestResetTopicsPattern().matcher(topicName).matches()); }
@Test public void shouldNotAddTableToOffsetResetLists() { final String topicName = "topic-1"; final String storeName = "test-store"; final Serde<String> stringSerde = Serdes.String(); builder.table(stringSerde, stringSerde, topicName, storeName); assertFalse(builder.latestResetTopicsPattern().matcher(topicName).matches()); assertFalse(builder.earliestResetTopicsPattern().matcher(topicName).matches()); }
@SuppressWarnings("unchecked") @Test public void shouldAddTimestampExtractorToTablePerSource() throws Exception { builder.table("topic", "store"); final ProcessorTopology processorTopology = builder.build(null); assertNull(processorTopology.source("topic").getTimestampExtractor()); }
@SuppressWarnings("unchecked") @Test public void kTableTimestampExtractorShouldBeNull() throws Exception { builder.table("topic", "store"); final ProcessorTopology processorTopology = builder.build(null); assertNull(processorTopology.source("topic").getTimestampExtractor()); }
@SuppressWarnings("unchecked") @Test public void shouldAddTimestampExtractorToTableWithKeyValSerdePerSource() throws Exception { builder.table(null, new MockTimestampExtractor(), null, null, "topic", "store"); final ProcessorTopology processorTopology = builder.build(null); assertThat(processorTopology.source("topic").getTimestampExtractor(), instanceOf(MockTimestampExtractor.class)); }
|
KStreamBuilder extends TopologyBuilder { public <K, V> GlobalKTable<K, V> globalTable(final String topic, final String queryableStoreName) { return globalTable(null, null, null, topic, queryableStoreName); } KStream<K, V> stream(final String... topics); KStream<K, V> stream(final AutoOffsetReset offsetReset,
final String... topics); KStream<K, V> stream(final Pattern topicPattern); KStream<K, V> stream(final AutoOffsetReset offsetReset, final Pattern topicPattern); KStream<K, V> stream(final Serde<K> keySerde, final Serde<V> valSerde, final String... topics); KStream<K, V> stream(final AutoOffsetReset offsetReset,
final Serde<K> keySerde,
final Serde<V> valSerde,
final String... topics); KStream<K, V> stream(final TimestampExtractor timestampExtractor,
final Serde<K> keySerde,
final Serde<V> valSerde,
final String... topics); KStream<K, V> stream(final AutoOffsetReset offsetReset,
final TimestampExtractor timestampExtractor,
final Serde<K> keySerde,
final Serde<V> valSerde,
final String... topics); KStream<K, V> stream(final Serde<K> keySerde,
final Serde<V> valSerde,
final Pattern topicPattern); KStream<K, V> stream(final AutoOffsetReset offsetReset,
final Serde<K> keySerde,
final Serde<V> valSerde,
final Pattern topicPattern); KStream<K, V> stream(final TimestampExtractor timestampExtractor,
final Serde<K> keySerde,
final Serde<V> valSerde,
final Pattern topicPattern); KStream<K, V> stream(final AutoOffsetReset offsetReset,
final TimestampExtractor timestampExtractor,
final Serde<K> keySerde,
final Serde<V> valSerde,
final Pattern topicPattern); KTable<K, V> table(final String topic,
final String queryableStoreName); KTable<K, V> table(final String topic,
final StateStoreSupplier<KeyValueStore> storeSupplier); KTable<K, V> table(final String topic); KTable<K, V> table(final AutoOffsetReset offsetReset,
final String topic,
final String queryableStoreName); KTable<K, V> table(final AutoOffsetReset offsetReset,
final String topic,
final StateStoreSupplier<KeyValueStore> storeSupplier); KTable<K, V> table(final AutoOffsetReset offsetReset,
final String topic); KTable<K, V> table(final TimestampExtractor timestampExtractor,
final String topic,
final String storeName); KTable<K, V> table(final AutoOffsetReset offsetReset,
final TimestampExtractor timestampExtractor,
final String topic,
final String storeName); KTable<K, V> table(final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic,
final String queryableStoreName); KTable<K, V> table(final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic,
final StateStoreSupplier<KeyValueStore> storeSupplier); KTable<K, V> table(final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic); KTable<K, V> table(final AutoOffsetReset offsetReset,
final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic,
final String queryableStoreName); KTable<K, V> table(final TimestampExtractor timestampExtractor,
final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic,
final String storeName); KTable<K, V> table(final AutoOffsetReset offsetReset,
final TimestampExtractor timestampExtractor,
final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic,
final String queryableStoreName); KTable<K, V> table(final AutoOffsetReset offsetReset,
final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic); KTable<K, V> table(final AutoOffsetReset offsetReset,
final TimestampExtractor timestampExtractor,
final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic,
final StateStoreSupplier<KeyValueStore> storeSupplier); GlobalKTable<K, V> globalTable(final String topic,
final String queryableStoreName); GlobalKTable<K, V> globalTable(final String topic); @SuppressWarnings("unchecked") GlobalKTable<K, V> globalTable(final Serde<K> keySerde,
final Serde<V> valSerde,
final TimestampExtractor timestampExtractor,
final String topic,
final String queryableStoreName); @SuppressWarnings("unchecked") GlobalKTable<K, V> globalTable(final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic,
final StateStoreSupplier<KeyValueStore> storeSupplier); @SuppressWarnings("unchecked") GlobalKTable<K, V> globalTable(final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic,
final String queryableStoreName); @SuppressWarnings("unchecked") GlobalKTable<K, V> globalTable(final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic); KStream<K, V> merge(final KStream<K, V>... streams); String newName(final String prefix); String newStoreName(final String prefix); }
|
@Test public void shouldBuildSimpleGlobalTableTopology() throws Exception { builder.globalTable("table", "globalTable"); final ProcessorTopology topology = builder.buildGlobalStateTopology(); final List<StateStore> stateStores = topology.globalStateStores(); assertEquals(1, stateStores.size()); assertEquals("globalTable", stateStores.get(0).name()); }
@Test public void shouldBuildGlobalTopologyWithAllGlobalTables() throws Exception { builder.globalTable("table", "globalTable"); builder.globalTable("table2", "globalTable2"); doBuildGlobalTopologyWithAllGlobalTables(); }
@Test public void shouldBuildGlobalTopologyWithAllGlobalTablesWithInternalStoreName() throws Exception { builder.globalTable("table"); builder.globalTable("table2"); doBuildGlobalTopologyWithAllGlobalTables(); }
|
MaskField implements Transformation<R> { @Override public R apply(R record) { if (operatingSchema(record) == null) { return applySchemaless(record); } else { return applyWithSchema(record); } } @Override void configure(Map<String, ?> props); @Override R apply(R record); @Override ConfigDef config(); @Override void close(); static final String OVERVIEW_DOC; static final ConfigDef CONFIG_DEF; }
|
@Test public void schemaless() { final Map<String, Object> value = new HashMap<>(); value.put("magic", 42); value.put("bool", true); value.put("byte", (byte) 42); value.put("short", (short) 42); value.put("int", 42); value.put("long", 42L); value.put("float", 42f); value.put("double", 42d); value.put("string", "blabla"); value.put("date", new Date()); value.put("bigint", new BigInteger("42")); value.put("bigdec", new BigDecimal("42.0")); value.put("list", Collections.singletonList(42)); value.put("map", Collections.singletonMap("key", "value")); final List<String> maskFields = new ArrayList<>(value.keySet()); maskFields.remove("magic"); final Map<String, Object> updatedValue = (Map) transform(maskFields).apply(record(null, value)).value(); assertEquals(42, updatedValue.get("magic")); assertEquals(false, updatedValue.get("bool")); assertEquals((byte) 0, updatedValue.get("byte")); assertEquals((short) 0, updatedValue.get("short")); assertEquals(0, updatedValue.get("int")); assertEquals(0L, updatedValue.get("long")); assertEquals(0f, updatedValue.get("float")); assertEquals(0d, updatedValue.get("double")); assertEquals("", updatedValue.get("string")); assertEquals(new Date(0), updatedValue.get("date")); assertEquals(BigInteger.ZERO, updatedValue.get("bigint")); assertEquals(BigDecimal.ZERO, updatedValue.get("bigdec")); assertEquals(Collections.emptyList(), updatedValue.get("list")); assertEquals(Collections.emptyMap(), updatedValue.get("map")); }
@Test public void withSchema() { Schema schema = SchemaBuilder.struct() .field("magic", Schema.INT32_SCHEMA) .field("bool", Schema.BOOLEAN_SCHEMA) .field("byte", Schema.INT8_SCHEMA) .field("short", Schema.INT16_SCHEMA) .field("int", Schema.INT32_SCHEMA) .field("long", Schema.INT64_SCHEMA) .field("float", Schema.FLOAT32_SCHEMA) .field("double", Schema.FLOAT64_SCHEMA) .field("string", Schema.STRING_SCHEMA) .field("date", org.apache.kafka.connect.data.Date.SCHEMA) .field("time", Time.SCHEMA) .field("timestamp", Timestamp.SCHEMA) .field("decimal", Decimal.schema(0)) .field("array", SchemaBuilder.array(Schema.INT32_SCHEMA)) .field("map", SchemaBuilder.map(Schema.STRING_SCHEMA, Schema.STRING_SCHEMA)) .build(); final Struct value = new Struct(schema); value.put("magic", 42); value.put("bool", true); value.put("byte", (byte) 42); value.put("short", (short) 42); value.put("int", 42); value.put("long", 42L); value.put("float", 42f); value.put("double", 42d); value.put("string", "hmm"); value.put("date", new Date()); value.put("time", new Date()); value.put("timestamp", new Date()); value.put("decimal", new BigDecimal(42)); value.put("array", Arrays.asList(1, 2, 3)); value.put("map", Collections.singletonMap("what", "what")); final List<String> maskFields = new ArrayList<>(schema.fields().size()); for (Field field: schema.fields()) { if (!field.name().equals("magic")) { maskFields.add(field.name()); } } final Struct updatedValue = (Struct) transform(maskFields).apply(record(schema, value)).value(); assertEquals(42, updatedValue.get("magic")); assertEquals(false, updatedValue.get("bool")); assertEquals((byte) 0, updatedValue.get("byte")); assertEquals((short) 0, updatedValue.get("short")); assertEquals(0, updatedValue.get("int")); assertEquals(0L, updatedValue.get("long")); assertEquals(0f, updatedValue.get("float")); assertEquals(0d, updatedValue.get("double")); assertEquals("", updatedValue.get("string")); assertEquals(new Date(0), updatedValue.get("date")); assertEquals(new Date(0), updatedValue.get("time")); assertEquals(new Date(0), updatedValue.get("timestamp")); assertEquals(BigDecimal.ZERO, updatedValue.get("decimal")); assertEquals(Collections.emptyList(), updatedValue.get("array")); assertEquals(Collections.emptyMap(), updatedValue.get("map")); }
@Test public void testSchemaless() { final List<String> maskFields = new ArrayList<>(VALUES.keySet()); maskFields.remove("magic"); @SuppressWarnings("unchecked") final Map<String, Object> updatedValue = (Map) transform(maskFields, null).apply(record(null, VALUES)).value(); assertEquals(42, updatedValue.get("magic")); assertEquals(false, updatedValue.get("bool")); assertEquals((byte) 0, updatedValue.get("byte")); assertEquals((short) 0, updatedValue.get("short")); assertEquals(0, updatedValue.get("int")); assertEquals(0L, updatedValue.get("long")); assertEquals(0f, updatedValue.get("float")); assertEquals(0d, updatedValue.get("double")); assertEquals("", updatedValue.get("string")); assertEquals(new Date(0), updatedValue.get("date")); assertEquals(BigInteger.ZERO, updatedValue.get("bigint")); assertEquals(BigDecimal.ZERO, updatedValue.get("bigdec")); assertEquals(Collections.emptyList(), updatedValue.get("list")); assertEquals(Collections.emptyMap(), updatedValue.get("map")); }
@Test public void testWithSchema() { final List<String> maskFields = new ArrayList<>(SCHEMA.fields().size()); for (Field field : SCHEMA.fields()) { if (!field.name().equals("magic")) { maskFields.add(field.name()); } } final Struct updatedValue = (Struct) transform(maskFields, null).apply(record(SCHEMA, VALUES_WITH_SCHEMA)).value(); assertEquals(42, updatedValue.get("magic")); assertEquals(false, updatedValue.get("bool")); assertEquals((byte) 0, updatedValue.get("byte")); assertEquals((short) 0, updatedValue.get("short")); assertEquals(0, updatedValue.get("int")); assertEquals(0L, updatedValue.get("long")); assertEquals(0f, updatedValue.get("float")); assertEquals(0d, updatedValue.get("double")); assertEquals("", updatedValue.get("string")); assertEquals(new Date(0), updatedValue.get("date")); assertEquals(new Date(0), updatedValue.get("time")); assertEquals(new Date(0), updatedValue.get("timestamp")); assertEquals(BigDecimal.ZERO, updatedValue.get("decimal")); assertEquals(Collections.emptyList(), updatedValue.get("array")); assertEquals(Collections.emptyMap(), updatedValue.get("map")); }
|
TimeWindows extends Windows<TimeWindow> { public static TimeWindows of(final long sizeMs) throws IllegalArgumentException { if (sizeMs <= 0) { throw new IllegalArgumentException("Window size (sizeMs) must be larger than zero."); } return new TimeWindows(sizeMs, sizeMs); } private TimeWindows(final long sizeMs, final long advanceMs); static TimeWindows of(final long sizeMs); TimeWindows advanceBy(final long advanceMs); @Override Map<Long, TimeWindow> windowsFor(final long timestamp); @Override long size(); @Override TimeWindows until(final long durationMs); @Override long maintainMs(); @Override boolean equals(final Object o); @Override int hashCode(); final long sizeMs; final long advanceMs; }
|
@Test public void shouldSetWindowSize() { assertEquals(ANY_SIZE, TimeWindows.of(ANY_SIZE).sizeMs); }
@Test(expected = IllegalArgumentException.class) public void windowSizeMustNotBeZero() { TimeWindows.of(0); }
@Test(expected = IllegalArgumentException.class) public void windowSizeMustNotBeNegative() { TimeWindows.of(-1); }
|
KTableImpl extends AbstractStream<K> implements KTable<K, V> { @Override public <K1, V1> KGroupedTable<K1, V1> groupBy(KeyValueMapper<? super K, ? super V, KeyValue<K1, V1>> selector, Serde<K1> keySerde, Serde<V1> valueSerde) { Objects.requireNonNull(selector, "selector can't be null"); String selectName = topology.newName(SELECT_NAME); KTableProcessorSupplier<K, V, KeyValue<K1, V1>> selectSupplier = new KTableRepartitionMap<K, V, K1, V1>(this, selector); topology.addProcessor(selectName, selectSupplier, this.name); this.enableSendingOldValues(); return new KGroupedTableImpl<>(topology, selectName, this.name, keySerde, valueSerde); } KTableImpl(KStreamBuilder topology,
String name,
ProcessorSupplier<?, ?> processorSupplier,
Set<String> sourceNodes,
final String queryableStoreName,
boolean isQueryable); KTableImpl(KStreamBuilder topology,
String name,
ProcessorSupplier<?, ?> processorSupplier,
final Serde<K> keySerde,
final Serde<V> valSerde,
Set<String> sourceNodes,
final String queryableStoreName,
boolean isQueryable); @Override String queryableStoreName(); @Override KTable<K, V> filter(final Predicate<? super K, ? super V> predicate); @Override KTable<K, V> filter(final Predicate<? super K, ? super V> predicate, final String queryableStoreName); @Override KTable<K, V> filter(final Predicate<? super K, ? super V> predicate, final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, V> filterNot(final Predicate<? super K, ? super V> predicate); @Override KTable<K, V> filterNot(final Predicate<? super K, ? super V> predicate, final String queryableStoreName); @Override KTable<K, V> filterNot(final Predicate<? super K, ? super V> predicate, final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, V1> mapValues(final ValueMapper<? super V, ? extends V1> mapper); @Override KTable<K, V1> mapValues(final ValueMapper<? super V, ? extends V1> mapper,
final Serde<V1> valueSerde,
final String queryableStoreName); @Override KTable<K, V1> mapValues(final ValueMapper<? super V, ? extends V1> mapper,
final Serde<V1> valueSerde,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override void print(); @Override void print(String streamName); @Override void print(Serde<K> keySerde, Serde<V> valSerde); @Override void print(Serde<K> keySerde, Serde<V> valSerde, String streamName); @Override void writeAsText(String filePath); @Override void writeAsText(String filePath, String streamName); @Override void writeAsText(String filePath, Serde<K> keySerde, Serde<V> valSerde); @Override void writeAsText(String filePath, String streamName, Serde<K> keySerde, Serde<V> valSerde); @Override void foreach(final ForeachAction<? super K, ? super V> action); @Override KTable<K, V> through(final Serde<K> keySerde,
final Serde<V> valSerde,
final StreamPartitioner<? super K, ? super V> partitioner,
final String topic,
final String queryableStoreName); @Override KTable<K, V> through(final Serde<K> keySerde,
final Serde<V> valSerde,
final StreamPartitioner<? super K, ? super V> partitioner,
final String topic,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, V> through(final Serde<K> keySerde,
final Serde<V> valSerde,
final StreamPartitioner<? super K, ? super V> partitioner,
final String topic); @Override KTable<K, V> through(final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic,
final String queryableStoreName); @Override KTable<K, V> through(final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, V> through(final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic); @Override KTable<K, V> through(final StreamPartitioner<? super K, ? super V> partitioner,
final String topic,
final String queryableStoreName); @Override KTable<K, V> through(final StreamPartitioner<? super K, ? super V> partitioner,
final String topic,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, V> through(final StreamPartitioner<? super K, ? super V> partitioner,
final String topic); @Override KTable<K, V> through(final String topic,
final String queryableStoreName); @Override KTable<K, V> through(final String topic,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, V> through(final String topic); @Override void to(String topic); @Override void to(StreamPartitioner<? super K, ? super V> partitioner, String topic); @Override void to(Serde<K> keySerde, Serde<V> valSerde, String topic); @Override void to(Serde<K> keySerde, Serde<V> valSerde, StreamPartitioner<? super K, ? super V> partitioner, String topic); @Override KStream<K, V> toStream(); @Override KStream<K1, V> toStream(KeyValueMapper<? super K, ? super V, ? extends K1> mapper); @Override KTable<K, R> join(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner); @Override KTable<K, R> join(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final Serde<R> joinSerde,
final String queryableStoreName); @Override KTable<K, R> join(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, R> outerJoin(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner); @Override KTable<K, R> outerJoin(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final Serde<R> joinSerde,
final String queryableStoreName); @Override KTable<K, R> outerJoin(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, R> leftJoin(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner); @Override KTable<K, R> leftJoin(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final Serde<R> joinSerde,
final String queryableStoreName); @Override KTable<K, R> leftJoin(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KGroupedTable<K1, V1> groupBy(KeyValueMapper<? super K, ? super V, KeyValue<K1, V1>> selector,
Serde<K1> keySerde,
Serde<V1> valueSerde); @Override KGroupedTable<K1, V1> groupBy(KeyValueMapper<? super K, ? super V, KeyValue<K1, V1>> selector); static final String JOINTHIS_NAME; static final String JOINOTHER_NAME; static final String MERGE_NAME; static final String SOURCE_NAME; static final String STATE_STORE_NAME; }
|
@Test public void testRepartition() throws Exception { String topic1 = "topic1"; String storeName1 = "storeName1"; final KStreamBuilder builder = new KStreamBuilder(); KTableImpl<String, String, String> table1 = (KTableImpl<String, String, String>) builder.table(stringSerde, stringSerde, topic1, storeName1); KTableImpl<String, String, String> table1Aggregated = (KTableImpl<String, String, String>) table1 .groupBy(MockKeyValueMapper.<String, String>NoOpKeyValueMapper()) .aggregate(MockInitializer.STRING_INIT, MockAggregator.TOSTRING_ADDER, MockAggregator.TOSTRING_REMOVER, "mock-result1"); KTableImpl<String, String, String> table1Reduced = (KTableImpl<String, String, String>) table1 .groupBy(MockKeyValueMapper.<String, String>NoOpKeyValueMapper()) .reduce(MockReducer.STRING_ADDER, MockReducer.STRING_REMOVER, "mock-result2"); driver = new KStreamTestDriver(builder, stateDir, stringSerde, stringSerde); driver.setTime(0L); assertEquals(3, driver.allStateStores().size()); assertTrue(driver.allProcessorNames().contains("KSTREAM-SINK-0000000003")); assertTrue(driver.allProcessorNames().contains("KSTREAM-SOURCE-0000000004")); assertTrue(driver.allProcessorNames().contains("KSTREAM-SINK-0000000007")); assertTrue(driver.allProcessorNames().contains("KSTREAM-SOURCE-0000000008")); Field valSerializerField = ((SinkNode) driver.processor("KSTREAM-SINK-0000000003")).getClass().getDeclaredField("valSerializer"); Field valDeserializerField = ((SourceNode) driver.processor("KSTREAM-SOURCE-0000000004")).getClass().getDeclaredField("valDeserializer"); valSerializerField.setAccessible(true); valDeserializerField.setAccessible(true); assertNotNull(((ChangedSerializer) valSerializerField.get(driver.processor("KSTREAM-SINK-0000000003"))).inner()); assertNotNull(((ChangedDeserializer) valDeserializerField.get(driver.processor("KSTREAM-SOURCE-0000000004"))).inner()); assertNotNull(((ChangedSerializer) valSerializerField.get(driver.processor("KSTREAM-SINK-0000000007"))).inner()); assertNotNull(((ChangedDeserializer) valDeserializerField.get(driver.processor("KSTREAM-SOURCE-0000000008"))).inner()); }
@Test(expected = NullPointerException.class) public void shouldNotAllowNullSelectorOnGroupBy() throws Exception { table.groupBy(null); }
|
KTableImpl extends AbstractStream<K> implements KTable<K, V> { @Override public KStream<K, V> toStream() { String name = topology.newName(TOSTREAM_NAME); topology.addProcessor(name, new KStreamMapValues<K, Change<V>, V>(new ValueMapper<Change<V>, V>() { @Override public V apply(Change<V> change) { return change.newValue; } }), this.name); return new KStreamImpl<>(topology, name, sourceNodes, false); } KTableImpl(KStreamBuilder topology,
String name,
ProcessorSupplier<?, ?> processorSupplier,
Set<String> sourceNodes,
final String queryableStoreName,
boolean isQueryable); KTableImpl(KStreamBuilder topology,
String name,
ProcessorSupplier<?, ?> processorSupplier,
final Serde<K> keySerde,
final Serde<V> valSerde,
Set<String> sourceNodes,
final String queryableStoreName,
boolean isQueryable); @Override String queryableStoreName(); @Override KTable<K, V> filter(final Predicate<? super K, ? super V> predicate); @Override KTable<K, V> filter(final Predicate<? super K, ? super V> predicate, final String queryableStoreName); @Override KTable<K, V> filter(final Predicate<? super K, ? super V> predicate, final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, V> filterNot(final Predicate<? super K, ? super V> predicate); @Override KTable<K, V> filterNot(final Predicate<? super K, ? super V> predicate, final String queryableStoreName); @Override KTable<K, V> filterNot(final Predicate<? super K, ? super V> predicate, final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, V1> mapValues(final ValueMapper<? super V, ? extends V1> mapper); @Override KTable<K, V1> mapValues(final ValueMapper<? super V, ? extends V1> mapper,
final Serde<V1> valueSerde,
final String queryableStoreName); @Override KTable<K, V1> mapValues(final ValueMapper<? super V, ? extends V1> mapper,
final Serde<V1> valueSerde,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override void print(); @Override void print(String streamName); @Override void print(Serde<K> keySerde, Serde<V> valSerde); @Override void print(Serde<K> keySerde, Serde<V> valSerde, String streamName); @Override void writeAsText(String filePath); @Override void writeAsText(String filePath, String streamName); @Override void writeAsText(String filePath, Serde<K> keySerde, Serde<V> valSerde); @Override void writeAsText(String filePath, String streamName, Serde<K> keySerde, Serde<V> valSerde); @Override void foreach(final ForeachAction<? super K, ? super V> action); @Override KTable<K, V> through(final Serde<K> keySerde,
final Serde<V> valSerde,
final StreamPartitioner<? super K, ? super V> partitioner,
final String topic,
final String queryableStoreName); @Override KTable<K, V> through(final Serde<K> keySerde,
final Serde<V> valSerde,
final StreamPartitioner<? super K, ? super V> partitioner,
final String topic,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, V> through(final Serde<K> keySerde,
final Serde<V> valSerde,
final StreamPartitioner<? super K, ? super V> partitioner,
final String topic); @Override KTable<K, V> through(final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic,
final String queryableStoreName); @Override KTable<K, V> through(final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, V> through(final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic); @Override KTable<K, V> through(final StreamPartitioner<? super K, ? super V> partitioner,
final String topic,
final String queryableStoreName); @Override KTable<K, V> through(final StreamPartitioner<? super K, ? super V> partitioner,
final String topic,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, V> through(final StreamPartitioner<? super K, ? super V> partitioner,
final String topic); @Override KTable<K, V> through(final String topic,
final String queryableStoreName); @Override KTable<K, V> through(final String topic,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, V> through(final String topic); @Override void to(String topic); @Override void to(StreamPartitioner<? super K, ? super V> partitioner, String topic); @Override void to(Serde<K> keySerde, Serde<V> valSerde, String topic); @Override void to(Serde<K> keySerde, Serde<V> valSerde, StreamPartitioner<? super K, ? super V> partitioner, String topic); @Override KStream<K, V> toStream(); @Override KStream<K1, V> toStream(KeyValueMapper<? super K, ? super V, ? extends K1> mapper); @Override KTable<K, R> join(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner); @Override KTable<K, R> join(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final Serde<R> joinSerde,
final String queryableStoreName); @Override KTable<K, R> join(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, R> outerJoin(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner); @Override KTable<K, R> outerJoin(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final Serde<R> joinSerde,
final String queryableStoreName); @Override KTable<K, R> outerJoin(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, R> leftJoin(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner); @Override KTable<K, R> leftJoin(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final Serde<R> joinSerde,
final String queryableStoreName); @Override KTable<K, R> leftJoin(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KGroupedTable<K1, V1> groupBy(KeyValueMapper<? super K, ? super V, KeyValue<K1, V1>> selector,
Serde<K1> keySerde,
Serde<V1> valueSerde); @Override KGroupedTable<K1, V1> groupBy(KeyValueMapper<? super K, ? super V, KeyValue<K1, V1>> selector); static final String JOINTHIS_NAME; static final String JOINOTHER_NAME; static final String MERGE_NAME; static final String SOURCE_NAME; static final String STATE_STORE_NAME; }
|
@Test(expected = NullPointerException.class) public void shouldNotAllowNullSelectorOnToStream() throws Exception { table.toStream(null); }
|
KTableImpl extends AbstractStream<K> implements KTable<K, V> { @Override public void to(String topic) { to(null, null, null, topic); } KTableImpl(KStreamBuilder topology,
String name,
ProcessorSupplier<?, ?> processorSupplier,
Set<String> sourceNodes,
final String queryableStoreName,
boolean isQueryable); KTableImpl(KStreamBuilder topology,
String name,
ProcessorSupplier<?, ?> processorSupplier,
final Serde<K> keySerde,
final Serde<V> valSerde,
Set<String> sourceNodes,
final String queryableStoreName,
boolean isQueryable); @Override String queryableStoreName(); @Override KTable<K, V> filter(final Predicate<? super K, ? super V> predicate); @Override KTable<K, V> filter(final Predicate<? super K, ? super V> predicate, final String queryableStoreName); @Override KTable<K, V> filter(final Predicate<? super K, ? super V> predicate, final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, V> filterNot(final Predicate<? super K, ? super V> predicate); @Override KTable<K, V> filterNot(final Predicate<? super K, ? super V> predicate, final String queryableStoreName); @Override KTable<K, V> filterNot(final Predicate<? super K, ? super V> predicate, final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, V1> mapValues(final ValueMapper<? super V, ? extends V1> mapper); @Override KTable<K, V1> mapValues(final ValueMapper<? super V, ? extends V1> mapper,
final Serde<V1> valueSerde,
final String queryableStoreName); @Override KTable<K, V1> mapValues(final ValueMapper<? super V, ? extends V1> mapper,
final Serde<V1> valueSerde,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override void print(); @Override void print(String streamName); @Override void print(Serde<K> keySerde, Serde<V> valSerde); @Override void print(Serde<K> keySerde, Serde<V> valSerde, String streamName); @Override void writeAsText(String filePath); @Override void writeAsText(String filePath, String streamName); @Override void writeAsText(String filePath, Serde<K> keySerde, Serde<V> valSerde); @Override void writeAsText(String filePath, String streamName, Serde<K> keySerde, Serde<V> valSerde); @Override void foreach(final ForeachAction<? super K, ? super V> action); @Override KTable<K, V> through(final Serde<K> keySerde,
final Serde<V> valSerde,
final StreamPartitioner<? super K, ? super V> partitioner,
final String topic,
final String queryableStoreName); @Override KTable<K, V> through(final Serde<K> keySerde,
final Serde<V> valSerde,
final StreamPartitioner<? super K, ? super V> partitioner,
final String topic,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, V> through(final Serde<K> keySerde,
final Serde<V> valSerde,
final StreamPartitioner<? super K, ? super V> partitioner,
final String topic); @Override KTable<K, V> through(final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic,
final String queryableStoreName); @Override KTable<K, V> through(final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, V> through(final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic); @Override KTable<K, V> through(final StreamPartitioner<? super K, ? super V> partitioner,
final String topic,
final String queryableStoreName); @Override KTable<K, V> through(final StreamPartitioner<? super K, ? super V> partitioner,
final String topic,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, V> through(final StreamPartitioner<? super K, ? super V> partitioner,
final String topic); @Override KTable<K, V> through(final String topic,
final String queryableStoreName); @Override KTable<K, V> through(final String topic,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, V> through(final String topic); @Override void to(String topic); @Override void to(StreamPartitioner<? super K, ? super V> partitioner, String topic); @Override void to(Serde<K> keySerde, Serde<V> valSerde, String topic); @Override void to(Serde<K> keySerde, Serde<V> valSerde, StreamPartitioner<? super K, ? super V> partitioner, String topic); @Override KStream<K, V> toStream(); @Override KStream<K1, V> toStream(KeyValueMapper<? super K, ? super V, ? extends K1> mapper); @Override KTable<K, R> join(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner); @Override KTable<K, R> join(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final Serde<R> joinSerde,
final String queryableStoreName); @Override KTable<K, R> join(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, R> outerJoin(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner); @Override KTable<K, R> outerJoin(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final Serde<R> joinSerde,
final String queryableStoreName); @Override KTable<K, R> outerJoin(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, R> leftJoin(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner); @Override KTable<K, R> leftJoin(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final Serde<R> joinSerde,
final String queryableStoreName); @Override KTable<K, R> leftJoin(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KGroupedTable<K1, V1> groupBy(KeyValueMapper<? super K, ? super V, KeyValue<K1, V1>> selector,
Serde<K1> keySerde,
Serde<V1> valueSerde); @Override KGroupedTable<K1, V1> groupBy(KeyValueMapper<? super K, ? super V, KeyValue<K1, V1>> selector); static final String JOINTHIS_NAME; static final String JOINOTHER_NAME; static final String MERGE_NAME; static final String SOURCE_NAME; static final String STATE_STORE_NAME; }
|
@Test(expected = NullPointerException.class) public void shouldNotAllowNullTopicOnTo() throws Exception { table.to(null); }
|
KTableImpl extends AbstractStream<K> implements KTable<K, V> { @Override public KTable<K, V> filter(final Predicate<? super K, ? super V> predicate) { return filter(predicate, (String) null); } KTableImpl(KStreamBuilder topology,
String name,
ProcessorSupplier<?, ?> processorSupplier,
Set<String> sourceNodes,
final String queryableStoreName,
boolean isQueryable); KTableImpl(KStreamBuilder topology,
String name,
ProcessorSupplier<?, ?> processorSupplier,
final Serde<K> keySerde,
final Serde<V> valSerde,
Set<String> sourceNodes,
final String queryableStoreName,
boolean isQueryable); @Override String queryableStoreName(); @Override KTable<K, V> filter(final Predicate<? super K, ? super V> predicate); @Override KTable<K, V> filter(final Predicate<? super K, ? super V> predicate, final String queryableStoreName); @Override KTable<K, V> filter(final Predicate<? super K, ? super V> predicate, final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, V> filterNot(final Predicate<? super K, ? super V> predicate); @Override KTable<K, V> filterNot(final Predicate<? super K, ? super V> predicate, final String queryableStoreName); @Override KTable<K, V> filterNot(final Predicate<? super K, ? super V> predicate, final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, V1> mapValues(final ValueMapper<? super V, ? extends V1> mapper); @Override KTable<K, V1> mapValues(final ValueMapper<? super V, ? extends V1> mapper,
final Serde<V1> valueSerde,
final String queryableStoreName); @Override KTable<K, V1> mapValues(final ValueMapper<? super V, ? extends V1> mapper,
final Serde<V1> valueSerde,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override void print(); @Override void print(String streamName); @Override void print(Serde<K> keySerde, Serde<V> valSerde); @Override void print(Serde<K> keySerde, Serde<V> valSerde, String streamName); @Override void writeAsText(String filePath); @Override void writeAsText(String filePath, String streamName); @Override void writeAsText(String filePath, Serde<K> keySerde, Serde<V> valSerde); @Override void writeAsText(String filePath, String streamName, Serde<K> keySerde, Serde<V> valSerde); @Override void foreach(final ForeachAction<? super K, ? super V> action); @Override KTable<K, V> through(final Serde<K> keySerde,
final Serde<V> valSerde,
final StreamPartitioner<? super K, ? super V> partitioner,
final String topic,
final String queryableStoreName); @Override KTable<K, V> through(final Serde<K> keySerde,
final Serde<V> valSerde,
final StreamPartitioner<? super K, ? super V> partitioner,
final String topic,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, V> through(final Serde<K> keySerde,
final Serde<V> valSerde,
final StreamPartitioner<? super K, ? super V> partitioner,
final String topic); @Override KTable<K, V> through(final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic,
final String queryableStoreName); @Override KTable<K, V> through(final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, V> through(final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic); @Override KTable<K, V> through(final StreamPartitioner<? super K, ? super V> partitioner,
final String topic,
final String queryableStoreName); @Override KTable<K, V> through(final StreamPartitioner<? super K, ? super V> partitioner,
final String topic,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, V> through(final StreamPartitioner<? super K, ? super V> partitioner,
final String topic); @Override KTable<K, V> through(final String topic,
final String queryableStoreName); @Override KTable<K, V> through(final String topic,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, V> through(final String topic); @Override void to(String topic); @Override void to(StreamPartitioner<? super K, ? super V> partitioner, String topic); @Override void to(Serde<K> keySerde, Serde<V> valSerde, String topic); @Override void to(Serde<K> keySerde, Serde<V> valSerde, StreamPartitioner<? super K, ? super V> partitioner, String topic); @Override KStream<K, V> toStream(); @Override KStream<K1, V> toStream(KeyValueMapper<? super K, ? super V, ? extends K1> mapper); @Override KTable<K, R> join(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner); @Override KTable<K, R> join(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final Serde<R> joinSerde,
final String queryableStoreName); @Override KTable<K, R> join(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, R> outerJoin(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner); @Override KTable<K, R> outerJoin(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final Serde<R> joinSerde,
final String queryableStoreName); @Override KTable<K, R> outerJoin(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, R> leftJoin(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner); @Override KTable<K, R> leftJoin(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final Serde<R> joinSerde,
final String queryableStoreName); @Override KTable<K, R> leftJoin(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KGroupedTable<K1, V1> groupBy(KeyValueMapper<? super K, ? super V, KeyValue<K1, V1>> selector,
Serde<K1> keySerde,
Serde<V1> valueSerde); @Override KGroupedTable<K1, V1> groupBy(KeyValueMapper<? super K, ? super V, KeyValue<K1, V1>> selector); static final String JOINTHIS_NAME; static final String JOINOTHER_NAME; static final String MERGE_NAME; static final String SOURCE_NAME; static final String STATE_STORE_NAME; }
|
@Test(expected = NullPointerException.class) public void shouldNotAllowNullPredicateOnFilter() throws Exception { table.filter(null); }
|
KTableImpl extends AbstractStream<K> implements KTable<K, V> { @Override public KTable<K, V> filterNot(final Predicate<? super K, ? super V> predicate) { return filterNot(predicate, (String) null); } KTableImpl(KStreamBuilder topology,
String name,
ProcessorSupplier<?, ?> processorSupplier,
Set<String> sourceNodes,
final String queryableStoreName,
boolean isQueryable); KTableImpl(KStreamBuilder topology,
String name,
ProcessorSupplier<?, ?> processorSupplier,
final Serde<K> keySerde,
final Serde<V> valSerde,
Set<String> sourceNodes,
final String queryableStoreName,
boolean isQueryable); @Override String queryableStoreName(); @Override KTable<K, V> filter(final Predicate<? super K, ? super V> predicate); @Override KTable<K, V> filter(final Predicate<? super K, ? super V> predicate, final String queryableStoreName); @Override KTable<K, V> filter(final Predicate<? super K, ? super V> predicate, final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, V> filterNot(final Predicate<? super K, ? super V> predicate); @Override KTable<K, V> filterNot(final Predicate<? super K, ? super V> predicate, final String queryableStoreName); @Override KTable<K, V> filterNot(final Predicate<? super K, ? super V> predicate, final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, V1> mapValues(final ValueMapper<? super V, ? extends V1> mapper); @Override KTable<K, V1> mapValues(final ValueMapper<? super V, ? extends V1> mapper,
final Serde<V1> valueSerde,
final String queryableStoreName); @Override KTable<K, V1> mapValues(final ValueMapper<? super V, ? extends V1> mapper,
final Serde<V1> valueSerde,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override void print(); @Override void print(String streamName); @Override void print(Serde<K> keySerde, Serde<V> valSerde); @Override void print(Serde<K> keySerde, Serde<V> valSerde, String streamName); @Override void writeAsText(String filePath); @Override void writeAsText(String filePath, String streamName); @Override void writeAsText(String filePath, Serde<K> keySerde, Serde<V> valSerde); @Override void writeAsText(String filePath, String streamName, Serde<K> keySerde, Serde<V> valSerde); @Override void foreach(final ForeachAction<? super K, ? super V> action); @Override KTable<K, V> through(final Serde<K> keySerde,
final Serde<V> valSerde,
final StreamPartitioner<? super K, ? super V> partitioner,
final String topic,
final String queryableStoreName); @Override KTable<K, V> through(final Serde<K> keySerde,
final Serde<V> valSerde,
final StreamPartitioner<? super K, ? super V> partitioner,
final String topic,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, V> through(final Serde<K> keySerde,
final Serde<V> valSerde,
final StreamPartitioner<? super K, ? super V> partitioner,
final String topic); @Override KTable<K, V> through(final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic,
final String queryableStoreName); @Override KTable<K, V> through(final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, V> through(final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic); @Override KTable<K, V> through(final StreamPartitioner<? super K, ? super V> partitioner,
final String topic,
final String queryableStoreName); @Override KTable<K, V> through(final StreamPartitioner<? super K, ? super V> partitioner,
final String topic,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, V> through(final StreamPartitioner<? super K, ? super V> partitioner,
final String topic); @Override KTable<K, V> through(final String topic,
final String queryableStoreName); @Override KTable<K, V> through(final String topic,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, V> through(final String topic); @Override void to(String topic); @Override void to(StreamPartitioner<? super K, ? super V> partitioner, String topic); @Override void to(Serde<K> keySerde, Serde<V> valSerde, String topic); @Override void to(Serde<K> keySerde, Serde<V> valSerde, StreamPartitioner<? super K, ? super V> partitioner, String topic); @Override KStream<K, V> toStream(); @Override KStream<K1, V> toStream(KeyValueMapper<? super K, ? super V, ? extends K1> mapper); @Override KTable<K, R> join(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner); @Override KTable<K, R> join(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final Serde<R> joinSerde,
final String queryableStoreName); @Override KTable<K, R> join(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, R> outerJoin(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner); @Override KTable<K, R> outerJoin(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final Serde<R> joinSerde,
final String queryableStoreName); @Override KTable<K, R> outerJoin(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, R> leftJoin(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner); @Override KTable<K, R> leftJoin(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final Serde<R> joinSerde,
final String queryableStoreName); @Override KTable<K, R> leftJoin(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KGroupedTable<K1, V1> groupBy(KeyValueMapper<? super K, ? super V, KeyValue<K1, V1>> selector,
Serde<K1> keySerde,
Serde<V1> valueSerde); @Override KGroupedTable<K1, V1> groupBy(KeyValueMapper<? super K, ? super V, KeyValue<K1, V1>> selector); static final String JOINTHIS_NAME; static final String JOINOTHER_NAME; static final String MERGE_NAME; static final String SOURCE_NAME; static final String STATE_STORE_NAME; }
|
@Test(expected = NullPointerException.class) public void shouldNotAllowNullPredicateOnFilterNot() throws Exception { table.filterNot(null); }
|
KTableImpl extends AbstractStream<K> implements KTable<K, V> { @Override public <V1> KTable<K, V1> mapValues(final ValueMapper<? super V, ? extends V1> mapper) { return mapValues(mapper, null, (String) null); } KTableImpl(KStreamBuilder topology,
String name,
ProcessorSupplier<?, ?> processorSupplier,
Set<String> sourceNodes,
final String queryableStoreName,
boolean isQueryable); KTableImpl(KStreamBuilder topology,
String name,
ProcessorSupplier<?, ?> processorSupplier,
final Serde<K> keySerde,
final Serde<V> valSerde,
Set<String> sourceNodes,
final String queryableStoreName,
boolean isQueryable); @Override String queryableStoreName(); @Override KTable<K, V> filter(final Predicate<? super K, ? super V> predicate); @Override KTable<K, V> filter(final Predicate<? super K, ? super V> predicate, final String queryableStoreName); @Override KTable<K, V> filter(final Predicate<? super K, ? super V> predicate, final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, V> filterNot(final Predicate<? super K, ? super V> predicate); @Override KTable<K, V> filterNot(final Predicate<? super K, ? super V> predicate, final String queryableStoreName); @Override KTable<K, V> filterNot(final Predicate<? super K, ? super V> predicate, final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, V1> mapValues(final ValueMapper<? super V, ? extends V1> mapper); @Override KTable<K, V1> mapValues(final ValueMapper<? super V, ? extends V1> mapper,
final Serde<V1> valueSerde,
final String queryableStoreName); @Override KTable<K, V1> mapValues(final ValueMapper<? super V, ? extends V1> mapper,
final Serde<V1> valueSerde,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override void print(); @Override void print(String streamName); @Override void print(Serde<K> keySerde, Serde<V> valSerde); @Override void print(Serde<K> keySerde, Serde<V> valSerde, String streamName); @Override void writeAsText(String filePath); @Override void writeAsText(String filePath, String streamName); @Override void writeAsText(String filePath, Serde<K> keySerde, Serde<V> valSerde); @Override void writeAsText(String filePath, String streamName, Serde<K> keySerde, Serde<V> valSerde); @Override void foreach(final ForeachAction<? super K, ? super V> action); @Override KTable<K, V> through(final Serde<K> keySerde,
final Serde<V> valSerde,
final StreamPartitioner<? super K, ? super V> partitioner,
final String topic,
final String queryableStoreName); @Override KTable<K, V> through(final Serde<K> keySerde,
final Serde<V> valSerde,
final StreamPartitioner<? super K, ? super V> partitioner,
final String topic,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, V> through(final Serde<K> keySerde,
final Serde<V> valSerde,
final StreamPartitioner<? super K, ? super V> partitioner,
final String topic); @Override KTable<K, V> through(final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic,
final String queryableStoreName); @Override KTable<K, V> through(final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, V> through(final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic); @Override KTable<K, V> through(final StreamPartitioner<? super K, ? super V> partitioner,
final String topic,
final String queryableStoreName); @Override KTable<K, V> through(final StreamPartitioner<? super K, ? super V> partitioner,
final String topic,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, V> through(final StreamPartitioner<? super K, ? super V> partitioner,
final String topic); @Override KTable<K, V> through(final String topic,
final String queryableStoreName); @Override KTable<K, V> through(final String topic,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, V> through(final String topic); @Override void to(String topic); @Override void to(StreamPartitioner<? super K, ? super V> partitioner, String topic); @Override void to(Serde<K> keySerde, Serde<V> valSerde, String topic); @Override void to(Serde<K> keySerde, Serde<V> valSerde, StreamPartitioner<? super K, ? super V> partitioner, String topic); @Override KStream<K, V> toStream(); @Override KStream<K1, V> toStream(KeyValueMapper<? super K, ? super V, ? extends K1> mapper); @Override KTable<K, R> join(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner); @Override KTable<K, R> join(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final Serde<R> joinSerde,
final String queryableStoreName); @Override KTable<K, R> join(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, R> outerJoin(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner); @Override KTable<K, R> outerJoin(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final Serde<R> joinSerde,
final String queryableStoreName); @Override KTable<K, R> outerJoin(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, R> leftJoin(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner); @Override KTable<K, R> leftJoin(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final Serde<R> joinSerde,
final String queryableStoreName); @Override KTable<K, R> leftJoin(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KGroupedTable<K1, V1> groupBy(KeyValueMapper<? super K, ? super V, KeyValue<K1, V1>> selector,
Serde<K1> keySerde,
Serde<V1> valueSerde); @Override KGroupedTable<K1, V1> groupBy(KeyValueMapper<? super K, ? super V, KeyValue<K1, V1>> selector); static final String JOINTHIS_NAME; static final String JOINOTHER_NAME; static final String MERGE_NAME; static final String SOURCE_NAME; static final String STATE_STORE_NAME; }
|
@Test(expected = NullPointerException.class) public void shouldNotAllowNullMapperOnMapValues() throws Exception { table.mapValues(null); }
|
KTableImpl extends AbstractStream<K> implements KTable<K, V> { @Override public void writeAsText(String filePath) { writeAsText(filePath, null, null, null); } KTableImpl(KStreamBuilder topology,
String name,
ProcessorSupplier<?, ?> processorSupplier,
Set<String> sourceNodes,
final String queryableStoreName,
boolean isQueryable); KTableImpl(KStreamBuilder topology,
String name,
ProcessorSupplier<?, ?> processorSupplier,
final Serde<K> keySerde,
final Serde<V> valSerde,
Set<String> sourceNodes,
final String queryableStoreName,
boolean isQueryable); @Override String queryableStoreName(); @Override KTable<K, V> filter(final Predicate<? super K, ? super V> predicate); @Override KTable<K, V> filter(final Predicate<? super K, ? super V> predicate, final String queryableStoreName); @Override KTable<K, V> filter(final Predicate<? super K, ? super V> predicate, final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, V> filterNot(final Predicate<? super K, ? super V> predicate); @Override KTable<K, V> filterNot(final Predicate<? super K, ? super V> predicate, final String queryableStoreName); @Override KTable<K, V> filterNot(final Predicate<? super K, ? super V> predicate, final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, V1> mapValues(final ValueMapper<? super V, ? extends V1> mapper); @Override KTable<K, V1> mapValues(final ValueMapper<? super V, ? extends V1> mapper,
final Serde<V1> valueSerde,
final String queryableStoreName); @Override KTable<K, V1> mapValues(final ValueMapper<? super V, ? extends V1> mapper,
final Serde<V1> valueSerde,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override void print(); @Override void print(String streamName); @Override void print(Serde<K> keySerde, Serde<V> valSerde); @Override void print(Serde<K> keySerde, Serde<V> valSerde, String streamName); @Override void writeAsText(String filePath); @Override void writeAsText(String filePath, String streamName); @Override void writeAsText(String filePath, Serde<K> keySerde, Serde<V> valSerde); @Override void writeAsText(String filePath, String streamName, Serde<K> keySerde, Serde<V> valSerde); @Override void foreach(final ForeachAction<? super K, ? super V> action); @Override KTable<K, V> through(final Serde<K> keySerde,
final Serde<V> valSerde,
final StreamPartitioner<? super K, ? super V> partitioner,
final String topic,
final String queryableStoreName); @Override KTable<K, V> through(final Serde<K> keySerde,
final Serde<V> valSerde,
final StreamPartitioner<? super K, ? super V> partitioner,
final String topic,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, V> through(final Serde<K> keySerde,
final Serde<V> valSerde,
final StreamPartitioner<? super K, ? super V> partitioner,
final String topic); @Override KTable<K, V> through(final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic,
final String queryableStoreName); @Override KTable<K, V> through(final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, V> through(final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic); @Override KTable<K, V> through(final StreamPartitioner<? super K, ? super V> partitioner,
final String topic,
final String queryableStoreName); @Override KTable<K, V> through(final StreamPartitioner<? super K, ? super V> partitioner,
final String topic,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, V> through(final StreamPartitioner<? super K, ? super V> partitioner,
final String topic); @Override KTable<K, V> through(final String topic,
final String queryableStoreName); @Override KTable<K, V> through(final String topic,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, V> through(final String topic); @Override void to(String topic); @Override void to(StreamPartitioner<? super K, ? super V> partitioner, String topic); @Override void to(Serde<K> keySerde, Serde<V> valSerde, String topic); @Override void to(Serde<K> keySerde, Serde<V> valSerde, StreamPartitioner<? super K, ? super V> partitioner, String topic); @Override KStream<K, V> toStream(); @Override KStream<K1, V> toStream(KeyValueMapper<? super K, ? super V, ? extends K1> mapper); @Override KTable<K, R> join(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner); @Override KTable<K, R> join(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final Serde<R> joinSerde,
final String queryableStoreName); @Override KTable<K, R> join(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, R> outerJoin(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner); @Override KTable<K, R> outerJoin(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final Serde<R> joinSerde,
final String queryableStoreName); @Override KTable<K, R> outerJoin(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, R> leftJoin(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner); @Override KTable<K, R> leftJoin(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final Serde<R> joinSerde,
final String queryableStoreName); @Override KTable<K, R> leftJoin(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KGroupedTable<K1, V1> groupBy(KeyValueMapper<? super K, ? super V, KeyValue<K1, V1>> selector,
Serde<K1> keySerde,
Serde<V1> valueSerde); @Override KGroupedTable<K1, V1> groupBy(KeyValueMapper<? super K, ? super V, KeyValue<K1, V1>> selector); static final String JOINTHIS_NAME; static final String JOINOTHER_NAME; static final String MERGE_NAME; static final String SOURCE_NAME; static final String STATE_STORE_NAME; }
|
@Test(expected = NullPointerException.class) public void shouldNotAllowNullFilePathOnWriteAsText() throws Exception { table.writeAsText(null); }
@Test(expected = TopologyBuilderException.class) public void shouldNotAllowEmptyFilePathOnWriteAsText() throws Exception { table.writeAsText("\t \t"); }
|
KTableImpl extends AbstractStream<K> implements KTable<K, V> { @Override public void foreach(final ForeachAction<? super K, ? super V> action) { Objects.requireNonNull(action, "action can't be null"); String name = topology.newName(FOREACH_NAME); KStreamPeek<K, Change<V>> processorSupplier = new KStreamPeek<>(new ForeachAction<K, Change<V>>() { @Override public void apply(K key, Change<V> value) { action.apply(key, value.newValue); } }, false); topology.addProcessor(name, processorSupplier, this.name); } KTableImpl(KStreamBuilder topology,
String name,
ProcessorSupplier<?, ?> processorSupplier,
Set<String> sourceNodes,
final String queryableStoreName,
boolean isQueryable); KTableImpl(KStreamBuilder topology,
String name,
ProcessorSupplier<?, ?> processorSupplier,
final Serde<K> keySerde,
final Serde<V> valSerde,
Set<String> sourceNodes,
final String queryableStoreName,
boolean isQueryable); @Override String queryableStoreName(); @Override KTable<K, V> filter(final Predicate<? super K, ? super V> predicate); @Override KTable<K, V> filter(final Predicate<? super K, ? super V> predicate, final String queryableStoreName); @Override KTable<K, V> filter(final Predicate<? super K, ? super V> predicate, final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, V> filterNot(final Predicate<? super K, ? super V> predicate); @Override KTable<K, V> filterNot(final Predicate<? super K, ? super V> predicate, final String queryableStoreName); @Override KTable<K, V> filterNot(final Predicate<? super K, ? super V> predicate, final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, V1> mapValues(final ValueMapper<? super V, ? extends V1> mapper); @Override KTable<K, V1> mapValues(final ValueMapper<? super V, ? extends V1> mapper,
final Serde<V1> valueSerde,
final String queryableStoreName); @Override KTable<K, V1> mapValues(final ValueMapper<? super V, ? extends V1> mapper,
final Serde<V1> valueSerde,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override void print(); @Override void print(String streamName); @Override void print(Serde<K> keySerde, Serde<V> valSerde); @Override void print(Serde<K> keySerde, Serde<V> valSerde, String streamName); @Override void writeAsText(String filePath); @Override void writeAsText(String filePath, String streamName); @Override void writeAsText(String filePath, Serde<K> keySerde, Serde<V> valSerde); @Override void writeAsText(String filePath, String streamName, Serde<K> keySerde, Serde<V> valSerde); @Override void foreach(final ForeachAction<? super K, ? super V> action); @Override KTable<K, V> through(final Serde<K> keySerde,
final Serde<V> valSerde,
final StreamPartitioner<? super K, ? super V> partitioner,
final String topic,
final String queryableStoreName); @Override KTable<K, V> through(final Serde<K> keySerde,
final Serde<V> valSerde,
final StreamPartitioner<? super K, ? super V> partitioner,
final String topic,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, V> through(final Serde<K> keySerde,
final Serde<V> valSerde,
final StreamPartitioner<? super K, ? super V> partitioner,
final String topic); @Override KTable<K, V> through(final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic,
final String queryableStoreName); @Override KTable<K, V> through(final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, V> through(final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic); @Override KTable<K, V> through(final StreamPartitioner<? super K, ? super V> partitioner,
final String topic,
final String queryableStoreName); @Override KTable<K, V> through(final StreamPartitioner<? super K, ? super V> partitioner,
final String topic,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, V> through(final StreamPartitioner<? super K, ? super V> partitioner,
final String topic); @Override KTable<K, V> through(final String topic,
final String queryableStoreName); @Override KTable<K, V> through(final String topic,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, V> through(final String topic); @Override void to(String topic); @Override void to(StreamPartitioner<? super K, ? super V> partitioner, String topic); @Override void to(Serde<K> keySerde, Serde<V> valSerde, String topic); @Override void to(Serde<K> keySerde, Serde<V> valSerde, StreamPartitioner<? super K, ? super V> partitioner, String topic); @Override KStream<K, V> toStream(); @Override KStream<K1, V> toStream(KeyValueMapper<? super K, ? super V, ? extends K1> mapper); @Override KTable<K, R> join(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner); @Override KTable<K, R> join(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final Serde<R> joinSerde,
final String queryableStoreName); @Override KTable<K, R> join(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, R> outerJoin(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner); @Override KTable<K, R> outerJoin(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final Serde<R> joinSerde,
final String queryableStoreName); @Override KTable<K, R> outerJoin(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, R> leftJoin(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner); @Override KTable<K, R> leftJoin(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final Serde<R> joinSerde,
final String queryableStoreName); @Override KTable<K, R> leftJoin(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KGroupedTable<K1, V1> groupBy(KeyValueMapper<? super K, ? super V, KeyValue<K1, V1>> selector,
Serde<K1> keySerde,
Serde<V1> valueSerde); @Override KGroupedTable<K1, V1> groupBy(KeyValueMapper<? super K, ? super V, KeyValue<K1, V1>> selector); static final String JOINTHIS_NAME; static final String JOINOTHER_NAME; static final String MERGE_NAME; static final String SOURCE_NAME; static final String STATE_STORE_NAME; }
|
@Test(expected = NullPointerException.class) public void shouldNotAllowNullActionOnForEach() throws Exception { table.foreach(null); }
|
KTableImpl extends AbstractStream<K> implements KTable<K, V> { @Override public KTable<K, V> through(final Serde<K> keySerde, final Serde<V> valSerde, final StreamPartitioner<? super K, ? super V> partitioner, final String topic, final String queryableStoreName) { final String internalStoreName = queryableStoreName != null ? queryableStoreName : topology.newStoreName(KTableImpl.TOSTREAM_NAME); to(keySerde, valSerde, partitioner, topic); return topology.table(keySerde, valSerde, topic, internalStoreName); } KTableImpl(KStreamBuilder topology,
String name,
ProcessorSupplier<?, ?> processorSupplier,
Set<String> sourceNodes,
final String queryableStoreName,
boolean isQueryable); KTableImpl(KStreamBuilder topology,
String name,
ProcessorSupplier<?, ?> processorSupplier,
final Serde<K> keySerde,
final Serde<V> valSerde,
Set<String> sourceNodes,
final String queryableStoreName,
boolean isQueryable); @Override String queryableStoreName(); @Override KTable<K, V> filter(final Predicate<? super K, ? super V> predicate); @Override KTable<K, V> filter(final Predicate<? super K, ? super V> predicate, final String queryableStoreName); @Override KTable<K, V> filter(final Predicate<? super K, ? super V> predicate, final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, V> filterNot(final Predicate<? super K, ? super V> predicate); @Override KTable<K, V> filterNot(final Predicate<? super K, ? super V> predicate, final String queryableStoreName); @Override KTable<K, V> filterNot(final Predicate<? super K, ? super V> predicate, final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, V1> mapValues(final ValueMapper<? super V, ? extends V1> mapper); @Override KTable<K, V1> mapValues(final ValueMapper<? super V, ? extends V1> mapper,
final Serde<V1> valueSerde,
final String queryableStoreName); @Override KTable<K, V1> mapValues(final ValueMapper<? super V, ? extends V1> mapper,
final Serde<V1> valueSerde,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override void print(); @Override void print(String streamName); @Override void print(Serde<K> keySerde, Serde<V> valSerde); @Override void print(Serde<K> keySerde, Serde<V> valSerde, String streamName); @Override void writeAsText(String filePath); @Override void writeAsText(String filePath, String streamName); @Override void writeAsText(String filePath, Serde<K> keySerde, Serde<V> valSerde); @Override void writeAsText(String filePath, String streamName, Serde<K> keySerde, Serde<V> valSerde); @Override void foreach(final ForeachAction<? super K, ? super V> action); @Override KTable<K, V> through(final Serde<K> keySerde,
final Serde<V> valSerde,
final StreamPartitioner<? super K, ? super V> partitioner,
final String topic,
final String queryableStoreName); @Override KTable<K, V> through(final Serde<K> keySerde,
final Serde<V> valSerde,
final StreamPartitioner<? super K, ? super V> partitioner,
final String topic,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, V> through(final Serde<K> keySerde,
final Serde<V> valSerde,
final StreamPartitioner<? super K, ? super V> partitioner,
final String topic); @Override KTable<K, V> through(final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic,
final String queryableStoreName); @Override KTable<K, V> through(final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, V> through(final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic); @Override KTable<K, V> through(final StreamPartitioner<? super K, ? super V> partitioner,
final String topic,
final String queryableStoreName); @Override KTable<K, V> through(final StreamPartitioner<? super K, ? super V> partitioner,
final String topic,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, V> through(final StreamPartitioner<? super K, ? super V> partitioner,
final String topic); @Override KTable<K, V> through(final String topic,
final String queryableStoreName); @Override KTable<K, V> through(final String topic,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, V> through(final String topic); @Override void to(String topic); @Override void to(StreamPartitioner<? super K, ? super V> partitioner, String topic); @Override void to(Serde<K> keySerde, Serde<V> valSerde, String topic); @Override void to(Serde<K> keySerde, Serde<V> valSerde, StreamPartitioner<? super K, ? super V> partitioner, String topic); @Override KStream<K, V> toStream(); @Override KStream<K1, V> toStream(KeyValueMapper<? super K, ? super V, ? extends K1> mapper); @Override KTable<K, R> join(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner); @Override KTable<K, R> join(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final Serde<R> joinSerde,
final String queryableStoreName); @Override KTable<K, R> join(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, R> outerJoin(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner); @Override KTable<K, R> outerJoin(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final Serde<R> joinSerde,
final String queryableStoreName); @Override KTable<K, R> outerJoin(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, R> leftJoin(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner); @Override KTable<K, R> leftJoin(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final Serde<R> joinSerde,
final String queryableStoreName); @Override KTable<K, R> leftJoin(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KGroupedTable<K1, V1> groupBy(KeyValueMapper<? super K, ? super V, KeyValue<K1, V1>> selector,
Serde<K1> keySerde,
Serde<V1> valueSerde); @Override KGroupedTable<K1, V1> groupBy(KeyValueMapper<? super K, ? super V, KeyValue<K1, V1>> selector); static final String JOINTHIS_NAME; static final String JOINOTHER_NAME; static final String MERGE_NAME; static final String SOURCE_NAME; static final String STATE_STORE_NAME; }
|
@Test(expected = NullPointerException.class) public void shouldAllowNullTopicInThrough() throws Exception { table.through((String) null, "store"); }
@Test public void shouldAllowNullStoreInThrough() throws Exception { table.through("topic", (String) null); }
|
KTableImpl extends AbstractStream<K> implements KTable<K, V> { @Override public <V1, R> KTable<K, R> join(final KTable<K, V1> other, final ValueJoiner<? super V, ? super V1, ? extends R> joiner) { return doJoin(other, joiner, false, false, null, (String) null); } KTableImpl(KStreamBuilder topology,
String name,
ProcessorSupplier<?, ?> processorSupplier,
Set<String> sourceNodes,
final String queryableStoreName,
boolean isQueryable); KTableImpl(KStreamBuilder topology,
String name,
ProcessorSupplier<?, ?> processorSupplier,
final Serde<K> keySerde,
final Serde<V> valSerde,
Set<String> sourceNodes,
final String queryableStoreName,
boolean isQueryable); @Override String queryableStoreName(); @Override KTable<K, V> filter(final Predicate<? super K, ? super V> predicate); @Override KTable<K, V> filter(final Predicate<? super K, ? super V> predicate, final String queryableStoreName); @Override KTable<K, V> filter(final Predicate<? super K, ? super V> predicate, final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, V> filterNot(final Predicate<? super K, ? super V> predicate); @Override KTable<K, V> filterNot(final Predicate<? super K, ? super V> predicate, final String queryableStoreName); @Override KTable<K, V> filterNot(final Predicate<? super K, ? super V> predicate, final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, V1> mapValues(final ValueMapper<? super V, ? extends V1> mapper); @Override KTable<K, V1> mapValues(final ValueMapper<? super V, ? extends V1> mapper,
final Serde<V1> valueSerde,
final String queryableStoreName); @Override KTable<K, V1> mapValues(final ValueMapper<? super V, ? extends V1> mapper,
final Serde<V1> valueSerde,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override void print(); @Override void print(String streamName); @Override void print(Serde<K> keySerde, Serde<V> valSerde); @Override void print(Serde<K> keySerde, Serde<V> valSerde, String streamName); @Override void writeAsText(String filePath); @Override void writeAsText(String filePath, String streamName); @Override void writeAsText(String filePath, Serde<K> keySerde, Serde<V> valSerde); @Override void writeAsText(String filePath, String streamName, Serde<K> keySerde, Serde<V> valSerde); @Override void foreach(final ForeachAction<? super K, ? super V> action); @Override KTable<K, V> through(final Serde<K> keySerde,
final Serde<V> valSerde,
final StreamPartitioner<? super K, ? super V> partitioner,
final String topic,
final String queryableStoreName); @Override KTable<K, V> through(final Serde<K> keySerde,
final Serde<V> valSerde,
final StreamPartitioner<? super K, ? super V> partitioner,
final String topic,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, V> through(final Serde<K> keySerde,
final Serde<V> valSerde,
final StreamPartitioner<? super K, ? super V> partitioner,
final String topic); @Override KTable<K, V> through(final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic,
final String queryableStoreName); @Override KTable<K, V> through(final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, V> through(final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic); @Override KTable<K, V> through(final StreamPartitioner<? super K, ? super V> partitioner,
final String topic,
final String queryableStoreName); @Override KTable<K, V> through(final StreamPartitioner<? super K, ? super V> partitioner,
final String topic,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, V> through(final StreamPartitioner<? super K, ? super V> partitioner,
final String topic); @Override KTable<K, V> through(final String topic,
final String queryableStoreName); @Override KTable<K, V> through(final String topic,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, V> through(final String topic); @Override void to(String topic); @Override void to(StreamPartitioner<? super K, ? super V> partitioner, String topic); @Override void to(Serde<K> keySerde, Serde<V> valSerde, String topic); @Override void to(Serde<K> keySerde, Serde<V> valSerde, StreamPartitioner<? super K, ? super V> partitioner, String topic); @Override KStream<K, V> toStream(); @Override KStream<K1, V> toStream(KeyValueMapper<? super K, ? super V, ? extends K1> mapper); @Override KTable<K, R> join(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner); @Override KTable<K, R> join(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final Serde<R> joinSerde,
final String queryableStoreName); @Override KTable<K, R> join(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, R> outerJoin(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner); @Override KTable<K, R> outerJoin(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final Serde<R> joinSerde,
final String queryableStoreName); @Override KTable<K, R> outerJoin(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, R> leftJoin(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner); @Override KTable<K, R> leftJoin(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final Serde<R> joinSerde,
final String queryableStoreName); @Override KTable<K, R> leftJoin(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KGroupedTable<K1, V1> groupBy(KeyValueMapper<? super K, ? super V, KeyValue<K1, V1>> selector,
Serde<K1> keySerde,
Serde<V1> valueSerde); @Override KGroupedTable<K1, V1> groupBy(KeyValueMapper<? super K, ? super V, KeyValue<K1, V1>> selector); static final String JOINTHIS_NAME; static final String JOINOTHER_NAME; static final String MERGE_NAME; static final String SOURCE_NAME; static final String STATE_STORE_NAME; }
|
@Test(expected = NullPointerException.class) public void shouldNotAllowNullOtherTableOnJoin() throws Exception { table.join(null, MockValueJoiner.TOSTRING_JOINER); }
@Test public void shouldAllowNullStoreInJoin() throws Exception { table.join(table, MockValueJoiner.TOSTRING_JOINER, null, (String) null); }
@Test(expected = NullPointerException.class) public void shouldNotAllowNullStoreSupplierInJoin() throws Exception { table.join(table, MockValueJoiner.TOSTRING_JOINER, (StateStoreSupplier<KeyValueStore>) null); }
@Test(expected = NullPointerException.class) public void shouldNotAllowNullJoinerJoin() throws Exception { table.join(table, null); }
|
KTableImpl extends AbstractStream<K> implements KTable<K, V> { @Override public <V1, R> KTable<K, R> leftJoin(final KTable<K, V1> other, final ValueJoiner<? super V, ? super V1, ? extends R> joiner) { return doJoin(other, joiner, true, false, null, (String) null); } KTableImpl(KStreamBuilder topology,
String name,
ProcessorSupplier<?, ?> processorSupplier,
Set<String> sourceNodes,
final String queryableStoreName,
boolean isQueryable); KTableImpl(KStreamBuilder topology,
String name,
ProcessorSupplier<?, ?> processorSupplier,
final Serde<K> keySerde,
final Serde<V> valSerde,
Set<String> sourceNodes,
final String queryableStoreName,
boolean isQueryable); @Override String queryableStoreName(); @Override KTable<K, V> filter(final Predicate<? super K, ? super V> predicate); @Override KTable<K, V> filter(final Predicate<? super K, ? super V> predicate, final String queryableStoreName); @Override KTable<K, V> filter(final Predicate<? super K, ? super V> predicate, final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, V> filterNot(final Predicate<? super K, ? super V> predicate); @Override KTable<K, V> filterNot(final Predicate<? super K, ? super V> predicate, final String queryableStoreName); @Override KTable<K, V> filterNot(final Predicate<? super K, ? super V> predicate, final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, V1> mapValues(final ValueMapper<? super V, ? extends V1> mapper); @Override KTable<K, V1> mapValues(final ValueMapper<? super V, ? extends V1> mapper,
final Serde<V1> valueSerde,
final String queryableStoreName); @Override KTable<K, V1> mapValues(final ValueMapper<? super V, ? extends V1> mapper,
final Serde<V1> valueSerde,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override void print(); @Override void print(String streamName); @Override void print(Serde<K> keySerde, Serde<V> valSerde); @Override void print(Serde<K> keySerde, Serde<V> valSerde, String streamName); @Override void writeAsText(String filePath); @Override void writeAsText(String filePath, String streamName); @Override void writeAsText(String filePath, Serde<K> keySerde, Serde<V> valSerde); @Override void writeAsText(String filePath, String streamName, Serde<K> keySerde, Serde<V> valSerde); @Override void foreach(final ForeachAction<? super K, ? super V> action); @Override KTable<K, V> through(final Serde<K> keySerde,
final Serde<V> valSerde,
final StreamPartitioner<? super K, ? super V> partitioner,
final String topic,
final String queryableStoreName); @Override KTable<K, V> through(final Serde<K> keySerde,
final Serde<V> valSerde,
final StreamPartitioner<? super K, ? super V> partitioner,
final String topic,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, V> through(final Serde<K> keySerde,
final Serde<V> valSerde,
final StreamPartitioner<? super K, ? super V> partitioner,
final String topic); @Override KTable<K, V> through(final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic,
final String queryableStoreName); @Override KTable<K, V> through(final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, V> through(final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic); @Override KTable<K, V> through(final StreamPartitioner<? super K, ? super V> partitioner,
final String topic,
final String queryableStoreName); @Override KTable<K, V> through(final StreamPartitioner<? super K, ? super V> partitioner,
final String topic,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, V> through(final StreamPartitioner<? super K, ? super V> partitioner,
final String topic); @Override KTable<K, V> through(final String topic,
final String queryableStoreName); @Override KTable<K, V> through(final String topic,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, V> through(final String topic); @Override void to(String topic); @Override void to(StreamPartitioner<? super K, ? super V> partitioner, String topic); @Override void to(Serde<K> keySerde, Serde<V> valSerde, String topic); @Override void to(Serde<K> keySerde, Serde<V> valSerde, StreamPartitioner<? super K, ? super V> partitioner, String topic); @Override KStream<K, V> toStream(); @Override KStream<K1, V> toStream(KeyValueMapper<? super K, ? super V, ? extends K1> mapper); @Override KTable<K, R> join(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner); @Override KTable<K, R> join(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final Serde<R> joinSerde,
final String queryableStoreName); @Override KTable<K, R> join(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, R> outerJoin(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner); @Override KTable<K, R> outerJoin(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final Serde<R> joinSerde,
final String queryableStoreName); @Override KTable<K, R> outerJoin(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, R> leftJoin(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner); @Override KTable<K, R> leftJoin(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final Serde<R> joinSerde,
final String queryableStoreName); @Override KTable<K, R> leftJoin(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KGroupedTable<K1, V1> groupBy(KeyValueMapper<? super K, ? super V, KeyValue<K1, V1>> selector,
Serde<K1> keySerde,
Serde<V1> valueSerde); @Override KGroupedTable<K1, V1> groupBy(KeyValueMapper<? super K, ? super V, KeyValue<K1, V1>> selector); static final String JOINTHIS_NAME; static final String JOINOTHER_NAME; static final String MERGE_NAME; static final String SOURCE_NAME; static final String STATE_STORE_NAME; }
|
@Test(expected = NullPointerException.class) public void shouldNotAllowNullStoreSupplierInLeftJoin() throws Exception { table.leftJoin(table, MockValueJoiner.TOSTRING_JOINER, (StateStoreSupplier<KeyValueStore>) null); }
@Test(expected = NullPointerException.class) public void shouldNotAllowNullJoinerOnLeftJoin() throws Exception { table.leftJoin(table, null); }
@Test(expected = NullPointerException.class) public void shouldNotAllowNullOtherTableOnLeftJoin() throws Exception { table.leftJoin(null, MockValueJoiner.TOSTRING_JOINER); }
|
KTableImpl extends AbstractStream<K> implements KTable<K, V> { @Override public <V1, R> KTable<K, R> outerJoin(final KTable<K, V1> other, final ValueJoiner<? super V, ? super V1, ? extends R> joiner) { return doJoin(other, joiner, true, true, null, (String) null); } KTableImpl(KStreamBuilder topology,
String name,
ProcessorSupplier<?, ?> processorSupplier,
Set<String> sourceNodes,
final String queryableStoreName,
boolean isQueryable); KTableImpl(KStreamBuilder topology,
String name,
ProcessorSupplier<?, ?> processorSupplier,
final Serde<K> keySerde,
final Serde<V> valSerde,
Set<String> sourceNodes,
final String queryableStoreName,
boolean isQueryable); @Override String queryableStoreName(); @Override KTable<K, V> filter(final Predicate<? super K, ? super V> predicate); @Override KTable<K, V> filter(final Predicate<? super K, ? super V> predicate, final String queryableStoreName); @Override KTable<K, V> filter(final Predicate<? super K, ? super V> predicate, final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, V> filterNot(final Predicate<? super K, ? super V> predicate); @Override KTable<K, V> filterNot(final Predicate<? super K, ? super V> predicate, final String queryableStoreName); @Override KTable<K, V> filterNot(final Predicate<? super K, ? super V> predicate, final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, V1> mapValues(final ValueMapper<? super V, ? extends V1> mapper); @Override KTable<K, V1> mapValues(final ValueMapper<? super V, ? extends V1> mapper,
final Serde<V1> valueSerde,
final String queryableStoreName); @Override KTable<K, V1> mapValues(final ValueMapper<? super V, ? extends V1> mapper,
final Serde<V1> valueSerde,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override void print(); @Override void print(String streamName); @Override void print(Serde<K> keySerde, Serde<V> valSerde); @Override void print(Serde<K> keySerde, Serde<V> valSerde, String streamName); @Override void writeAsText(String filePath); @Override void writeAsText(String filePath, String streamName); @Override void writeAsText(String filePath, Serde<K> keySerde, Serde<V> valSerde); @Override void writeAsText(String filePath, String streamName, Serde<K> keySerde, Serde<V> valSerde); @Override void foreach(final ForeachAction<? super K, ? super V> action); @Override KTable<K, V> through(final Serde<K> keySerde,
final Serde<V> valSerde,
final StreamPartitioner<? super K, ? super V> partitioner,
final String topic,
final String queryableStoreName); @Override KTable<K, V> through(final Serde<K> keySerde,
final Serde<V> valSerde,
final StreamPartitioner<? super K, ? super V> partitioner,
final String topic,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, V> through(final Serde<K> keySerde,
final Serde<V> valSerde,
final StreamPartitioner<? super K, ? super V> partitioner,
final String topic); @Override KTable<K, V> through(final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic,
final String queryableStoreName); @Override KTable<K, V> through(final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, V> through(final Serde<K> keySerde,
final Serde<V> valSerde,
final String topic); @Override KTable<K, V> through(final StreamPartitioner<? super K, ? super V> partitioner,
final String topic,
final String queryableStoreName); @Override KTable<K, V> through(final StreamPartitioner<? super K, ? super V> partitioner,
final String topic,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, V> through(final StreamPartitioner<? super K, ? super V> partitioner,
final String topic); @Override KTable<K, V> through(final String topic,
final String queryableStoreName); @Override KTable<K, V> through(final String topic,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, V> through(final String topic); @Override void to(String topic); @Override void to(StreamPartitioner<? super K, ? super V> partitioner, String topic); @Override void to(Serde<K> keySerde, Serde<V> valSerde, String topic); @Override void to(Serde<K> keySerde, Serde<V> valSerde, StreamPartitioner<? super K, ? super V> partitioner, String topic); @Override KStream<K, V> toStream(); @Override KStream<K1, V> toStream(KeyValueMapper<? super K, ? super V, ? extends K1> mapper); @Override KTable<K, R> join(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner); @Override KTable<K, R> join(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final Serde<R> joinSerde,
final String queryableStoreName); @Override KTable<K, R> join(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, R> outerJoin(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner); @Override KTable<K, R> outerJoin(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final Serde<R> joinSerde,
final String queryableStoreName); @Override KTable<K, R> outerJoin(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, R> leftJoin(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner); @Override KTable<K, R> leftJoin(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final Serde<R> joinSerde,
final String queryableStoreName); @Override KTable<K, R> leftJoin(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KGroupedTable<K1, V1> groupBy(KeyValueMapper<? super K, ? super V, KeyValue<K1, V1>> selector,
Serde<K1> keySerde,
Serde<V1> valueSerde); @Override KGroupedTable<K1, V1> groupBy(KeyValueMapper<? super K, ? super V, KeyValue<K1, V1>> selector); static final String JOINTHIS_NAME; static final String JOINOTHER_NAME; static final String MERGE_NAME; static final String SOURCE_NAME; static final String STATE_STORE_NAME; }
|
@Test(expected = NullPointerException.class) public void shouldNotAllowNullStoreSupplierInOuterJoin() throws Exception { table.outerJoin(table, MockValueJoiner.TOSTRING_JOINER, (StateStoreSupplier<KeyValueStore>) null); }
@Test(expected = NullPointerException.class) public void shouldNotAllowNullOtherTableOnOuterJoin() throws Exception { table.outerJoin(null, MockValueJoiner.TOSTRING_JOINER); }
@Test(expected = NullPointerException.class) public void shouldNotAllowNullJoinerOnOuterJoin() throws Exception { table.outerJoin(table, null); }
|
SetSchemaMetadata implements Transformation<R> { protected static Object updateSchemaIn(Object keyOrValue, Schema updatedSchema) { if (keyOrValue instanceof Struct) { Struct origStruct = (Struct) keyOrValue; Struct newStruct = new Struct(updatedSchema); for (Field field : updatedSchema.fields()) { newStruct.put(field, origStruct.get(field)); } return newStruct; } return keyOrValue; } @Override void configure(Map<String, ?> configs); @Override R apply(R record); @Override ConfigDef config(); @Override void close(); static final String OVERVIEW_DOC; static final ConfigDef CONFIG_DEF; }
|
@Test public void updateSchemaOfNonStruct() { Object value = new Integer(1); Object updatedValue = SetSchemaMetadata.updateSchemaIn(value, Schema.INT32_SCHEMA); assertSame(value, updatedValue); }
@Test public void updateSchemaOfStruct() { final String fieldName1 = "f1"; final String fieldName2 = "f2"; final String fieldValue1 = "value1"; final int fieldValue2 = 1; final Schema schema = SchemaBuilder.struct() .name("my.orig.SchemaDefn") .field(fieldName1, Schema.STRING_SCHEMA) .field(fieldName2, Schema.INT32_SCHEMA) .build(); final Struct value = new Struct(schema).put(fieldName1, fieldValue1).put(fieldName2, fieldValue2); final Schema newSchema = SchemaBuilder.struct() .name("my.updated.SchemaDefn") .field(fieldName1, Schema.STRING_SCHEMA) .field(fieldName2, Schema.INT32_SCHEMA) .build(); Struct newValue = (Struct) SetSchemaMetadata.updateSchemaIn(value, newSchema); assertMatchingSchema(newValue, newSchema); }
@Test public void updateSchemaOfNonStruct() { Object value = Integer.valueOf(1); Object updatedValue = SetSchemaMetadata.updateSchemaIn(value, Schema.INT32_SCHEMA); assertSame(value, updatedValue); }
@Test public void updateSchemaOfNull() { Object updatedValue = SetSchemaMetadata.updateSchemaIn(null, Schema.INT32_SCHEMA); assertEquals(null, updatedValue); }
|
WindowedStreamPartitioner implements StreamPartitioner<Windowed<K>, V> { public Integer partition(final Windowed<K> windowedKey, final V value, final int numPartitions) { final byte[] keyBytes = serializer.serializeBaseKey(topic, windowedKey); return toPositive(Utils.murmur2(keyBytes)) % numPartitions; } WindowedStreamPartitioner(final String topic, final WindowedSerializer<K> serializer); Integer partition(final Windowed<K> windowedKey, final V value, final int numPartitions); }
|
@Test public void testCopartitioning() { Random rand = new Random(); DefaultPartitioner defaultPartitioner = new DefaultPartitioner(); WindowedSerializer<Integer> windowedSerializer = new WindowedSerializer<>(intSerializer); WindowedStreamPartitioner<Integer, String> streamPartitioner = new WindowedStreamPartitioner<>(topicName, windowedSerializer); for (int k = 0; k < 10; k++) { Integer key = rand.nextInt(); byte[] keyBytes = intSerializer.serialize(topicName, key); String value = key.toString(); byte[] valueBytes = stringSerializer.serialize(topicName, value); Integer expected = defaultPartitioner.partition("topic", key, keyBytes, value, valueBytes, cluster); for (int w = 1; w < 10; w++) { TimeWindow window = new TimeWindow(10 * w, 20 * w); Windowed<Integer> windowedKey = new Windowed<>(key, window); Integer actual = streamPartitioner.partition(windowedKey, value, infos.size()); assertEquals(expected, actual); } } }
|
KTableKTableOuterJoin extends KTableKTableAbstractJoin<K, R, V1, V2> { @Override public Processor<K, Change<V1>> get() { return new KTableKTableOuterJoinProcessor(valueGetterSupplier2.get()); } KTableKTableOuterJoin(KTableImpl<K, ?, V1> table1, KTableImpl<K, ?, V2> table2, ValueJoiner<? super V1, ? super V2, ? extends R> joiner); @Override Processor<K, Change<V1>> get(); @Override KTableValueGetterSupplier<K, R> view(); }
|
@Test public void testJoin() throws Exception { KStreamBuilder builder = new KStreamBuilder(); final int[] expectedKeys = new int[]{0, 1, 2, 3}; KTable<Integer, String> table1; KTable<Integer, String> table2; KTable<Integer, String> joined; MockProcessorSupplier<Integer, String> processor; processor = new MockProcessorSupplier<>(); table1 = builder.table(intSerde, stringSerde, topic1, storeName1); table2 = builder.table(intSerde, stringSerde, topic2, storeName2); joined = table1.outerJoin(table2, MockValueJoiner.TOSTRING_JOINER); joined.toStream().process(processor); Collection<Set<String>> copartitionGroups = builder.copartitionGroups(); assertEquals(1, copartitionGroups.size()); assertEquals(new HashSet<>(Arrays.asList(topic1, topic2)), copartitionGroups.iterator().next()); KTableValueGetterSupplier<Integer, String> getterSupplier = ((KTableImpl<Integer, String, String>) joined).valueGetterSupplier(); driver = new KStreamTestDriver(builder, stateDir); KTableValueGetter<Integer, String> getter = getterSupplier.get(); getter.init(driver.context()); for (int i = 0; i < 2; i++) { driver.process(topic1, expectedKeys[i], "X" + expectedKeys[i]); } driver.process(topic1, null, "SomeVal"); driver.flushState(); processor.checkAndClearProcessResult("0:X0+null", "1:X1+null"); checkJoinedValues(getter, kv(0, "X0+null"), kv(1, "X1+null"), kv(2, null), kv(3, null)); for (int i = 0; i < 2; i++) { driver.process(topic2, expectedKeys[i], "Y" + expectedKeys[i]); } driver.process(topic2, null, "AnotherVal"); driver.flushState(); processor.checkAndClearProcessResult("0:X0+Y0", "1:X1+Y1"); checkJoinedValues(getter, kv(0, "X0+Y0"), kv(1, "X1+Y1"), kv(2, null), kv(3, null)); for (int expectedKey : expectedKeys) { driver.process(topic1, expectedKey, "X" + expectedKey); } driver.flushState(); processor.checkAndClearProcessResult("0:X0+Y0", "1:X1+Y1", "2:X2+null", "3:X3+null"); checkJoinedValues(getter, kv(0, "X0+Y0"), kv(1, "X1+Y1"), kv(2, "X2+null"), kv(3, "X3+null")); for (int expectedKey : expectedKeys) { driver.process(topic2, expectedKey, "YY" + expectedKey); } driver.flushState(); processor.checkAndClearProcessResult("0:X0+YY0", "1:X1+YY1", "2:X2+YY2", "3:X3+YY3"); checkJoinedValues(getter, kv(0, "X0+YY0"), kv(1, "X1+YY1"), kv(2, "X2+YY2"), kv(3, "X3+YY3")); for (int expectedKey : expectedKeys) { driver.process(topic1, expectedKey, "X" + expectedKey); } driver.flushState(); processor.checkAndClearProcessResult("0:X0+YY0", "1:X1+YY1", "2:X2+YY2", "3:X3+YY3"); checkJoinedValues(getter, kv(0, "X0+YY0"), kv(1, "X1+YY1"), kv(2, "X2+YY2"), kv(3, "X3+YY3")); for (int i = 0; i < 2; i++) { driver.process(topic2, expectedKeys[i], null); } driver.flushState(); processor.checkAndClearProcessResult("0:X0+null", "1:X1+null"); checkJoinedValues(getter, kv(0, "X0+null"), kv(1, "X1+null"), kv(2, "X2+YY2"), kv(3, "X3+YY3")); for (int expectedKey : expectedKeys) { driver.process(topic1, expectedKey, "XX" + expectedKey); } driver.flushState(); processor.checkAndClearProcessResult("0:XX0+null", "1:XX1+null", "2:XX2+YY2", "3:XX3+YY3"); checkJoinedValues(getter, kv(0, "XX0+null"), kv(1, "XX1+null"), kv(2, "XX2+YY2"), kv(3, "XX3+YY3")); for (int i = 1; i < 3; i++) { driver.process(topic1, expectedKeys[i], null); } driver.flushState(); processor.checkAndClearProcessResult("1:null", "2:null+YY2"); checkJoinedValues(getter, kv(0, "XX0+null"), kv(1, null), kv(2, "null+YY2"), kv(3, "XX3+YY3")); }
|
KTableAggregate implements KTableProcessorSupplier<K, V, T> { @Override public Processor<K, Change<V>> get() { return new KTableAggregateProcessor(); } KTableAggregate(String storeName, Initializer<T> initializer, Aggregator<? super K, ? super V, T> add, Aggregator<? super K, ? super V, T> remove); @Override void enableSendingOldValues(); @Override Processor<K, Change<V>> get(); @Override KTableValueGetterSupplier<K, T> view(); }
|
@Test public void shouldForwardToCorrectProcessorNodeWhenMultiCacheEvictions() throws Exception { final String tableOne = "tableOne"; final String tableTwo = "tableTwo"; final KStreamBuilder builder = new KStreamBuilder(); final String reduceTopic = "TestDriver-reducer-store-repartition"; final Map<String, Long> reduceResults = new HashMap<>(); final KTable<String, String> one = builder.table(Serdes.String(), Serdes.String(), tableOne, tableOne); final KTable<Long, String> two = builder.table(Serdes.Long(), Serdes.String(), tableTwo, tableTwo); final KTable<String, Long> reduce = two.groupBy(new KeyValueMapper<Long, String, KeyValue<String, Long>>() { @Override public KeyValue<String, Long> apply(final Long key, final String value) { return new KeyValue<>(value, key); } }, Serdes.String(), Serdes.Long()) .reduce(new Reducer<Long>() { @Override public Long apply(final Long value1, final Long value2) { return value1 + value2; } }, new Reducer<Long>() { @Override public Long apply(final Long value1, final Long value2) { return value1 - value2; } }, "reducer-store"); reduce.foreach(new ForeachAction<String, Long>() { @Override public void apply(final String key, final Long value) { reduceResults.put(key, value); } }); one.leftJoin(reduce, new ValueJoiner<String, Long, String>() { @Override public String apply(final String value1, final Long value2) { return value1 + ":" + value2; } }) .mapValues(new ValueMapper<String, String>() { @Override public String apply(final String value) { return value; } }); driver = new KStreamTestDriver(builder, stateDir, 111); driver.process(reduceTopic, "1", new Change<>(1L, null)); driver.process("tableOne", "2", "2"); driver.process(reduceTopic, "2", new Change<>(2L, null)); driver.process(reduceTopic, "2", new Change<>(2L, null)); assertEquals(Long.valueOf(2L), reduceResults.get("2")); driver.process("tableOne", "1", "5"); assertEquals(Long.valueOf(4L), reduceResults.get("2")); }
|
KStreamFlatMap implements ProcessorSupplier<K, V> { @Override public Processor<K, V> get() { return new KStreamFlatMapProcessor(); } KStreamFlatMap(KeyValueMapper<? super K, ? super V, ? extends Iterable<? extends KeyValue<? extends K1, ? extends V1>>> mapper); @Override Processor<K, V> get(); }
|
@Test public void testFlatMap() { KStreamBuilder builder = new KStreamBuilder(); KeyValueMapper<Number, Object, Iterable<KeyValue<String, String>>> mapper = new KeyValueMapper<Number, Object, Iterable<KeyValue<String, String>>>() { @Override public Iterable<KeyValue<String, String>> apply(Number key, Object value) { ArrayList<KeyValue<String, String>> result = new ArrayList<>(); for (int i = 0; i < key.intValue(); i++) { result.add(KeyValue.pair(Integer.toString(key.intValue() * 10 + i), value.toString())); } return result; } }; final int[] expectedKeys = {0, 1, 2, 3}; KStream<Integer, String> stream; MockProcessorSupplier<String, String> processor; processor = new MockProcessorSupplier<>(); stream = builder.stream(Serdes.Integer(), Serdes.String(), topicName); stream.flatMap(mapper).process(processor); driver = new KStreamTestDriver(builder); for (int expectedKey : expectedKeys) { driver.process(topicName, expectedKey, "V" + expectedKey); } assertEquals(6, processor.processed.size()); String[] expected = {"10:V1", "20:V2", "21:V2", "30:V3", "31:V3", "32:V3"}; for (int i = 0; i < expected.length; i++) { assertEquals(expected[i], processor.processed.get(i)); } }
|
KStreamFlatMapValues implements ProcessorSupplier<K, V> { @Override public Processor<K, V> get() { return new KStreamFlatMapValuesProcessor(); } KStreamFlatMapValues(ValueMapper<? super V, ? extends Iterable<? extends V1>> mapper); @Override Processor<K, V> get(); }
|
@Test public void testFlatMapValues() { KStreamBuilder builder = new KStreamBuilder(); ValueMapper<Number, Iterable<String>> mapper = new ValueMapper<Number, Iterable<String>>() { @Override public Iterable<String> apply(Number value) { ArrayList<String> result = new ArrayList<String>(); result.add("v" + value); result.add("V" + value); return result; } }; final int[] expectedKeys = {0, 1, 2, 3}; KStream<Integer, Integer> stream; MockProcessorSupplier<Integer, String> processor; processor = new MockProcessorSupplier<>(); stream = builder.stream(Serdes.Integer(), Serdes.Integer(), topicName); stream.flatMapValues(mapper).process(processor); driver = new KStreamTestDriver(builder); for (int expectedKey : expectedKeys) { driver.process(topicName, expectedKey, expectedKey); } assertEquals(8, processor.processed.size()); String[] expected = {"0:v0", "0:V0", "1:v1", "1:V1", "2:v2", "2:V2", "3:v3", "3:V3"}; for (int i = 0; i < expected.length; i++) { assertEquals(expected[i], processor.processed.get(i)); } }
|
KStreamImpl extends AbstractStream<K> implements KStream<K, V> { @Override public void to(String topic) { to(null, null, null, topic); } KStreamImpl(KStreamBuilder topology, String name, Set<String> sourceNodes,
boolean repartitionRequired); @Override KStream<K, V> filter(Predicate<? super K, ? super V> predicate); @Override KStream<K, V> filterNot(final Predicate<? super K, ? super V> predicate); @Override KStream<K1, V> selectKey(final KeyValueMapper<? super K, ? super V, ? extends K1> mapper); @Override KStream<K1, V1> map(KeyValueMapper<? super K, ? super V, ? extends KeyValue<? extends K1, ? extends V1>> mapper); @Override KStream<K, V1> mapValues(ValueMapper<? super V, ? extends V1> mapper); @Override void print(); @Override void print(String streamName); @Override void print(Serde<K> keySerde, Serde<V> valSerde); @Override void print(Serde<K> keySerde, Serde<V> valSerde, String streamName); @Override void writeAsText(String filePath); @Override void writeAsText(String filePath, String streamName); @Override void writeAsText(String filePath, Serde<K> keySerde, Serde<V> valSerde); @Override void writeAsText(String filePath, String streamName, Serde<K> keySerde, Serde<V> valSerde); @Override KStream<K1, V1> flatMap(KeyValueMapper<? super K, ? super V, ? extends Iterable<? extends KeyValue<? extends K1, ? extends V1>>> mapper); @Override KStream<K, V1> flatMapValues(ValueMapper<? super V, ? extends Iterable<? extends V1>> mapper); @Override @SuppressWarnings("unchecked") KStream<K, V>[] branch(Predicate<? super K, ? super V>... predicates); static KStream<K, V> merge(KStreamBuilder topology, KStream<K, V>[] streams); @Override KStream<K, V> through(Serde<K> keySerde, Serde<V> valSerde, StreamPartitioner<? super K, ? super V> partitioner, String topic); @Override void foreach(ForeachAction<? super K, ? super V> action); @Override KStream<K, V> peek(final ForeachAction<? super K, ? super V> action); @Override KStream<K, V> through(Serde<K> keySerde, Serde<V> valSerde, String topic); @Override KStream<K, V> through(StreamPartitioner<? super K, ? super V> partitioner, String topic); @Override KStream<K, V> through(String topic); @Override void to(String topic); @Override void to(StreamPartitioner<? super K, ? super V> partitioner, String topic); @Override void to(Serde<K> keySerde, Serde<V> valSerde, String topic); @SuppressWarnings("unchecked") @Override void to(final Serde<K> keySerde, final Serde<V> valSerde, StreamPartitioner<? super K, ? super V> partitioner, final String topic); @Override KStream<K1, V1> transform(TransformerSupplier<? super K, ? super V, KeyValue<K1, V1>> transformerSupplier, String... stateStoreNames); @Override KStream<K, V1> transformValues(ValueTransformerSupplier<? super V, ? extends V1> valueTransformerSupplier, String... stateStoreNames); @Override void process(final ProcessorSupplier<? super K, ? super V> processorSupplier, String... stateStoreNames); @Override KStream<K, R> join(
final KStream<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final JoinWindows windows,
final Serde<K> keySerde,
final Serde<V> thisValueSerde,
final Serde<V1> otherValueSerde); @Override KStream<K, R> join(
final KStream<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final JoinWindows windows); @Override KStream<K, R> outerJoin(
final KStream<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final JoinWindows windows,
final Serde<K> keySerde,
final Serde<V> thisValueSerde,
final Serde<V1> otherValueSerde); @Override KStream<K, R> outerJoin(
final KStream<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final JoinWindows windows); @Override KStream<K, R> leftJoin(
final KStream<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final JoinWindows windows,
final Serde<K> keySerde,
final Serde<V> thisValSerde,
final Serde<V1> otherValueSerde); @Override KStream<K, R> leftJoin(
KStream<K, V1> other,
ValueJoiner<? super V, ? super V1, ? extends R> joiner,
JoinWindows windows); @Override KStream<K, R> join(final KTable<K, V1> other, final ValueJoiner<? super V, ? super V1, ? extends R> joiner); @Override KStream<K, R> join(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final Serde<K> keySerde,
final Serde<V> valueSerde); @Override KStream<K, R> leftJoin(final GlobalKTable<K1, V1> globalTable,
final KeyValueMapper<? super K, ? super V, ? extends K1> keyMapper,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner); @Override KStream<K, V2> join(final GlobalKTable<K1, V1> globalTable,
final KeyValueMapper<? super K, ? super V, ? extends K1> keyMapper,
final ValueJoiner<? super V, ? super V1, ? extends V2> joiner); @Override KStream<K, R> leftJoin(final KTable<K, V1> other, final ValueJoiner<? super V, ? super V1, ? extends R> joiner); KStream<K, R> leftJoin(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final Serde<K> keySerde,
final Serde<V> valueSerde); @Override KGroupedStream<K1, V> groupBy(KeyValueMapper<? super K, ? super V, K1> selector); @Override KGroupedStream<K1, V> groupBy(KeyValueMapper<? super K, ? super V, K1> selector,
Serde<K1> keySerde,
Serde<V> valSerde); @Override KGroupedStream<K, V> groupByKey(); @Override KGroupedStream<K, V> groupByKey(Serde<K> keySerde,
Serde<V> valSerde); static final String FILTER_NAME; static final String PEEK_NAME; static final String JOINTHIS_NAME; static final String JOINOTHER_NAME; static final String JOIN_NAME; static final String LEFTJOIN_NAME; static final String MERGE_NAME; static final String OUTERTHIS_NAME; static final String OUTEROTHER_NAME; static final String SINK_NAME; static final String SOURCE_NAME; static final String REPARTITION_TOPIC_SUFFIX; }
|
@Test public void testToWithNullValueSerdeDoesntNPE() { final KStreamBuilder builder = new KStreamBuilder(); final KStream<String, String> inputStream = builder.stream(stringSerde, stringSerde, "input"); inputStream.to(stringSerde, null, "output"); }
@Test(expected = NullPointerException.class) public void shouldNotAllowNullTopicOnTo() throws Exception { testStream.to(null); }
|
KStreamImpl extends AbstractStream<K> implements KStream<K, V> { @Override public KStream<K, V> filter(Predicate<? super K, ? super V> predicate) { Objects.requireNonNull(predicate, "predicate can't be null"); String name = topology.newName(FILTER_NAME); topology.addProcessor(name, new KStreamFilter<>(predicate, false), this.name); return new KStreamImpl<>(topology, name, sourceNodes, this.repartitionRequired); } KStreamImpl(KStreamBuilder topology, String name, Set<String> sourceNodes,
boolean repartitionRequired); @Override KStream<K, V> filter(Predicate<? super K, ? super V> predicate); @Override KStream<K, V> filterNot(final Predicate<? super K, ? super V> predicate); @Override KStream<K1, V> selectKey(final KeyValueMapper<? super K, ? super V, ? extends K1> mapper); @Override KStream<K1, V1> map(KeyValueMapper<? super K, ? super V, ? extends KeyValue<? extends K1, ? extends V1>> mapper); @Override KStream<K, V1> mapValues(ValueMapper<? super V, ? extends V1> mapper); @Override void print(); @Override void print(String streamName); @Override void print(Serde<K> keySerde, Serde<V> valSerde); @Override void print(Serde<K> keySerde, Serde<V> valSerde, String streamName); @Override void writeAsText(String filePath); @Override void writeAsText(String filePath, String streamName); @Override void writeAsText(String filePath, Serde<K> keySerde, Serde<V> valSerde); @Override void writeAsText(String filePath, String streamName, Serde<K> keySerde, Serde<V> valSerde); @Override KStream<K1, V1> flatMap(KeyValueMapper<? super K, ? super V, ? extends Iterable<? extends KeyValue<? extends K1, ? extends V1>>> mapper); @Override KStream<K, V1> flatMapValues(ValueMapper<? super V, ? extends Iterable<? extends V1>> mapper); @Override @SuppressWarnings("unchecked") KStream<K, V>[] branch(Predicate<? super K, ? super V>... predicates); static KStream<K, V> merge(KStreamBuilder topology, KStream<K, V>[] streams); @Override KStream<K, V> through(Serde<K> keySerde, Serde<V> valSerde, StreamPartitioner<? super K, ? super V> partitioner, String topic); @Override void foreach(ForeachAction<? super K, ? super V> action); @Override KStream<K, V> peek(final ForeachAction<? super K, ? super V> action); @Override KStream<K, V> through(Serde<K> keySerde, Serde<V> valSerde, String topic); @Override KStream<K, V> through(StreamPartitioner<? super K, ? super V> partitioner, String topic); @Override KStream<K, V> through(String topic); @Override void to(String topic); @Override void to(StreamPartitioner<? super K, ? super V> partitioner, String topic); @Override void to(Serde<K> keySerde, Serde<V> valSerde, String topic); @SuppressWarnings("unchecked") @Override void to(final Serde<K> keySerde, final Serde<V> valSerde, StreamPartitioner<? super K, ? super V> partitioner, final String topic); @Override KStream<K1, V1> transform(TransformerSupplier<? super K, ? super V, KeyValue<K1, V1>> transformerSupplier, String... stateStoreNames); @Override KStream<K, V1> transformValues(ValueTransformerSupplier<? super V, ? extends V1> valueTransformerSupplier, String... stateStoreNames); @Override void process(final ProcessorSupplier<? super K, ? super V> processorSupplier, String... stateStoreNames); @Override KStream<K, R> join(
final KStream<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final JoinWindows windows,
final Serde<K> keySerde,
final Serde<V> thisValueSerde,
final Serde<V1> otherValueSerde); @Override KStream<K, R> join(
final KStream<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final JoinWindows windows); @Override KStream<K, R> outerJoin(
final KStream<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final JoinWindows windows,
final Serde<K> keySerde,
final Serde<V> thisValueSerde,
final Serde<V1> otherValueSerde); @Override KStream<K, R> outerJoin(
final KStream<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final JoinWindows windows); @Override KStream<K, R> leftJoin(
final KStream<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final JoinWindows windows,
final Serde<K> keySerde,
final Serde<V> thisValSerde,
final Serde<V1> otherValueSerde); @Override KStream<K, R> leftJoin(
KStream<K, V1> other,
ValueJoiner<? super V, ? super V1, ? extends R> joiner,
JoinWindows windows); @Override KStream<K, R> join(final KTable<K, V1> other, final ValueJoiner<? super V, ? super V1, ? extends R> joiner); @Override KStream<K, R> join(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final Serde<K> keySerde,
final Serde<V> valueSerde); @Override KStream<K, R> leftJoin(final GlobalKTable<K1, V1> globalTable,
final KeyValueMapper<? super K, ? super V, ? extends K1> keyMapper,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner); @Override KStream<K, V2> join(final GlobalKTable<K1, V1> globalTable,
final KeyValueMapper<? super K, ? super V, ? extends K1> keyMapper,
final ValueJoiner<? super V, ? super V1, ? extends V2> joiner); @Override KStream<K, R> leftJoin(final KTable<K, V1> other, final ValueJoiner<? super V, ? super V1, ? extends R> joiner); KStream<K, R> leftJoin(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final Serde<K> keySerde,
final Serde<V> valueSerde); @Override KGroupedStream<K1, V> groupBy(KeyValueMapper<? super K, ? super V, K1> selector); @Override KGroupedStream<K1, V> groupBy(KeyValueMapper<? super K, ? super V, K1> selector,
Serde<K1> keySerde,
Serde<V> valSerde); @Override KGroupedStream<K, V> groupByKey(); @Override KGroupedStream<K, V> groupByKey(Serde<K> keySerde,
Serde<V> valSerde); static final String FILTER_NAME; static final String PEEK_NAME; static final String JOINTHIS_NAME; static final String JOINOTHER_NAME; static final String JOIN_NAME; static final String LEFTJOIN_NAME; static final String MERGE_NAME; static final String OUTERTHIS_NAME; static final String OUTEROTHER_NAME; static final String SINK_NAME; static final String SOURCE_NAME; static final String REPARTITION_TOPIC_SUFFIX; }
|
@Test(expected = NullPointerException.class) public void shouldNotAllowNullPredicateOnFilter() throws Exception { testStream.filter(null); }
|
KStreamImpl extends AbstractStream<K> implements KStream<K, V> { @Override public KStream<K, V> filterNot(final Predicate<? super K, ? super V> predicate) { Objects.requireNonNull(predicate, "predicate can't be null"); String name = topology.newName(FILTER_NAME); topology.addProcessor(name, new KStreamFilter<>(predicate, true), this.name); return new KStreamImpl<>(topology, name, sourceNodes, this.repartitionRequired); } KStreamImpl(KStreamBuilder topology, String name, Set<String> sourceNodes,
boolean repartitionRequired); @Override KStream<K, V> filter(Predicate<? super K, ? super V> predicate); @Override KStream<K, V> filterNot(final Predicate<? super K, ? super V> predicate); @Override KStream<K1, V> selectKey(final KeyValueMapper<? super K, ? super V, ? extends K1> mapper); @Override KStream<K1, V1> map(KeyValueMapper<? super K, ? super V, ? extends KeyValue<? extends K1, ? extends V1>> mapper); @Override KStream<K, V1> mapValues(ValueMapper<? super V, ? extends V1> mapper); @Override void print(); @Override void print(String streamName); @Override void print(Serde<K> keySerde, Serde<V> valSerde); @Override void print(Serde<K> keySerde, Serde<V> valSerde, String streamName); @Override void writeAsText(String filePath); @Override void writeAsText(String filePath, String streamName); @Override void writeAsText(String filePath, Serde<K> keySerde, Serde<V> valSerde); @Override void writeAsText(String filePath, String streamName, Serde<K> keySerde, Serde<V> valSerde); @Override KStream<K1, V1> flatMap(KeyValueMapper<? super K, ? super V, ? extends Iterable<? extends KeyValue<? extends K1, ? extends V1>>> mapper); @Override KStream<K, V1> flatMapValues(ValueMapper<? super V, ? extends Iterable<? extends V1>> mapper); @Override @SuppressWarnings("unchecked") KStream<K, V>[] branch(Predicate<? super K, ? super V>... predicates); static KStream<K, V> merge(KStreamBuilder topology, KStream<K, V>[] streams); @Override KStream<K, V> through(Serde<K> keySerde, Serde<V> valSerde, StreamPartitioner<? super K, ? super V> partitioner, String topic); @Override void foreach(ForeachAction<? super K, ? super V> action); @Override KStream<K, V> peek(final ForeachAction<? super K, ? super V> action); @Override KStream<K, V> through(Serde<K> keySerde, Serde<V> valSerde, String topic); @Override KStream<K, V> through(StreamPartitioner<? super K, ? super V> partitioner, String topic); @Override KStream<K, V> through(String topic); @Override void to(String topic); @Override void to(StreamPartitioner<? super K, ? super V> partitioner, String topic); @Override void to(Serde<K> keySerde, Serde<V> valSerde, String topic); @SuppressWarnings("unchecked") @Override void to(final Serde<K> keySerde, final Serde<V> valSerde, StreamPartitioner<? super K, ? super V> partitioner, final String topic); @Override KStream<K1, V1> transform(TransformerSupplier<? super K, ? super V, KeyValue<K1, V1>> transformerSupplier, String... stateStoreNames); @Override KStream<K, V1> transformValues(ValueTransformerSupplier<? super V, ? extends V1> valueTransformerSupplier, String... stateStoreNames); @Override void process(final ProcessorSupplier<? super K, ? super V> processorSupplier, String... stateStoreNames); @Override KStream<K, R> join(
final KStream<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final JoinWindows windows,
final Serde<K> keySerde,
final Serde<V> thisValueSerde,
final Serde<V1> otherValueSerde); @Override KStream<K, R> join(
final KStream<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final JoinWindows windows); @Override KStream<K, R> outerJoin(
final KStream<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final JoinWindows windows,
final Serde<K> keySerde,
final Serde<V> thisValueSerde,
final Serde<V1> otherValueSerde); @Override KStream<K, R> outerJoin(
final KStream<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final JoinWindows windows); @Override KStream<K, R> leftJoin(
final KStream<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final JoinWindows windows,
final Serde<K> keySerde,
final Serde<V> thisValSerde,
final Serde<V1> otherValueSerde); @Override KStream<K, R> leftJoin(
KStream<K, V1> other,
ValueJoiner<? super V, ? super V1, ? extends R> joiner,
JoinWindows windows); @Override KStream<K, R> join(final KTable<K, V1> other, final ValueJoiner<? super V, ? super V1, ? extends R> joiner); @Override KStream<K, R> join(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final Serde<K> keySerde,
final Serde<V> valueSerde); @Override KStream<K, R> leftJoin(final GlobalKTable<K1, V1> globalTable,
final KeyValueMapper<? super K, ? super V, ? extends K1> keyMapper,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner); @Override KStream<K, V2> join(final GlobalKTable<K1, V1> globalTable,
final KeyValueMapper<? super K, ? super V, ? extends K1> keyMapper,
final ValueJoiner<? super V, ? super V1, ? extends V2> joiner); @Override KStream<K, R> leftJoin(final KTable<K, V1> other, final ValueJoiner<? super V, ? super V1, ? extends R> joiner); KStream<K, R> leftJoin(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final Serde<K> keySerde,
final Serde<V> valueSerde); @Override KGroupedStream<K1, V> groupBy(KeyValueMapper<? super K, ? super V, K1> selector); @Override KGroupedStream<K1, V> groupBy(KeyValueMapper<? super K, ? super V, K1> selector,
Serde<K1> keySerde,
Serde<V> valSerde); @Override KGroupedStream<K, V> groupByKey(); @Override KGroupedStream<K, V> groupByKey(Serde<K> keySerde,
Serde<V> valSerde); static final String FILTER_NAME; static final String PEEK_NAME; static final String JOINTHIS_NAME; static final String JOINOTHER_NAME; static final String JOIN_NAME; static final String LEFTJOIN_NAME; static final String MERGE_NAME; static final String OUTERTHIS_NAME; static final String OUTEROTHER_NAME; static final String SINK_NAME; static final String SOURCE_NAME; static final String REPARTITION_TOPIC_SUFFIX; }
|
@Test(expected = NullPointerException.class) public void shouldNotAllowNullPredicateOnFilterNot() throws Exception { testStream.filterNot(null); }
|
KStreamImpl extends AbstractStream<K> implements KStream<K, V> { @Override public <K1> KStream<K1, V> selectKey(final KeyValueMapper<? super K, ? super V, ? extends K1> mapper) { Objects.requireNonNull(mapper, "mapper can't be null"); return new KStreamImpl<>(topology, internalSelectKey(mapper), sourceNodes, true); } KStreamImpl(KStreamBuilder topology, String name, Set<String> sourceNodes,
boolean repartitionRequired); @Override KStream<K, V> filter(Predicate<? super K, ? super V> predicate); @Override KStream<K, V> filterNot(final Predicate<? super K, ? super V> predicate); @Override KStream<K1, V> selectKey(final KeyValueMapper<? super K, ? super V, ? extends K1> mapper); @Override KStream<K1, V1> map(KeyValueMapper<? super K, ? super V, ? extends KeyValue<? extends K1, ? extends V1>> mapper); @Override KStream<K, V1> mapValues(ValueMapper<? super V, ? extends V1> mapper); @Override void print(); @Override void print(String streamName); @Override void print(Serde<K> keySerde, Serde<V> valSerde); @Override void print(Serde<K> keySerde, Serde<V> valSerde, String streamName); @Override void writeAsText(String filePath); @Override void writeAsText(String filePath, String streamName); @Override void writeAsText(String filePath, Serde<K> keySerde, Serde<V> valSerde); @Override void writeAsText(String filePath, String streamName, Serde<K> keySerde, Serde<V> valSerde); @Override KStream<K1, V1> flatMap(KeyValueMapper<? super K, ? super V, ? extends Iterable<? extends KeyValue<? extends K1, ? extends V1>>> mapper); @Override KStream<K, V1> flatMapValues(ValueMapper<? super V, ? extends Iterable<? extends V1>> mapper); @Override @SuppressWarnings("unchecked") KStream<K, V>[] branch(Predicate<? super K, ? super V>... predicates); static KStream<K, V> merge(KStreamBuilder topology, KStream<K, V>[] streams); @Override KStream<K, V> through(Serde<K> keySerde, Serde<V> valSerde, StreamPartitioner<? super K, ? super V> partitioner, String topic); @Override void foreach(ForeachAction<? super K, ? super V> action); @Override KStream<K, V> peek(final ForeachAction<? super K, ? super V> action); @Override KStream<K, V> through(Serde<K> keySerde, Serde<V> valSerde, String topic); @Override KStream<K, V> through(StreamPartitioner<? super K, ? super V> partitioner, String topic); @Override KStream<K, V> through(String topic); @Override void to(String topic); @Override void to(StreamPartitioner<? super K, ? super V> partitioner, String topic); @Override void to(Serde<K> keySerde, Serde<V> valSerde, String topic); @SuppressWarnings("unchecked") @Override void to(final Serde<K> keySerde, final Serde<V> valSerde, StreamPartitioner<? super K, ? super V> partitioner, final String topic); @Override KStream<K1, V1> transform(TransformerSupplier<? super K, ? super V, KeyValue<K1, V1>> transformerSupplier, String... stateStoreNames); @Override KStream<K, V1> transformValues(ValueTransformerSupplier<? super V, ? extends V1> valueTransformerSupplier, String... stateStoreNames); @Override void process(final ProcessorSupplier<? super K, ? super V> processorSupplier, String... stateStoreNames); @Override KStream<K, R> join(
final KStream<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final JoinWindows windows,
final Serde<K> keySerde,
final Serde<V> thisValueSerde,
final Serde<V1> otherValueSerde); @Override KStream<K, R> join(
final KStream<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final JoinWindows windows); @Override KStream<K, R> outerJoin(
final KStream<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final JoinWindows windows,
final Serde<K> keySerde,
final Serde<V> thisValueSerde,
final Serde<V1> otherValueSerde); @Override KStream<K, R> outerJoin(
final KStream<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final JoinWindows windows); @Override KStream<K, R> leftJoin(
final KStream<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final JoinWindows windows,
final Serde<K> keySerde,
final Serde<V> thisValSerde,
final Serde<V1> otherValueSerde); @Override KStream<K, R> leftJoin(
KStream<K, V1> other,
ValueJoiner<? super V, ? super V1, ? extends R> joiner,
JoinWindows windows); @Override KStream<K, R> join(final KTable<K, V1> other, final ValueJoiner<? super V, ? super V1, ? extends R> joiner); @Override KStream<K, R> join(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final Serde<K> keySerde,
final Serde<V> valueSerde); @Override KStream<K, R> leftJoin(final GlobalKTable<K1, V1> globalTable,
final KeyValueMapper<? super K, ? super V, ? extends K1> keyMapper,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner); @Override KStream<K, V2> join(final GlobalKTable<K1, V1> globalTable,
final KeyValueMapper<? super K, ? super V, ? extends K1> keyMapper,
final ValueJoiner<? super V, ? super V1, ? extends V2> joiner); @Override KStream<K, R> leftJoin(final KTable<K, V1> other, final ValueJoiner<? super V, ? super V1, ? extends R> joiner); KStream<K, R> leftJoin(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final Serde<K> keySerde,
final Serde<V> valueSerde); @Override KGroupedStream<K1, V> groupBy(KeyValueMapper<? super K, ? super V, K1> selector); @Override KGroupedStream<K1, V> groupBy(KeyValueMapper<? super K, ? super V, K1> selector,
Serde<K1> keySerde,
Serde<V> valSerde); @Override KGroupedStream<K, V> groupByKey(); @Override KGroupedStream<K, V> groupByKey(Serde<K> keySerde,
Serde<V> valSerde); static final String FILTER_NAME; static final String PEEK_NAME; static final String JOINTHIS_NAME; static final String JOINOTHER_NAME; static final String JOIN_NAME; static final String LEFTJOIN_NAME; static final String MERGE_NAME; static final String OUTERTHIS_NAME; static final String OUTEROTHER_NAME; static final String SINK_NAME; static final String SOURCE_NAME; static final String REPARTITION_TOPIC_SUFFIX; }
|
@Test(expected = NullPointerException.class) public void shouldNotAllowNullMapperOnSelectKey() throws Exception { testStream.selectKey(null); }
|
KStreamImpl extends AbstractStream<K> implements KStream<K, V> { @Override public <K1, V1> KStream<K1, V1> map(KeyValueMapper<? super K, ? super V, ? extends KeyValue<? extends K1, ? extends V1>> mapper) { Objects.requireNonNull(mapper, "mapper can't be null"); String name = topology.newName(MAP_NAME); topology.addProcessor(name, new KStreamMap<K, V, K1, V1>(mapper), this.name); return new KStreamImpl<>(topology, name, sourceNodes, true); } KStreamImpl(KStreamBuilder topology, String name, Set<String> sourceNodes,
boolean repartitionRequired); @Override KStream<K, V> filter(Predicate<? super K, ? super V> predicate); @Override KStream<K, V> filterNot(final Predicate<? super K, ? super V> predicate); @Override KStream<K1, V> selectKey(final KeyValueMapper<? super K, ? super V, ? extends K1> mapper); @Override KStream<K1, V1> map(KeyValueMapper<? super K, ? super V, ? extends KeyValue<? extends K1, ? extends V1>> mapper); @Override KStream<K, V1> mapValues(ValueMapper<? super V, ? extends V1> mapper); @Override void print(); @Override void print(String streamName); @Override void print(Serde<K> keySerde, Serde<V> valSerde); @Override void print(Serde<K> keySerde, Serde<V> valSerde, String streamName); @Override void writeAsText(String filePath); @Override void writeAsText(String filePath, String streamName); @Override void writeAsText(String filePath, Serde<K> keySerde, Serde<V> valSerde); @Override void writeAsText(String filePath, String streamName, Serde<K> keySerde, Serde<V> valSerde); @Override KStream<K1, V1> flatMap(KeyValueMapper<? super K, ? super V, ? extends Iterable<? extends KeyValue<? extends K1, ? extends V1>>> mapper); @Override KStream<K, V1> flatMapValues(ValueMapper<? super V, ? extends Iterable<? extends V1>> mapper); @Override @SuppressWarnings("unchecked") KStream<K, V>[] branch(Predicate<? super K, ? super V>... predicates); static KStream<K, V> merge(KStreamBuilder topology, KStream<K, V>[] streams); @Override KStream<K, V> through(Serde<K> keySerde, Serde<V> valSerde, StreamPartitioner<? super K, ? super V> partitioner, String topic); @Override void foreach(ForeachAction<? super K, ? super V> action); @Override KStream<K, V> peek(final ForeachAction<? super K, ? super V> action); @Override KStream<K, V> through(Serde<K> keySerde, Serde<V> valSerde, String topic); @Override KStream<K, V> through(StreamPartitioner<? super K, ? super V> partitioner, String topic); @Override KStream<K, V> through(String topic); @Override void to(String topic); @Override void to(StreamPartitioner<? super K, ? super V> partitioner, String topic); @Override void to(Serde<K> keySerde, Serde<V> valSerde, String topic); @SuppressWarnings("unchecked") @Override void to(final Serde<K> keySerde, final Serde<V> valSerde, StreamPartitioner<? super K, ? super V> partitioner, final String topic); @Override KStream<K1, V1> transform(TransformerSupplier<? super K, ? super V, KeyValue<K1, V1>> transformerSupplier, String... stateStoreNames); @Override KStream<K, V1> transformValues(ValueTransformerSupplier<? super V, ? extends V1> valueTransformerSupplier, String... stateStoreNames); @Override void process(final ProcessorSupplier<? super K, ? super V> processorSupplier, String... stateStoreNames); @Override KStream<K, R> join(
final KStream<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final JoinWindows windows,
final Serde<K> keySerde,
final Serde<V> thisValueSerde,
final Serde<V1> otherValueSerde); @Override KStream<K, R> join(
final KStream<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final JoinWindows windows); @Override KStream<K, R> outerJoin(
final KStream<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final JoinWindows windows,
final Serde<K> keySerde,
final Serde<V> thisValueSerde,
final Serde<V1> otherValueSerde); @Override KStream<K, R> outerJoin(
final KStream<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final JoinWindows windows); @Override KStream<K, R> leftJoin(
final KStream<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final JoinWindows windows,
final Serde<K> keySerde,
final Serde<V> thisValSerde,
final Serde<V1> otherValueSerde); @Override KStream<K, R> leftJoin(
KStream<K, V1> other,
ValueJoiner<? super V, ? super V1, ? extends R> joiner,
JoinWindows windows); @Override KStream<K, R> join(final KTable<K, V1> other, final ValueJoiner<? super V, ? super V1, ? extends R> joiner); @Override KStream<K, R> join(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final Serde<K> keySerde,
final Serde<V> valueSerde); @Override KStream<K, R> leftJoin(final GlobalKTable<K1, V1> globalTable,
final KeyValueMapper<? super K, ? super V, ? extends K1> keyMapper,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner); @Override KStream<K, V2> join(final GlobalKTable<K1, V1> globalTable,
final KeyValueMapper<? super K, ? super V, ? extends K1> keyMapper,
final ValueJoiner<? super V, ? super V1, ? extends V2> joiner); @Override KStream<K, R> leftJoin(final KTable<K, V1> other, final ValueJoiner<? super V, ? super V1, ? extends R> joiner); KStream<K, R> leftJoin(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final Serde<K> keySerde,
final Serde<V> valueSerde); @Override KGroupedStream<K1, V> groupBy(KeyValueMapper<? super K, ? super V, K1> selector); @Override KGroupedStream<K1, V> groupBy(KeyValueMapper<? super K, ? super V, K1> selector,
Serde<K1> keySerde,
Serde<V> valSerde); @Override KGroupedStream<K, V> groupByKey(); @Override KGroupedStream<K, V> groupByKey(Serde<K> keySerde,
Serde<V> valSerde); static final String FILTER_NAME; static final String PEEK_NAME; static final String JOINTHIS_NAME; static final String JOINOTHER_NAME; static final String JOIN_NAME; static final String LEFTJOIN_NAME; static final String MERGE_NAME; static final String OUTERTHIS_NAME; static final String OUTEROTHER_NAME; static final String SINK_NAME; static final String SOURCE_NAME; static final String REPARTITION_TOPIC_SUFFIX; }
|
@Test(expected = NullPointerException.class) public void shouldNotAllowNullMapperOnMap() throws Exception { testStream.map(null); }
|
KStreamImpl extends AbstractStream<K> implements KStream<K, V> { @Override public <V1> KStream<K, V1> mapValues(ValueMapper<? super V, ? extends V1> mapper) { Objects.requireNonNull(mapper, "mapper can't be null"); String name = topology.newName(MAPVALUES_NAME); topology.addProcessor(name, new KStreamMapValues<>(mapper), this.name); return new KStreamImpl<>(topology, name, sourceNodes, this.repartitionRequired); } KStreamImpl(KStreamBuilder topology, String name, Set<String> sourceNodes,
boolean repartitionRequired); @Override KStream<K, V> filter(Predicate<? super K, ? super V> predicate); @Override KStream<K, V> filterNot(final Predicate<? super K, ? super V> predicate); @Override KStream<K1, V> selectKey(final KeyValueMapper<? super K, ? super V, ? extends K1> mapper); @Override KStream<K1, V1> map(KeyValueMapper<? super K, ? super V, ? extends KeyValue<? extends K1, ? extends V1>> mapper); @Override KStream<K, V1> mapValues(ValueMapper<? super V, ? extends V1> mapper); @Override void print(); @Override void print(String streamName); @Override void print(Serde<K> keySerde, Serde<V> valSerde); @Override void print(Serde<K> keySerde, Serde<V> valSerde, String streamName); @Override void writeAsText(String filePath); @Override void writeAsText(String filePath, String streamName); @Override void writeAsText(String filePath, Serde<K> keySerde, Serde<V> valSerde); @Override void writeAsText(String filePath, String streamName, Serde<K> keySerde, Serde<V> valSerde); @Override KStream<K1, V1> flatMap(KeyValueMapper<? super K, ? super V, ? extends Iterable<? extends KeyValue<? extends K1, ? extends V1>>> mapper); @Override KStream<K, V1> flatMapValues(ValueMapper<? super V, ? extends Iterable<? extends V1>> mapper); @Override @SuppressWarnings("unchecked") KStream<K, V>[] branch(Predicate<? super K, ? super V>... predicates); static KStream<K, V> merge(KStreamBuilder topology, KStream<K, V>[] streams); @Override KStream<K, V> through(Serde<K> keySerde, Serde<V> valSerde, StreamPartitioner<? super K, ? super V> partitioner, String topic); @Override void foreach(ForeachAction<? super K, ? super V> action); @Override KStream<K, V> peek(final ForeachAction<? super K, ? super V> action); @Override KStream<K, V> through(Serde<K> keySerde, Serde<V> valSerde, String topic); @Override KStream<K, V> through(StreamPartitioner<? super K, ? super V> partitioner, String topic); @Override KStream<K, V> through(String topic); @Override void to(String topic); @Override void to(StreamPartitioner<? super K, ? super V> partitioner, String topic); @Override void to(Serde<K> keySerde, Serde<V> valSerde, String topic); @SuppressWarnings("unchecked") @Override void to(final Serde<K> keySerde, final Serde<V> valSerde, StreamPartitioner<? super K, ? super V> partitioner, final String topic); @Override KStream<K1, V1> transform(TransformerSupplier<? super K, ? super V, KeyValue<K1, V1>> transformerSupplier, String... stateStoreNames); @Override KStream<K, V1> transformValues(ValueTransformerSupplier<? super V, ? extends V1> valueTransformerSupplier, String... stateStoreNames); @Override void process(final ProcessorSupplier<? super K, ? super V> processorSupplier, String... stateStoreNames); @Override KStream<K, R> join(
final KStream<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final JoinWindows windows,
final Serde<K> keySerde,
final Serde<V> thisValueSerde,
final Serde<V1> otherValueSerde); @Override KStream<K, R> join(
final KStream<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final JoinWindows windows); @Override KStream<K, R> outerJoin(
final KStream<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final JoinWindows windows,
final Serde<K> keySerde,
final Serde<V> thisValueSerde,
final Serde<V1> otherValueSerde); @Override KStream<K, R> outerJoin(
final KStream<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final JoinWindows windows); @Override KStream<K, R> leftJoin(
final KStream<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final JoinWindows windows,
final Serde<K> keySerde,
final Serde<V> thisValSerde,
final Serde<V1> otherValueSerde); @Override KStream<K, R> leftJoin(
KStream<K, V1> other,
ValueJoiner<? super V, ? super V1, ? extends R> joiner,
JoinWindows windows); @Override KStream<K, R> join(final KTable<K, V1> other, final ValueJoiner<? super V, ? super V1, ? extends R> joiner); @Override KStream<K, R> join(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final Serde<K> keySerde,
final Serde<V> valueSerde); @Override KStream<K, R> leftJoin(final GlobalKTable<K1, V1> globalTable,
final KeyValueMapper<? super K, ? super V, ? extends K1> keyMapper,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner); @Override KStream<K, V2> join(final GlobalKTable<K1, V1> globalTable,
final KeyValueMapper<? super K, ? super V, ? extends K1> keyMapper,
final ValueJoiner<? super V, ? super V1, ? extends V2> joiner); @Override KStream<K, R> leftJoin(final KTable<K, V1> other, final ValueJoiner<? super V, ? super V1, ? extends R> joiner); KStream<K, R> leftJoin(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final Serde<K> keySerde,
final Serde<V> valueSerde); @Override KGroupedStream<K1, V> groupBy(KeyValueMapper<? super K, ? super V, K1> selector); @Override KGroupedStream<K1, V> groupBy(KeyValueMapper<? super K, ? super V, K1> selector,
Serde<K1> keySerde,
Serde<V> valSerde); @Override KGroupedStream<K, V> groupByKey(); @Override KGroupedStream<K, V> groupByKey(Serde<K> keySerde,
Serde<V> valSerde); static final String FILTER_NAME; static final String PEEK_NAME; static final String JOINTHIS_NAME; static final String JOINOTHER_NAME; static final String JOIN_NAME; static final String LEFTJOIN_NAME; static final String MERGE_NAME; static final String OUTERTHIS_NAME; static final String OUTEROTHER_NAME; static final String SINK_NAME; static final String SOURCE_NAME; static final String REPARTITION_TOPIC_SUFFIX; }
|
@Test(expected = NullPointerException.class) public void shouldNotAllowNullMapperOnMapValues() throws Exception { testStream.mapValues(null); }
|
KStreamImpl extends AbstractStream<K> implements KStream<K, V> { @Override public void writeAsText(String filePath) { writeAsText(filePath, null, null, null); } KStreamImpl(KStreamBuilder topology, String name, Set<String> sourceNodes,
boolean repartitionRequired); @Override KStream<K, V> filter(Predicate<? super K, ? super V> predicate); @Override KStream<K, V> filterNot(final Predicate<? super K, ? super V> predicate); @Override KStream<K1, V> selectKey(final KeyValueMapper<? super K, ? super V, ? extends K1> mapper); @Override KStream<K1, V1> map(KeyValueMapper<? super K, ? super V, ? extends KeyValue<? extends K1, ? extends V1>> mapper); @Override KStream<K, V1> mapValues(ValueMapper<? super V, ? extends V1> mapper); @Override void print(); @Override void print(String streamName); @Override void print(Serde<K> keySerde, Serde<V> valSerde); @Override void print(Serde<K> keySerde, Serde<V> valSerde, String streamName); @Override void writeAsText(String filePath); @Override void writeAsText(String filePath, String streamName); @Override void writeAsText(String filePath, Serde<K> keySerde, Serde<V> valSerde); @Override void writeAsText(String filePath, String streamName, Serde<K> keySerde, Serde<V> valSerde); @Override KStream<K1, V1> flatMap(KeyValueMapper<? super K, ? super V, ? extends Iterable<? extends KeyValue<? extends K1, ? extends V1>>> mapper); @Override KStream<K, V1> flatMapValues(ValueMapper<? super V, ? extends Iterable<? extends V1>> mapper); @Override @SuppressWarnings("unchecked") KStream<K, V>[] branch(Predicate<? super K, ? super V>... predicates); static KStream<K, V> merge(KStreamBuilder topology, KStream<K, V>[] streams); @Override KStream<K, V> through(Serde<K> keySerde, Serde<V> valSerde, StreamPartitioner<? super K, ? super V> partitioner, String topic); @Override void foreach(ForeachAction<? super K, ? super V> action); @Override KStream<K, V> peek(final ForeachAction<? super K, ? super V> action); @Override KStream<K, V> through(Serde<K> keySerde, Serde<V> valSerde, String topic); @Override KStream<K, V> through(StreamPartitioner<? super K, ? super V> partitioner, String topic); @Override KStream<K, V> through(String topic); @Override void to(String topic); @Override void to(StreamPartitioner<? super K, ? super V> partitioner, String topic); @Override void to(Serde<K> keySerde, Serde<V> valSerde, String topic); @SuppressWarnings("unchecked") @Override void to(final Serde<K> keySerde, final Serde<V> valSerde, StreamPartitioner<? super K, ? super V> partitioner, final String topic); @Override KStream<K1, V1> transform(TransformerSupplier<? super K, ? super V, KeyValue<K1, V1>> transformerSupplier, String... stateStoreNames); @Override KStream<K, V1> transformValues(ValueTransformerSupplier<? super V, ? extends V1> valueTransformerSupplier, String... stateStoreNames); @Override void process(final ProcessorSupplier<? super K, ? super V> processorSupplier, String... stateStoreNames); @Override KStream<K, R> join(
final KStream<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final JoinWindows windows,
final Serde<K> keySerde,
final Serde<V> thisValueSerde,
final Serde<V1> otherValueSerde); @Override KStream<K, R> join(
final KStream<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final JoinWindows windows); @Override KStream<K, R> outerJoin(
final KStream<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final JoinWindows windows,
final Serde<K> keySerde,
final Serde<V> thisValueSerde,
final Serde<V1> otherValueSerde); @Override KStream<K, R> outerJoin(
final KStream<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final JoinWindows windows); @Override KStream<K, R> leftJoin(
final KStream<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final JoinWindows windows,
final Serde<K> keySerde,
final Serde<V> thisValSerde,
final Serde<V1> otherValueSerde); @Override KStream<K, R> leftJoin(
KStream<K, V1> other,
ValueJoiner<? super V, ? super V1, ? extends R> joiner,
JoinWindows windows); @Override KStream<K, R> join(final KTable<K, V1> other, final ValueJoiner<? super V, ? super V1, ? extends R> joiner); @Override KStream<K, R> join(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final Serde<K> keySerde,
final Serde<V> valueSerde); @Override KStream<K, R> leftJoin(final GlobalKTable<K1, V1> globalTable,
final KeyValueMapper<? super K, ? super V, ? extends K1> keyMapper,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner); @Override KStream<K, V2> join(final GlobalKTable<K1, V1> globalTable,
final KeyValueMapper<? super K, ? super V, ? extends K1> keyMapper,
final ValueJoiner<? super V, ? super V1, ? extends V2> joiner); @Override KStream<K, R> leftJoin(final KTable<K, V1> other, final ValueJoiner<? super V, ? super V1, ? extends R> joiner); KStream<K, R> leftJoin(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final Serde<K> keySerde,
final Serde<V> valueSerde); @Override KGroupedStream<K1, V> groupBy(KeyValueMapper<? super K, ? super V, K1> selector); @Override KGroupedStream<K1, V> groupBy(KeyValueMapper<? super K, ? super V, K1> selector,
Serde<K1> keySerde,
Serde<V> valSerde); @Override KGroupedStream<K, V> groupByKey(); @Override KGroupedStream<K, V> groupByKey(Serde<K> keySerde,
Serde<V> valSerde); static final String FILTER_NAME; static final String PEEK_NAME; static final String JOINTHIS_NAME; static final String JOINOTHER_NAME; static final String JOIN_NAME; static final String LEFTJOIN_NAME; static final String MERGE_NAME; static final String OUTERTHIS_NAME; static final String OUTEROTHER_NAME; static final String SINK_NAME; static final String SOURCE_NAME; static final String REPARTITION_TOPIC_SUFFIX; }
|
@Test(expected = NullPointerException.class) public void shouldNotAllowNullFilePathOnWriteAsText() throws Exception { testStream.writeAsText(null); }
@Test(expected = TopologyBuilderException.class) public void shouldNotAllowEmptyFilePathOnWriteAsText() throws Exception { testStream.writeAsText("\t \t"); }
|
Cast implements Transformation<R> { @Override public void configure(Map<String, ?> props) { final SimpleConfig config = new SimpleConfig(CONFIG_DEF, props); casts = parseFieldTypes(config.getList(SPEC_CONFIG)); wholeValueCastType = casts.get(WHOLE_VALUE_CAST); schemaUpdateCache = new SynchronizedCache<>(new LRUCache<Schema, Schema>(16)); } @Override void configure(Map<String, ?> props); @Override R apply(R record); @Override ConfigDef config(); @Override void close(); static final String OVERVIEW_DOC; static final String SPEC_CONFIG; static final ConfigDef CONFIG_DEF; }
|
@Test(expected = ConfigException.class) public void testConfigEmpty() { final Cast<SourceRecord> xform = new Cast.Key<>(); xform.configure(Collections.singletonMap(Cast.SPEC_CONFIG, "")); }
@Test(expected = ConfigException.class) public void testConfigInvalidSchemaType() { final Cast<SourceRecord> xform = new Cast.Key<>(); xform.configure(Collections.singletonMap(Cast.SPEC_CONFIG, "foo:faketype")); }
@Test(expected = ConfigException.class) public void testConfigInvalidTargetType() { final Cast<SourceRecord> xform = new Cast.Key<>(); xform.configure(Collections.singletonMap(Cast.SPEC_CONFIG, "foo:array")); }
@Test(expected = ConfigException.class) public void testConfigInvalidMap() { final Cast<SourceRecord> xform = new Cast.Key<>(); xform.configure(Collections.singletonMap(Cast.SPEC_CONFIG, "foo:int8:extra")); }
@Test(expected = ConfigException.class) public void testConfigMixWholeAndFieldTransformation() { final Cast<SourceRecord> xform = new Cast.Key<>(); xform.configure(Collections.singletonMap(Cast.SPEC_CONFIG, "foo:int8,int32")); }
|
KStreamImpl extends AbstractStream<K> implements KStream<K, V> { @Override public <K1, V1> KStream<K1, V1> flatMap(KeyValueMapper<? super K, ? super V, ? extends Iterable<? extends KeyValue<? extends K1, ? extends V1>>> mapper) { Objects.requireNonNull(mapper, "mapper can't be null"); String name = topology.newName(FLATMAP_NAME); topology.addProcessor(name, new KStreamFlatMap<>(mapper), this.name); return new KStreamImpl<>(topology, name, sourceNodes, true); } KStreamImpl(KStreamBuilder topology, String name, Set<String> sourceNodes,
boolean repartitionRequired); @Override KStream<K, V> filter(Predicate<? super K, ? super V> predicate); @Override KStream<K, V> filterNot(final Predicate<? super K, ? super V> predicate); @Override KStream<K1, V> selectKey(final KeyValueMapper<? super K, ? super V, ? extends K1> mapper); @Override KStream<K1, V1> map(KeyValueMapper<? super K, ? super V, ? extends KeyValue<? extends K1, ? extends V1>> mapper); @Override KStream<K, V1> mapValues(ValueMapper<? super V, ? extends V1> mapper); @Override void print(); @Override void print(String streamName); @Override void print(Serde<K> keySerde, Serde<V> valSerde); @Override void print(Serde<K> keySerde, Serde<V> valSerde, String streamName); @Override void writeAsText(String filePath); @Override void writeAsText(String filePath, String streamName); @Override void writeAsText(String filePath, Serde<K> keySerde, Serde<V> valSerde); @Override void writeAsText(String filePath, String streamName, Serde<K> keySerde, Serde<V> valSerde); @Override KStream<K1, V1> flatMap(KeyValueMapper<? super K, ? super V, ? extends Iterable<? extends KeyValue<? extends K1, ? extends V1>>> mapper); @Override KStream<K, V1> flatMapValues(ValueMapper<? super V, ? extends Iterable<? extends V1>> mapper); @Override @SuppressWarnings("unchecked") KStream<K, V>[] branch(Predicate<? super K, ? super V>... predicates); static KStream<K, V> merge(KStreamBuilder topology, KStream<K, V>[] streams); @Override KStream<K, V> through(Serde<K> keySerde, Serde<V> valSerde, StreamPartitioner<? super K, ? super V> partitioner, String topic); @Override void foreach(ForeachAction<? super K, ? super V> action); @Override KStream<K, V> peek(final ForeachAction<? super K, ? super V> action); @Override KStream<K, V> through(Serde<K> keySerde, Serde<V> valSerde, String topic); @Override KStream<K, V> through(StreamPartitioner<? super K, ? super V> partitioner, String topic); @Override KStream<K, V> through(String topic); @Override void to(String topic); @Override void to(StreamPartitioner<? super K, ? super V> partitioner, String topic); @Override void to(Serde<K> keySerde, Serde<V> valSerde, String topic); @SuppressWarnings("unchecked") @Override void to(final Serde<K> keySerde, final Serde<V> valSerde, StreamPartitioner<? super K, ? super V> partitioner, final String topic); @Override KStream<K1, V1> transform(TransformerSupplier<? super K, ? super V, KeyValue<K1, V1>> transformerSupplier, String... stateStoreNames); @Override KStream<K, V1> transformValues(ValueTransformerSupplier<? super V, ? extends V1> valueTransformerSupplier, String... stateStoreNames); @Override void process(final ProcessorSupplier<? super K, ? super V> processorSupplier, String... stateStoreNames); @Override KStream<K, R> join(
final KStream<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final JoinWindows windows,
final Serde<K> keySerde,
final Serde<V> thisValueSerde,
final Serde<V1> otherValueSerde); @Override KStream<K, R> join(
final KStream<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final JoinWindows windows); @Override KStream<K, R> outerJoin(
final KStream<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final JoinWindows windows,
final Serde<K> keySerde,
final Serde<V> thisValueSerde,
final Serde<V1> otherValueSerde); @Override KStream<K, R> outerJoin(
final KStream<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final JoinWindows windows); @Override KStream<K, R> leftJoin(
final KStream<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final JoinWindows windows,
final Serde<K> keySerde,
final Serde<V> thisValSerde,
final Serde<V1> otherValueSerde); @Override KStream<K, R> leftJoin(
KStream<K, V1> other,
ValueJoiner<? super V, ? super V1, ? extends R> joiner,
JoinWindows windows); @Override KStream<K, R> join(final KTable<K, V1> other, final ValueJoiner<? super V, ? super V1, ? extends R> joiner); @Override KStream<K, R> join(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final Serde<K> keySerde,
final Serde<V> valueSerde); @Override KStream<K, R> leftJoin(final GlobalKTable<K1, V1> globalTable,
final KeyValueMapper<? super K, ? super V, ? extends K1> keyMapper,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner); @Override KStream<K, V2> join(final GlobalKTable<K1, V1> globalTable,
final KeyValueMapper<? super K, ? super V, ? extends K1> keyMapper,
final ValueJoiner<? super V, ? super V1, ? extends V2> joiner); @Override KStream<K, R> leftJoin(final KTable<K, V1> other, final ValueJoiner<? super V, ? super V1, ? extends R> joiner); KStream<K, R> leftJoin(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final Serde<K> keySerde,
final Serde<V> valueSerde); @Override KGroupedStream<K1, V> groupBy(KeyValueMapper<? super K, ? super V, K1> selector); @Override KGroupedStream<K1, V> groupBy(KeyValueMapper<? super K, ? super V, K1> selector,
Serde<K1> keySerde,
Serde<V> valSerde); @Override KGroupedStream<K, V> groupByKey(); @Override KGroupedStream<K, V> groupByKey(Serde<K> keySerde,
Serde<V> valSerde); static final String FILTER_NAME; static final String PEEK_NAME; static final String JOINTHIS_NAME; static final String JOINOTHER_NAME; static final String JOIN_NAME; static final String LEFTJOIN_NAME; static final String MERGE_NAME; static final String OUTERTHIS_NAME; static final String OUTEROTHER_NAME; static final String SINK_NAME; static final String SOURCE_NAME; static final String REPARTITION_TOPIC_SUFFIX; }
|
@Test(expected = NullPointerException.class) public void shouldNotAllowNullMapperOnFlatMap() throws Exception { testStream.flatMap(null); }
|
KStreamImpl extends AbstractStream<K> implements KStream<K, V> { @Override public <V1> KStream<K, V1> flatMapValues(ValueMapper<? super V, ? extends Iterable<? extends V1>> mapper) { Objects.requireNonNull(mapper, "mapper can't be null"); String name = topology.newName(FLATMAPVALUES_NAME); topology.addProcessor(name, new KStreamFlatMapValues<>(mapper), this.name); return new KStreamImpl<>(topology, name, sourceNodes, this.repartitionRequired); } KStreamImpl(KStreamBuilder topology, String name, Set<String> sourceNodes,
boolean repartitionRequired); @Override KStream<K, V> filter(Predicate<? super K, ? super V> predicate); @Override KStream<K, V> filterNot(final Predicate<? super K, ? super V> predicate); @Override KStream<K1, V> selectKey(final KeyValueMapper<? super K, ? super V, ? extends K1> mapper); @Override KStream<K1, V1> map(KeyValueMapper<? super K, ? super V, ? extends KeyValue<? extends K1, ? extends V1>> mapper); @Override KStream<K, V1> mapValues(ValueMapper<? super V, ? extends V1> mapper); @Override void print(); @Override void print(String streamName); @Override void print(Serde<K> keySerde, Serde<V> valSerde); @Override void print(Serde<K> keySerde, Serde<V> valSerde, String streamName); @Override void writeAsText(String filePath); @Override void writeAsText(String filePath, String streamName); @Override void writeAsText(String filePath, Serde<K> keySerde, Serde<V> valSerde); @Override void writeAsText(String filePath, String streamName, Serde<K> keySerde, Serde<V> valSerde); @Override KStream<K1, V1> flatMap(KeyValueMapper<? super K, ? super V, ? extends Iterable<? extends KeyValue<? extends K1, ? extends V1>>> mapper); @Override KStream<K, V1> flatMapValues(ValueMapper<? super V, ? extends Iterable<? extends V1>> mapper); @Override @SuppressWarnings("unchecked") KStream<K, V>[] branch(Predicate<? super K, ? super V>... predicates); static KStream<K, V> merge(KStreamBuilder topology, KStream<K, V>[] streams); @Override KStream<K, V> through(Serde<K> keySerde, Serde<V> valSerde, StreamPartitioner<? super K, ? super V> partitioner, String topic); @Override void foreach(ForeachAction<? super K, ? super V> action); @Override KStream<K, V> peek(final ForeachAction<? super K, ? super V> action); @Override KStream<K, V> through(Serde<K> keySerde, Serde<V> valSerde, String topic); @Override KStream<K, V> through(StreamPartitioner<? super K, ? super V> partitioner, String topic); @Override KStream<K, V> through(String topic); @Override void to(String topic); @Override void to(StreamPartitioner<? super K, ? super V> partitioner, String topic); @Override void to(Serde<K> keySerde, Serde<V> valSerde, String topic); @SuppressWarnings("unchecked") @Override void to(final Serde<K> keySerde, final Serde<V> valSerde, StreamPartitioner<? super K, ? super V> partitioner, final String topic); @Override KStream<K1, V1> transform(TransformerSupplier<? super K, ? super V, KeyValue<K1, V1>> transformerSupplier, String... stateStoreNames); @Override KStream<K, V1> transformValues(ValueTransformerSupplier<? super V, ? extends V1> valueTransformerSupplier, String... stateStoreNames); @Override void process(final ProcessorSupplier<? super K, ? super V> processorSupplier, String... stateStoreNames); @Override KStream<K, R> join(
final KStream<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final JoinWindows windows,
final Serde<K> keySerde,
final Serde<V> thisValueSerde,
final Serde<V1> otherValueSerde); @Override KStream<K, R> join(
final KStream<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final JoinWindows windows); @Override KStream<K, R> outerJoin(
final KStream<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final JoinWindows windows,
final Serde<K> keySerde,
final Serde<V> thisValueSerde,
final Serde<V1> otherValueSerde); @Override KStream<K, R> outerJoin(
final KStream<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final JoinWindows windows); @Override KStream<K, R> leftJoin(
final KStream<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final JoinWindows windows,
final Serde<K> keySerde,
final Serde<V> thisValSerde,
final Serde<V1> otherValueSerde); @Override KStream<K, R> leftJoin(
KStream<K, V1> other,
ValueJoiner<? super V, ? super V1, ? extends R> joiner,
JoinWindows windows); @Override KStream<K, R> join(final KTable<K, V1> other, final ValueJoiner<? super V, ? super V1, ? extends R> joiner); @Override KStream<K, R> join(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final Serde<K> keySerde,
final Serde<V> valueSerde); @Override KStream<K, R> leftJoin(final GlobalKTable<K1, V1> globalTable,
final KeyValueMapper<? super K, ? super V, ? extends K1> keyMapper,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner); @Override KStream<K, V2> join(final GlobalKTable<K1, V1> globalTable,
final KeyValueMapper<? super K, ? super V, ? extends K1> keyMapper,
final ValueJoiner<? super V, ? super V1, ? extends V2> joiner); @Override KStream<K, R> leftJoin(final KTable<K, V1> other, final ValueJoiner<? super V, ? super V1, ? extends R> joiner); KStream<K, R> leftJoin(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final Serde<K> keySerde,
final Serde<V> valueSerde); @Override KGroupedStream<K1, V> groupBy(KeyValueMapper<? super K, ? super V, K1> selector); @Override KGroupedStream<K1, V> groupBy(KeyValueMapper<? super K, ? super V, K1> selector,
Serde<K1> keySerde,
Serde<V> valSerde); @Override KGroupedStream<K, V> groupByKey(); @Override KGroupedStream<K, V> groupByKey(Serde<K> keySerde,
Serde<V> valSerde); static final String FILTER_NAME; static final String PEEK_NAME; static final String JOINTHIS_NAME; static final String JOINOTHER_NAME; static final String JOIN_NAME; static final String LEFTJOIN_NAME; static final String MERGE_NAME; static final String OUTERTHIS_NAME; static final String OUTEROTHER_NAME; static final String SINK_NAME; static final String SOURCE_NAME; static final String REPARTITION_TOPIC_SUFFIX; }
|
@Test(expected = NullPointerException.class) public void shouldNotAllowNullMapperOnFlatMapValues() throws Exception { testStream.flatMapValues(null); }
|
KStreamImpl extends AbstractStream<K> implements KStream<K, V> { @Override @SuppressWarnings("unchecked") public KStream<K, V>[] branch(Predicate<? super K, ? super V>... predicates) { if (predicates.length == 0) { throw new IllegalArgumentException("you must provide at least one predicate"); } for (Predicate<? super K, ? super V> predicate : predicates) { Objects.requireNonNull(predicate, "predicates can't have null values"); } String branchName = topology.newName(BRANCH_NAME); topology.addProcessor(branchName, new KStreamBranch(predicates.clone()), this.name); KStream<K, V>[] branchChildren = (KStream<K, V>[]) Array.newInstance(KStream.class, predicates.length); for (int i = 0; i < predicates.length; i++) { String childName = topology.newName(BRANCHCHILD_NAME); topology.addProcessor(childName, new KStreamPassThrough<K, V>(), branchName); branchChildren[i] = new KStreamImpl<>(topology, childName, sourceNodes, this.repartitionRequired); } return branchChildren; } KStreamImpl(KStreamBuilder topology, String name, Set<String> sourceNodes,
boolean repartitionRequired); @Override KStream<K, V> filter(Predicate<? super K, ? super V> predicate); @Override KStream<K, V> filterNot(final Predicate<? super K, ? super V> predicate); @Override KStream<K1, V> selectKey(final KeyValueMapper<? super K, ? super V, ? extends K1> mapper); @Override KStream<K1, V1> map(KeyValueMapper<? super K, ? super V, ? extends KeyValue<? extends K1, ? extends V1>> mapper); @Override KStream<K, V1> mapValues(ValueMapper<? super V, ? extends V1> mapper); @Override void print(); @Override void print(String streamName); @Override void print(Serde<K> keySerde, Serde<V> valSerde); @Override void print(Serde<K> keySerde, Serde<V> valSerde, String streamName); @Override void writeAsText(String filePath); @Override void writeAsText(String filePath, String streamName); @Override void writeAsText(String filePath, Serde<K> keySerde, Serde<V> valSerde); @Override void writeAsText(String filePath, String streamName, Serde<K> keySerde, Serde<V> valSerde); @Override KStream<K1, V1> flatMap(KeyValueMapper<? super K, ? super V, ? extends Iterable<? extends KeyValue<? extends K1, ? extends V1>>> mapper); @Override KStream<K, V1> flatMapValues(ValueMapper<? super V, ? extends Iterable<? extends V1>> mapper); @Override @SuppressWarnings("unchecked") KStream<K, V>[] branch(Predicate<? super K, ? super V>... predicates); static KStream<K, V> merge(KStreamBuilder topology, KStream<K, V>[] streams); @Override KStream<K, V> through(Serde<K> keySerde, Serde<V> valSerde, StreamPartitioner<? super K, ? super V> partitioner, String topic); @Override void foreach(ForeachAction<? super K, ? super V> action); @Override KStream<K, V> peek(final ForeachAction<? super K, ? super V> action); @Override KStream<K, V> through(Serde<K> keySerde, Serde<V> valSerde, String topic); @Override KStream<K, V> through(StreamPartitioner<? super K, ? super V> partitioner, String topic); @Override KStream<K, V> through(String topic); @Override void to(String topic); @Override void to(StreamPartitioner<? super K, ? super V> partitioner, String topic); @Override void to(Serde<K> keySerde, Serde<V> valSerde, String topic); @SuppressWarnings("unchecked") @Override void to(final Serde<K> keySerde, final Serde<V> valSerde, StreamPartitioner<? super K, ? super V> partitioner, final String topic); @Override KStream<K1, V1> transform(TransformerSupplier<? super K, ? super V, KeyValue<K1, V1>> transformerSupplier, String... stateStoreNames); @Override KStream<K, V1> transformValues(ValueTransformerSupplier<? super V, ? extends V1> valueTransformerSupplier, String... stateStoreNames); @Override void process(final ProcessorSupplier<? super K, ? super V> processorSupplier, String... stateStoreNames); @Override KStream<K, R> join(
final KStream<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final JoinWindows windows,
final Serde<K> keySerde,
final Serde<V> thisValueSerde,
final Serde<V1> otherValueSerde); @Override KStream<K, R> join(
final KStream<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final JoinWindows windows); @Override KStream<K, R> outerJoin(
final KStream<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final JoinWindows windows,
final Serde<K> keySerde,
final Serde<V> thisValueSerde,
final Serde<V1> otherValueSerde); @Override KStream<K, R> outerJoin(
final KStream<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final JoinWindows windows); @Override KStream<K, R> leftJoin(
final KStream<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final JoinWindows windows,
final Serde<K> keySerde,
final Serde<V> thisValSerde,
final Serde<V1> otherValueSerde); @Override KStream<K, R> leftJoin(
KStream<K, V1> other,
ValueJoiner<? super V, ? super V1, ? extends R> joiner,
JoinWindows windows); @Override KStream<K, R> join(final KTable<K, V1> other, final ValueJoiner<? super V, ? super V1, ? extends R> joiner); @Override KStream<K, R> join(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final Serde<K> keySerde,
final Serde<V> valueSerde); @Override KStream<K, R> leftJoin(final GlobalKTable<K1, V1> globalTable,
final KeyValueMapper<? super K, ? super V, ? extends K1> keyMapper,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner); @Override KStream<K, V2> join(final GlobalKTable<K1, V1> globalTable,
final KeyValueMapper<? super K, ? super V, ? extends K1> keyMapper,
final ValueJoiner<? super V, ? super V1, ? extends V2> joiner); @Override KStream<K, R> leftJoin(final KTable<K, V1> other, final ValueJoiner<? super V, ? super V1, ? extends R> joiner); KStream<K, R> leftJoin(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final Serde<K> keySerde,
final Serde<V> valueSerde); @Override KGroupedStream<K1, V> groupBy(KeyValueMapper<? super K, ? super V, K1> selector); @Override KGroupedStream<K1, V> groupBy(KeyValueMapper<? super K, ? super V, K1> selector,
Serde<K1> keySerde,
Serde<V> valSerde); @Override KGroupedStream<K, V> groupByKey(); @Override KGroupedStream<K, V> groupByKey(Serde<K> keySerde,
Serde<V> valSerde); static final String FILTER_NAME; static final String PEEK_NAME; static final String JOINTHIS_NAME; static final String JOINOTHER_NAME; static final String JOIN_NAME; static final String LEFTJOIN_NAME; static final String MERGE_NAME; static final String OUTERTHIS_NAME; static final String OUTEROTHER_NAME; static final String SINK_NAME; static final String SOURCE_NAME; static final String REPARTITION_TOPIC_SUFFIX; }
|
@Test(expected = IllegalArgumentException.class) public void shouldHaveAtLeastOnPredicateWhenBranching() throws Exception { testStream.branch(); }
@Test(expected = NullPointerException.class) public void shouldCantHaveNullPredicate() throws Exception { testStream.branch((Predicate) null); }
|
KStreamImpl extends AbstractStream<K> implements KStream<K, V> { @Override public KStream<K, V> through(Serde<K> keySerde, Serde<V> valSerde, StreamPartitioner<? super K, ? super V> partitioner, String topic) { to(keySerde, valSerde, partitioner, topic); return topology.stream(keySerde, valSerde, topic); } KStreamImpl(KStreamBuilder topology, String name, Set<String> sourceNodes,
boolean repartitionRequired); @Override KStream<K, V> filter(Predicate<? super K, ? super V> predicate); @Override KStream<K, V> filterNot(final Predicate<? super K, ? super V> predicate); @Override KStream<K1, V> selectKey(final KeyValueMapper<? super K, ? super V, ? extends K1> mapper); @Override KStream<K1, V1> map(KeyValueMapper<? super K, ? super V, ? extends KeyValue<? extends K1, ? extends V1>> mapper); @Override KStream<K, V1> mapValues(ValueMapper<? super V, ? extends V1> mapper); @Override void print(); @Override void print(String streamName); @Override void print(Serde<K> keySerde, Serde<V> valSerde); @Override void print(Serde<K> keySerde, Serde<V> valSerde, String streamName); @Override void writeAsText(String filePath); @Override void writeAsText(String filePath, String streamName); @Override void writeAsText(String filePath, Serde<K> keySerde, Serde<V> valSerde); @Override void writeAsText(String filePath, String streamName, Serde<K> keySerde, Serde<V> valSerde); @Override KStream<K1, V1> flatMap(KeyValueMapper<? super K, ? super V, ? extends Iterable<? extends KeyValue<? extends K1, ? extends V1>>> mapper); @Override KStream<K, V1> flatMapValues(ValueMapper<? super V, ? extends Iterable<? extends V1>> mapper); @Override @SuppressWarnings("unchecked") KStream<K, V>[] branch(Predicate<? super K, ? super V>... predicates); static KStream<K, V> merge(KStreamBuilder topology, KStream<K, V>[] streams); @Override KStream<K, V> through(Serde<K> keySerde, Serde<V> valSerde, StreamPartitioner<? super K, ? super V> partitioner, String topic); @Override void foreach(ForeachAction<? super K, ? super V> action); @Override KStream<K, V> peek(final ForeachAction<? super K, ? super V> action); @Override KStream<K, V> through(Serde<K> keySerde, Serde<V> valSerde, String topic); @Override KStream<K, V> through(StreamPartitioner<? super K, ? super V> partitioner, String topic); @Override KStream<K, V> through(String topic); @Override void to(String topic); @Override void to(StreamPartitioner<? super K, ? super V> partitioner, String topic); @Override void to(Serde<K> keySerde, Serde<V> valSerde, String topic); @SuppressWarnings("unchecked") @Override void to(final Serde<K> keySerde, final Serde<V> valSerde, StreamPartitioner<? super K, ? super V> partitioner, final String topic); @Override KStream<K1, V1> transform(TransformerSupplier<? super K, ? super V, KeyValue<K1, V1>> transformerSupplier, String... stateStoreNames); @Override KStream<K, V1> transformValues(ValueTransformerSupplier<? super V, ? extends V1> valueTransformerSupplier, String... stateStoreNames); @Override void process(final ProcessorSupplier<? super K, ? super V> processorSupplier, String... stateStoreNames); @Override KStream<K, R> join(
final KStream<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final JoinWindows windows,
final Serde<K> keySerde,
final Serde<V> thisValueSerde,
final Serde<V1> otherValueSerde); @Override KStream<K, R> join(
final KStream<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final JoinWindows windows); @Override KStream<K, R> outerJoin(
final KStream<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final JoinWindows windows,
final Serde<K> keySerde,
final Serde<V> thisValueSerde,
final Serde<V1> otherValueSerde); @Override KStream<K, R> outerJoin(
final KStream<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final JoinWindows windows); @Override KStream<K, R> leftJoin(
final KStream<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final JoinWindows windows,
final Serde<K> keySerde,
final Serde<V> thisValSerde,
final Serde<V1> otherValueSerde); @Override KStream<K, R> leftJoin(
KStream<K, V1> other,
ValueJoiner<? super V, ? super V1, ? extends R> joiner,
JoinWindows windows); @Override KStream<K, R> join(final KTable<K, V1> other, final ValueJoiner<? super V, ? super V1, ? extends R> joiner); @Override KStream<K, R> join(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final Serde<K> keySerde,
final Serde<V> valueSerde); @Override KStream<K, R> leftJoin(final GlobalKTable<K1, V1> globalTable,
final KeyValueMapper<? super K, ? super V, ? extends K1> keyMapper,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner); @Override KStream<K, V2> join(final GlobalKTable<K1, V1> globalTable,
final KeyValueMapper<? super K, ? super V, ? extends K1> keyMapper,
final ValueJoiner<? super V, ? super V1, ? extends V2> joiner); @Override KStream<K, R> leftJoin(final KTable<K, V1> other, final ValueJoiner<? super V, ? super V1, ? extends R> joiner); KStream<K, R> leftJoin(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final Serde<K> keySerde,
final Serde<V> valueSerde); @Override KGroupedStream<K1, V> groupBy(KeyValueMapper<? super K, ? super V, K1> selector); @Override KGroupedStream<K1, V> groupBy(KeyValueMapper<? super K, ? super V, K1> selector,
Serde<K1> keySerde,
Serde<V> valSerde); @Override KGroupedStream<K, V> groupByKey(); @Override KGroupedStream<K, V> groupByKey(Serde<K> keySerde,
Serde<V> valSerde); static final String FILTER_NAME; static final String PEEK_NAME; static final String JOINTHIS_NAME; static final String JOINOTHER_NAME; static final String JOIN_NAME; static final String LEFTJOIN_NAME; static final String MERGE_NAME; static final String OUTERTHIS_NAME; static final String OUTEROTHER_NAME; static final String SINK_NAME; static final String SOURCE_NAME; static final String REPARTITION_TOPIC_SUFFIX; }
|
@Test(expected = NullPointerException.class) public void shouldNotAllowNullTopicOnThrough() throws Exception { testStream.through(null); }
|
KStreamImpl extends AbstractStream<K> implements KStream<K, V> { @Override public <K1, V1> KStream<K1, V1> transform(TransformerSupplier<? super K, ? super V, KeyValue<K1, V1>> transformerSupplier, String... stateStoreNames) { Objects.requireNonNull(transformerSupplier, "transformerSupplier can't be null"); String name = topology.newName(TRANSFORM_NAME); topology.addProcessor(name, new KStreamTransform<>(transformerSupplier), this.name); topology.connectProcessorAndStateStores(name, stateStoreNames); return new KStreamImpl<>(topology, name, sourceNodes, true); } KStreamImpl(KStreamBuilder topology, String name, Set<String> sourceNodes,
boolean repartitionRequired); @Override KStream<K, V> filter(Predicate<? super K, ? super V> predicate); @Override KStream<K, V> filterNot(final Predicate<? super K, ? super V> predicate); @Override KStream<K1, V> selectKey(final KeyValueMapper<? super K, ? super V, ? extends K1> mapper); @Override KStream<K1, V1> map(KeyValueMapper<? super K, ? super V, ? extends KeyValue<? extends K1, ? extends V1>> mapper); @Override KStream<K, V1> mapValues(ValueMapper<? super V, ? extends V1> mapper); @Override void print(); @Override void print(String streamName); @Override void print(Serde<K> keySerde, Serde<V> valSerde); @Override void print(Serde<K> keySerde, Serde<V> valSerde, String streamName); @Override void writeAsText(String filePath); @Override void writeAsText(String filePath, String streamName); @Override void writeAsText(String filePath, Serde<K> keySerde, Serde<V> valSerde); @Override void writeAsText(String filePath, String streamName, Serde<K> keySerde, Serde<V> valSerde); @Override KStream<K1, V1> flatMap(KeyValueMapper<? super K, ? super V, ? extends Iterable<? extends KeyValue<? extends K1, ? extends V1>>> mapper); @Override KStream<K, V1> flatMapValues(ValueMapper<? super V, ? extends Iterable<? extends V1>> mapper); @Override @SuppressWarnings("unchecked") KStream<K, V>[] branch(Predicate<? super K, ? super V>... predicates); static KStream<K, V> merge(KStreamBuilder topology, KStream<K, V>[] streams); @Override KStream<K, V> through(Serde<K> keySerde, Serde<V> valSerde, StreamPartitioner<? super K, ? super V> partitioner, String topic); @Override void foreach(ForeachAction<? super K, ? super V> action); @Override KStream<K, V> peek(final ForeachAction<? super K, ? super V> action); @Override KStream<K, V> through(Serde<K> keySerde, Serde<V> valSerde, String topic); @Override KStream<K, V> through(StreamPartitioner<? super K, ? super V> partitioner, String topic); @Override KStream<K, V> through(String topic); @Override void to(String topic); @Override void to(StreamPartitioner<? super K, ? super V> partitioner, String topic); @Override void to(Serde<K> keySerde, Serde<V> valSerde, String topic); @SuppressWarnings("unchecked") @Override void to(final Serde<K> keySerde, final Serde<V> valSerde, StreamPartitioner<? super K, ? super V> partitioner, final String topic); @Override KStream<K1, V1> transform(TransformerSupplier<? super K, ? super V, KeyValue<K1, V1>> transformerSupplier, String... stateStoreNames); @Override KStream<K, V1> transformValues(ValueTransformerSupplier<? super V, ? extends V1> valueTransformerSupplier, String... stateStoreNames); @Override void process(final ProcessorSupplier<? super K, ? super V> processorSupplier, String... stateStoreNames); @Override KStream<K, R> join(
final KStream<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final JoinWindows windows,
final Serde<K> keySerde,
final Serde<V> thisValueSerde,
final Serde<V1> otherValueSerde); @Override KStream<K, R> join(
final KStream<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final JoinWindows windows); @Override KStream<K, R> outerJoin(
final KStream<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final JoinWindows windows,
final Serde<K> keySerde,
final Serde<V> thisValueSerde,
final Serde<V1> otherValueSerde); @Override KStream<K, R> outerJoin(
final KStream<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final JoinWindows windows); @Override KStream<K, R> leftJoin(
final KStream<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final JoinWindows windows,
final Serde<K> keySerde,
final Serde<V> thisValSerde,
final Serde<V1> otherValueSerde); @Override KStream<K, R> leftJoin(
KStream<K, V1> other,
ValueJoiner<? super V, ? super V1, ? extends R> joiner,
JoinWindows windows); @Override KStream<K, R> join(final KTable<K, V1> other, final ValueJoiner<? super V, ? super V1, ? extends R> joiner); @Override KStream<K, R> join(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final Serde<K> keySerde,
final Serde<V> valueSerde); @Override KStream<K, R> leftJoin(final GlobalKTable<K1, V1> globalTable,
final KeyValueMapper<? super K, ? super V, ? extends K1> keyMapper,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner); @Override KStream<K, V2> join(final GlobalKTable<K1, V1> globalTable,
final KeyValueMapper<? super K, ? super V, ? extends K1> keyMapper,
final ValueJoiner<? super V, ? super V1, ? extends V2> joiner); @Override KStream<K, R> leftJoin(final KTable<K, V1> other, final ValueJoiner<? super V, ? super V1, ? extends R> joiner); KStream<K, R> leftJoin(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final Serde<K> keySerde,
final Serde<V> valueSerde); @Override KGroupedStream<K1, V> groupBy(KeyValueMapper<? super K, ? super V, K1> selector); @Override KGroupedStream<K1, V> groupBy(KeyValueMapper<? super K, ? super V, K1> selector,
Serde<K1> keySerde,
Serde<V> valSerde); @Override KGroupedStream<K, V> groupByKey(); @Override KGroupedStream<K, V> groupByKey(Serde<K> keySerde,
Serde<V> valSerde); static final String FILTER_NAME; static final String PEEK_NAME; static final String JOINTHIS_NAME; static final String JOINOTHER_NAME; static final String JOIN_NAME; static final String LEFTJOIN_NAME; static final String MERGE_NAME; static final String OUTERTHIS_NAME; static final String OUTEROTHER_NAME; static final String SINK_NAME; static final String SOURCE_NAME; static final String REPARTITION_TOPIC_SUFFIX; }
|
@Test(expected = NullPointerException.class) public void shouldNotAllowNullTransformSupplierOnTransform() throws Exception { testStream.transform(null); }
|
KStreamImpl extends AbstractStream<K> implements KStream<K, V> { @Override public <V1> KStream<K, V1> transformValues(ValueTransformerSupplier<? super V, ? extends V1> valueTransformerSupplier, String... stateStoreNames) { Objects.requireNonNull(valueTransformerSupplier, "valueTransformSupplier can't be null"); String name = topology.newName(TRANSFORMVALUES_NAME); topology.addProcessor(name, new KStreamTransformValues<>(valueTransformerSupplier), this.name); topology.connectProcessorAndStateStores(name, stateStoreNames); return new KStreamImpl<>(topology, name, sourceNodes, this.repartitionRequired); } KStreamImpl(KStreamBuilder topology, String name, Set<String> sourceNodes,
boolean repartitionRequired); @Override KStream<K, V> filter(Predicate<? super K, ? super V> predicate); @Override KStream<K, V> filterNot(final Predicate<? super K, ? super V> predicate); @Override KStream<K1, V> selectKey(final KeyValueMapper<? super K, ? super V, ? extends K1> mapper); @Override KStream<K1, V1> map(KeyValueMapper<? super K, ? super V, ? extends KeyValue<? extends K1, ? extends V1>> mapper); @Override KStream<K, V1> mapValues(ValueMapper<? super V, ? extends V1> mapper); @Override void print(); @Override void print(String streamName); @Override void print(Serde<K> keySerde, Serde<V> valSerde); @Override void print(Serde<K> keySerde, Serde<V> valSerde, String streamName); @Override void writeAsText(String filePath); @Override void writeAsText(String filePath, String streamName); @Override void writeAsText(String filePath, Serde<K> keySerde, Serde<V> valSerde); @Override void writeAsText(String filePath, String streamName, Serde<K> keySerde, Serde<V> valSerde); @Override KStream<K1, V1> flatMap(KeyValueMapper<? super K, ? super V, ? extends Iterable<? extends KeyValue<? extends K1, ? extends V1>>> mapper); @Override KStream<K, V1> flatMapValues(ValueMapper<? super V, ? extends Iterable<? extends V1>> mapper); @Override @SuppressWarnings("unchecked") KStream<K, V>[] branch(Predicate<? super K, ? super V>... predicates); static KStream<K, V> merge(KStreamBuilder topology, KStream<K, V>[] streams); @Override KStream<K, V> through(Serde<K> keySerde, Serde<V> valSerde, StreamPartitioner<? super K, ? super V> partitioner, String topic); @Override void foreach(ForeachAction<? super K, ? super V> action); @Override KStream<K, V> peek(final ForeachAction<? super K, ? super V> action); @Override KStream<K, V> through(Serde<K> keySerde, Serde<V> valSerde, String topic); @Override KStream<K, V> through(StreamPartitioner<? super K, ? super V> partitioner, String topic); @Override KStream<K, V> through(String topic); @Override void to(String topic); @Override void to(StreamPartitioner<? super K, ? super V> partitioner, String topic); @Override void to(Serde<K> keySerde, Serde<V> valSerde, String topic); @SuppressWarnings("unchecked") @Override void to(final Serde<K> keySerde, final Serde<V> valSerde, StreamPartitioner<? super K, ? super V> partitioner, final String topic); @Override KStream<K1, V1> transform(TransformerSupplier<? super K, ? super V, KeyValue<K1, V1>> transformerSupplier, String... stateStoreNames); @Override KStream<K, V1> transformValues(ValueTransformerSupplier<? super V, ? extends V1> valueTransformerSupplier, String... stateStoreNames); @Override void process(final ProcessorSupplier<? super K, ? super V> processorSupplier, String... stateStoreNames); @Override KStream<K, R> join(
final KStream<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final JoinWindows windows,
final Serde<K> keySerde,
final Serde<V> thisValueSerde,
final Serde<V1> otherValueSerde); @Override KStream<K, R> join(
final KStream<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final JoinWindows windows); @Override KStream<K, R> outerJoin(
final KStream<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final JoinWindows windows,
final Serde<K> keySerde,
final Serde<V> thisValueSerde,
final Serde<V1> otherValueSerde); @Override KStream<K, R> outerJoin(
final KStream<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final JoinWindows windows); @Override KStream<K, R> leftJoin(
final KStream<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final JoinWindows windows,
final Serde<K> keySerde,
final Serde<V> thisValSerde,
final Serde<V1> otherValueSerde); @Override KStream<K, R> leftJoin(
KStream<K, V1> other,
ValueJoiner<? super V, ? super V1, ? extends R> joiner,
JoinWindows windows); @Override KStream<K, R> join(final KTable<K, V1> other, final ValueJoiner<? super V, ? super V1, ? extends R> joiner); @Override KStream<K, R> join(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final Serde<K> keySerde,
final Serde<V> valueSerde); @Override KStream<K, R> leftJoin(final GlobalKTable<K1, V1> globalTable,
final KeyValueMapper<? super K, ? super V, ? extends K1> keyMapper,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner); @Override KStream<K, V2> join(final GlobalKTable<K1, V1> globalTable,
final KeyValueMapper<? super K, ? super V, ? extends K1> keyMapper,
final ValueJoiner<? super V, ? super V1, ? extends V2> joiner); @Override KStream<K, R> leftJoin(final KTable<K, V1> other, final ValueJoiner<? super V, ? super V1, ? extends R> joiner); KStream<K, R> leftJoin(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final Serde<K> keySerde,
final Serde<V> valueSerde); @Override KGroupedStream<K1, V> groupBy(KeyValueMapper<? super K, ? super V, K1> selector); @Override KGroupedStream<K1, V> groupBy(KeyValueMapper<? super K, ? super V, K1> selector,
Serde<K1> keySerde,
Serde<V> valSerde); @Override KGroupedStream<K, V> groupByKey(); @Override KGroupedStream<K, V> groupByKey(Serde<K> keySerde,
Serde<V> valSerde); static final String FILTER_NAME; static final String PEEK_NAME; static final String JOINTHIS_NAME; static final String JOINOTHER_NAME; static final String JOIN_NAME; static final String LEFTJOIN_NAME; static final String MERGE_NAME; static final String OUTERTHIS_NAME; static final String OUTEROTHER_NAME; static final String SINK_NAME; static final String SOURCE_NAME; static final String REPARTITION_TOPIC_SUFFIX; }
|
@Test(expected = NullPointerException.class) public void shouldNotAllowNullTransformSupplierOnTransformValues() throws Exception { testStream.transformValues(null); }
|
KStreamImpl extends AbstractStream<K> implements KStream<K, V> { @Override public void process(final ProcessorSupplier<? super K, ? super V> processorSupplier, String... stateStoreNames) { String name = topology.newName(PROCESSOR_NAME); topology.addProcessor(name, processorSupplier, this.name); topology.connectProcessorAndStateStores(name, stateStoreNames); } KStreamImpl(KStreamBuilder topology, String name, Set<String> sourceNodes,
boolean repartitionRequired); @Override KStream<K, V> filter(Predicate<? super K, ? super V> predicate); @Override KStream<K, V> filterNot(final Predicate<? super K, ? super V> predicate); @Override KStream<K1, V> selectKey(final KeyValueMapper<? super K, ? super V, ? extends K1> mapper); @Override KStream<K1, V1> map(KeyValueMapper<? super K, ? super V, ? extends KeyValue<? extends K1, ? extends V1>> mapper); @Override KStream<K, V1> mapValues(ValueMapper<? super V, ? extends V1> mapper); @Override void print(); @Override void print(String streamName); @Override void print(Serde<K> keySerde, Serde<V> valSerde); @Override void print(Serde<K> keySerde, Serde<V> valSerde, String streamName); @Override void writeAsText(String filePath); @Override void writeAsText(String filePath, String streamName); @Override void writeAsText(String filePath, Serde<K> keySerde, Serde<V> valSerde); @Override void writeAsText(String filePath, String streamName, Serde<K> keySerde, Serde<V> valSerde); @Override KStream<K1, V1> flatMap(KeyValueMapper<? super K, ? super V, ? extends Iterable<? extends KeyValue<? extends K1, ? extends V1>>> mapper); @Override KStream<K, V1> flatMapValues(ValueMapper<? super V, ? extends Iterable<? extends V1>> mapper); @Override @SuppressWarnings("unchecked") KStream<K, V>[] branch(Predicate<? super K, ? super V>... predicates); static KStream<K, V> merge(KStreamBuilder topology, KStream<K, V>[] streams); @Override KStream<K, V> through(Serde<K> keySerde, Serde<V> valSerde, StreamPartitioner<? super K, ? super V> partitioner, String topic); @Override void foreach(ForeachAction<? super K, ? super V> action); @Override KStream<K, V> peek(final ForeachAction<? super K, ? super V> action); @Override KStream<K, V> through(Serde<K> keySerde, Serde<V> valSerde, String topic); @Override KStream<K, V> through(StreamPartitioner<? super K, ? super V> partitioner, String topic); @Override KStream<K, V> through(String topic); @Override void to(String topic); @Override void to(StreamPartitioner<? super K, ? super V> partitioner, String topic); @Override void to(Serde<K> keySerde, Serde<V> valSerde, String topic); @SuppressWarnings("unchecked") @Override void to(final Serde<K> keySerde, final Serde<V> valSerde, StreamPartitioner<? super K, ? super V> partitioner, final String topic); @Override KStream<K1, V1> transform(TransformerSupplier<? super K, ? super V, KeyValue<K1, V1>> transformerSupplier, String... stateStoreNames); @Override KStream<K, V1> transformValues(ValueTransformerSupplier<? super V, ? extends V1> valueTransformerSupplier, String... stateStoreNames); @Override void process(final ProcessorSupplier<? super K, ? super V> processorSupplier, String... stateStoreNames); @Override KStream<K, R> join(
final KStream<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final JoinWindows windows,
final Serde<K> keySerde,
final Serde<V> thisValueSerde,
final Serde<V1> otherValueSerde); @Override KStream<K, R> join(
final KStream<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final JoinWindows windows); @Override KStream<K, R> outerJoin(
final KStream<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final JoinWindows windows,
final Serde<K> keySerde,
final Serde<V> thisValueSerde,
final Serde<V1> otherValueSerde); @Override KStream<K, R> outerJoin(
final KStream<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final JoinWindows windows); @Override KStream<K, R> leftJoin(
final KStream<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final JoinWindows windows,
final Serde<K> keySerde,
final Serde<V> thisValSerde,
final Serde<V1> otherValueSerde); @Override KStream<K, R> leftJoin(
KStream<K, V1> other,
ValueJoiner<? super V, ? super V1, ? extends R> joiner,
JoinWindows windows); @Override KStream<K, R> join(final KTable<K, V1> other, final ValueJoiner<? super V, ? super V1, ? extends R> joiner); @Override KStream<K, R> join(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final Serde<K> keySerde,
final Serde<V> valueSerde); @Override KStream<K, R> leftJoin(final GlobalKTable<K1, V1> globalTable,
final KeyValueMapper<? super K, ? super V, ? extends K1> keyMapper,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner); @Override KStream<K, V2> join(final GlobalKTable<K1, V1> globalTable,
final KeyValueMapper<? super K, ? super V, ? extends K1> keyMapper,
final ValueJoiner<? super V, ? super V1, ? extends V2> joiner); @Override KStream<K, R> leftJoin(final KTable<K, V1> other, final ValueJoiner<? super V, ? super V1, ? extends R> joiner); KStream<K, R> leftJoin(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final Serde<K> keySerde,
final Serde<V> valueSerde); @Override KGroupedStream<K1, V> groupBy(KeyValueMapper<? super K, ? super V, K1> selector); @Override KGroupedStream<K1, V> groupBy(KeyValueMapper<? super K, ? super V, K1> selector,
Serde<K1> keySerde,
Serde<V> valSerde); @Override KGroupedStream<K, V> groupByKey(); @Override KGroupedStream<K, V> groupByKey(Serde<K> keySerde,
Serde<V> valSerde); static final String FILTER_NAME; static final String PEEK_NAME; static final String JOINTHIS_NAME; static final String JOINOTHER_NAME; static final String JOIN_NAME; static final String LEFTJOIN_NAME; static final String MERGE_NAME; static final String OUTERTHIS_NAME; static final String OUTEROTHER_NAME; static final String SINK_NAME; static final String SOURCE_NAME; static final String REPARTITION_TOPIC_SUFFIX; }
|
@Test(expected = NullPointerException.class) public void shouldNotAllowNullProcessSupplier() throws Exception { testStream.process(null); }
|
KStreamImpl extends AbstractStream<K> implements KStream<K, V> { @Override public <V1, R> KStream<K, R> join( final KStream<K, V1> other, final ValueJoiner<? super V, ? super V1, ? extends R> joiner, final JoinWindows windows, final Serde<K> keySerde, final Serde<V> thisValueSerde, final Serde<V1> otherValueSerde) { return doJoin(other, joiner, windows, keySerde, thisValueSerde, otherValueSerde, new KStreamImplJoin(false, false)); } KStreamImpl(KStreamBuilder topology, String name, Set<String> sourceNodes,
boolean repartitionRequired); @Override KStream<K, V> filter(Predicate<? super K, ? super V> predicate); @Override KStream<K, V> filterNot(final Predicate<? super K, ? super V> predicate); @Override KStream<K1, V> selectKey(final KeyValueMapper<? super K, ? super V, ? extends K1> mapper); @Override KStream<K1, V1> map(KeyValueMapper<? super K, ? super V, ? extends KeyValue<? extends K1, ? extends V1>> mapper); @Override KStream<K, V1> mapValues(ValueMapper<? super V, ? extends V1> mapper); @Override void print(); @Override void print(String streamName); @Override void print(Serde<K> keySerde, Serde<V> valSerde); @Override void print(Serde<K> keySerde, Serde<V> valSerde, String streamName); @Override void writeAsText(String filePath); @Override void writeAsText(String filePath, String streamName); @Override void writeAsText(String filePath, Serde<K> keySerde, Serde<V> valSerde); @Override void writeAsText(String filePath, String streamName, Serde<K> keySerde, Serde<V> valSerde); @Override KStream<K1, V1> flatMap(KeyValueMapper<? super K, ? super V, ? extends Iterable<? extends KeyValue<? extends K1, ? extends V1>>> mapper); @Override KStream<K, V1> flatMapValues(ValueMapper<? super V, ? extends Iterable<? extends V1>> mapper); @Override @SuppressWarnings("unchecked") KStream<K, V>[] branch(Predicate<? super K, ? super V>... predicates); static KStream<K, V> merge(KStreamBuilder topology, KStream<K, V>[] streams); @Override KStream<K, V> through(Serde<K> keySerde, Serde<V> valSerde, StreamPartitioner<? super K, ? super V> partitioner, String topic); @Override void foreach(ForeachAction<? super K, ? super V> action); @Override KStream<K, V> peek(final ForeachAction<? super K, ? super V> action); @Override KStream<K, V> through(Serde<K> keySerde, Serde<V> valSerde, String topic); @Override KStream<K, V> through(StreamPartitioner<? super K, ? super V> partitioner, String topic); @Override KStream<K, V> through(String topic); @Override void to(String topic); @Override void to(StreamPartitioner<? super K, ? super V> partitioner, String topic); @Override void to(Serde<K> keySerde, Serde<V> valSerde, String topic); @SuppressWarnings("unchecked") @Override void to(final Serde<K> keySerde, final Serde<V> valSerde, StreamPartitioner<? super K, ? super V> partitioner, final String topic); @Override KStream<K1, V1> transform(TransformerSupplier<? super K, ? super V, KeyValue<K1, V1>> transformerSupplier, String... stateStoreNames); @Override KStream<K, V1> transformValues(ValueTransformerSupplier<? super V, ? extends V1> valueTransformerSupplier, String... stateStoreNames); @Override void process(final ProcessorSupplier<? super K, ? super V> processorSupplier, String... stateStoreNames); @Override KStream<K, R> join(
final KStream<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final JoinWindows windows,
final Serde<K> keySerde,
final Serde<V> thisValueSerde,
final Serde<V1> otherValueSerde); @Override KStream<K, R> join(
final KStream<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final JoinWindows windows); @Override KStream<K, R> outerJoin(
final KStream<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final JoinWindows windows,
final Serde<K> keySerde,
final Serde<V> thisValueSerde,
final Serde<V1> otherValueSerde); @Override KStream<K, R> outerJoin(
final KStream<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final JoinWindows windows); @Override KStream<K, R> leftJoin(
final KStream<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final JoinWindows windows,
final Serde<K> keySerde,
final Serde<V> thisValSerde,
final Serde<V1> otherValueSerde); @Override KStream<K, R> leftJoin(
KStream<K, V1> other,
ValueJoiner<? super V, ? super V1, ? extends R> joiner,
JoinWindows windows); @Override KStream<K, R> join(final KTable<K, V1> other, final ValueJoiner<? super V, ? super V1, ? extends R> joiner); @Override KStream<K, R> join(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final Serde<K> keySerde,
final Serde<V> valueSerde); @Override KStream<K, R> leftJoin(final GlobalKTable<K1, V1> globalTable,
final KeyValueMapper<? super K, ? super V, ? extends K1> keyMapper,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner); @Override KStream<K, V2> join(final GlobalKTable<K1, V1> globalTable,
final KeyValueMapper<? super K, ? super V, ? extends K1> keyMapper,
final ValueJoiner<? super V, ? super V1, ? extends V2> joiner); @Override KStream<K, R> leftJoin(final KTable<K, V1> other, final ValueJoiner<? super V, ? super V1, ? extends R> joiner); KStream<K, R> leftJoin(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final Serde<K> keySerde,
final Serde<V> valueSerde); @Override KGroupedStream<K1, V> groupBy(KeyValueMapper<? super K, ? super V, K1> selector); @Override KGroupedStream<K1, V> groupBy(KeyValueMapper<? super K, ? super V, K1> selector,
Serde<K1> keySerde,
Serde<V> valSerde); @Override KGroupedStream<K, V> groupByKey(); @Override KGroupedStream<K, V> groupByKey(Serde<K> keySerde,
Serde<V> valSerde); static final String FILTER_NAME; static final String PEEK_NAME; static final String JOINTHIS_NAME; static final String JOINOTHER_NAME; static final String JOIN_NAME; static final String LEFTJOIN_NAME; static final String MERGE_NAME; static final String OUTERTHIS_NAME; static final String OUTEROTHER_NAME; static final String SINK_NAME; static final String SOURCE_NAME; static final String REPARTITION_TOPIC_SUFFIX; }
|
@Test(expected = NullPointerException.class) public void shouldNotAllowNullOtherStreamOnJoin() throws Exception { testStream.join(null, MockValueJoiner.TOSTRING_JOINER, JoinWindows.of(10)); }
@Test(expected = NullPointerException.class) public void shouldNotAllowNullValueJoinerOnJoin() throws Exception { testStream.join(testStream, null, JoinWindows.of(10)); }
@Test(expected = NullPointerException.class) public void shouldNotAllowNullJoinWindowsOnJoin() throws Exception { testStream.join(testStream, MockValueJoiner.TOSTRING_JOINER, null); }
@Test(expected = NullPointerException.class) public void shouldNotAllowNullTableOnJoinWithGlobalTable() throws Exception { testStream.join((GlobalKTable) null, MockKeyValueMapper.<String, String>SelectValueMapper(), MockValueJoiner.TOSTRING_JOINER); }
@Test(expected = NullPointerException.class) public void shouldNotAllowNullMapperOnJoinWithGlobalTable() throws Exception { testStream.join(builder.globalTable(Serdes.String(), Serdes.String(), null, "global", "global"), null, MockValueJoiner.TOSTRING_JOINER); }
@Test(expected = NullPointerException.class) public void shouldNotAllowNullJoinerOnJoinWithGlobalTable() throws Exception { testStream.join(builder.globalTable(Serdes.String(), Serdes.String(), null, "global", "global"), MockKeyValueMapper.<String, String>SelectValueMapper(), null); }
|
KStreamImpl extends AbstractStream<K> implements KStream<K, V> { @Override public <V1, R> KStream<K, R> leftJoin( final KStream<K, V1> other, final ValueJoiner<? super V, ? super V1, ? extends R> joiner, final JoinWindows windows, final Serde<K> keySerde, final Serde<V> thisValSerde, final Serde<V1> otherValueSerde) { return doJoin(other, joiner, windows, keySerde, thisValSerde, otherValueSerde, new KStreamImplJoin(true, false)); } KStreamImpl(KStreamBuilder topology, String name, Set<String> sourceNodes,
boolean repartitionRequired); @Override KStream<K, V> filter(Predicate<? super K, ? super V> predicate); @Override KStream<K, V> filterNot(final Predicate<? super K, ? super V> predicate); @Override KStream<K1, V> selectKey(final KeyValueMapper<? super K, ? super V, ? extends K1> mapper); @Override KStream<K1, V1> map(KeyValueMapper<? super K, ? super V, ? extends KeyValue<? extends K1, ? extends V1>> mapper); @Override KStream<K, V1> mapValues(ValueMapper<? super V, ? extends V1> mapper); @Override void print(); @Override void print(String streamName); @Override void print(Serde<K> keySerde, Serde<V> valSerde); @Override void print(Serde<K> keySerde, Serde<V> valSerde, String streamName); @Override void writeAsText(String filePath); @Override void writeAsText(String filePath, String streamName); @Override void writeAsText(String filePath, Serde<K> keySerde, Serde<V> valSerde); @Override void writeAsText(String filePath, String streamName, Serde<K> keySerde, Serde<V> valSerde); @Override KStream<K1, V1> flatMap(KeyValueMapper<? super K, ? super V, ? extends Iterable<? extends KeyValue<? extends K1, ? extends V1>>> mapper); @Override KStream<K, V1> flatMapValues(ValueMapper<? super V, ? extends Iterable<? extends V1>> mapper); @Override @SuppressWarnings("unchecked") KStream<K, V>[] branch(Predicate<? super K, ? super V>... predicates); static KStream<K, V> merge(KStreamBuilder topology, KStream<K, V>[] streams); @Override KStream<K, V> through(Serde<K> keySerde, Serde<V> valSerde, StreamPartitioner<? super K, ? super V> partitioner, String topic); @Override void foreach(ForeachAction<? super K, ? super V> action); @Override KStream<K, V> peek(final ForeachAction<? super K, ? super V> action); @Override KStream<K, V> through(Serde<K> keySerde, Serde<V> valSerde, String topic); @Override KStream<K, V> through(StreamPartitioner<? super K, ? super V> partitioner, String topic); @Override KStream<K, V> through(String topic); @Override void to(String topic); @Override void to(StreamPartitioner<? super K, ? super V> partitioner, String topic); @Override void to(Serde<K> keySerde, Serde<V> valSerde, String topic); @SuppressWarnings("unchecked") @Override void to(final Serde<K> keySerde, final Serde<V> valSerde, StreamPartitioner<? super K, ? super V> partitioner, final String topic); @Override KStream<K1, V1> transform(TransformerSupplier<? super K, ? super V, KeyValue<K1, V1>> transformerSupplier, String... stateStoreNames); @Override KStream<K, V1> transformValues(ValueTransformerSupplier<? super V, ? extends V1> valueTransformerSupplier, String... stateStoreNames); @Override void process(final ProcessorSupplier<? super K, ? super V> processorSupplier, String... stateStoreNames); @Override KStream<K, R> join(
final KStream<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final JoinWindows windows,
final Serde<K> keySerde,
final Serde<V> thisValueSerde,
final Serde<V1> otherValueSerde); @Override KStream<K, R> join(
final KStream<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final JoinWindows windows); @Override KStream<K, R> outerJoin(
final KStream<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final JoinWindows windows,
final Serde<K> keySerde,
final Serde<V> thisValueSerde,
final Serde<V1> otherValueSerde); @Override KStream<K, R> outerJoin(
final KStream<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final JoinWindows windows); @Override KStream<K, R> leftJoin(
final KStream<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final JoinWindows windows,
final Serde<K> keySerde,
final Serde<V> thisValSerde,
final Serde<V1> otherValueSerde); @Override KStream<K, R> leftJoin(
KStream<K, V1> other,
ValueJoiner<? super V, ? super V1, ? extends R> joiner,
JoinWindows windows); @Override KStream<K, R> join(final KTable<K, V1> other, final ValueJoiner<? super V, ? super V1, ? extends R> joiner); @Override KStream<K, R> join(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final Serde<K> keySerde,
final Serde<V> valueSerde); @Override KStream<K, R> leftJoin(final GlobalKTable<K1, V1> globalTable,
final KeyValueMapper<? super K, ? super V, ? extends K1> keyMapper,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner); @Override KStream<K, V2> join(final GlobalKTable<K1, V1> globalTable,
final KeyValueMapper<? super K, ? super V, ? extends K1> keyMapper,
final ValueJoiner<? super V, ? super V1, ? extends V2> joiner); @Override KStream<K, R> leftJoin(final KTable<K, V1> other, final ValueJoiner<? super V, ? super V1, ? extends R> joiner); KStream<K, R> leftJoin(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final Serde<K> keySerde,
final Serde<V> valueSerde); @Override KGroupedStream<K1, V> groupBy(KeyValueMapper<? super K, ? super V, K1> selector); @Override KGroupedStream<K1, V> groupBy(KeyValueMapper<? super K, ? super V, K1> selector,
Serde<K1> keySerde,
Serde<V> valSerde); @Override KGroupedStream<K, V> groupByKey(); @Override KGroupedStream<K, V> groupByKey(Serde<K> keySerde,
Serde<V> valSerde); static final String FILTER_NAME; static final String PEEK_NAME; static final String JOINTHIS_NAME; static final String JOINOTHER_NAME; static final String JOIN_NAME; static final String LEFTJOIN_NAME; static final String MERGE_NAME; static final String OUTERTHIS_NAME; static final String OUTEROTHER_NAME; static final String SINK_NAME; static final String SOURCE_NAME; static final String REPARTITION_TOPIC_SUFFIX; }
|
@Test(expected = NullPointerException.class) public void shouldNotAllowNullTableOnTableJoin() throws Exception { testStream.leftJoin((KTable) null, MockValueJoiner.TOSTRING_JOINER); }
@Test(expected = NullPointerException.class) public void shouldNotAllowNullValueMapperOnTableJoin() throws Exception { testStream.leftJoin(builder.table(Serdes.String(), Serdes.String(), "topic", "store"), null); }
@Test(expected = NullPointerException.class) public void shouldNotAllowNullTableOnJLeftJoinWithGlobalTable() throws Exception { testStream.leftJoin((GlobalKTable) null, MockKeyValueMapper.<String, String>SelectValueMapper(), MockValueJoiner.TOSTRING_JOINER); }
@Test(expected = NullPointerException.class) public void shouldNotAllowNullMapperOnLeftJoinWithGlobalTable() throws Exception { testStream.leftJoin(builder.globalTable(Serdes.String(), Serdes.String(), null, "global", "global"), null, MockValueJoiner.TOSTRING_JOINER); }
@Test(expected = NullPointerException.class) public void shouldNotAllowNullJoinerOnLeftJoinWithGlobalTable() throws Exception { testStream.leftJoin(builder.globalTable(Serdes.String(), Serdes.String(), null, "global", "global"), MockKeyValueMapper.<String, String>SelectValueMapper(), null); }
|
KStreamImpl extends AbstractStream<K> implements KStream<K, V> { @Override public <K1> KGroupedStream<K1, V> groupBy(KeyValueMapper<? super K, ? super V, K1> selector) { return groupBy(selector, null, null); } KStreamImpl(KStreamBuilder topology, String name, Set<String> sourceNodes,
boolean repartitionRequired); @Override KStream<K, V> filter(Predicate<? super K, ? super V> predicate); @Override KStream<K, V> filterNot(final Predicate<? super K, ? super V> predicate); @Override KStream<K1, V> selectKey(final KeyValueMapper<? super K, ? super V, ? extends K1> mapper); @Override KStream<K1, V1> map(KeyValueMapper<? super K, ? super V, ? extends KeyValue<? extends K1, ? extends V1>> mapper); @Override KStream<K, V1> mapValues(ValueMapper<? super V, ? extends V1> mapper); @Override void print(); @Override void print(String streamName); @Override void print(Serde<K> keySerde, Serde<V> valSerde); @Override void print(Serde<K> keySerde, Serde<V> valSerde, String streamName); @Override void writeAsText(String filePath); @Override void writeAsText(String filePath, String streamName); @Override void writeAsText(String filePath, Serde<K> keySerde, Serde<V> valSerde); @Override void writeAsText(String filePath, String streamName, Serde<K> keySerde, Serde<V> valSerde); @Override KStream<K1, V1> flatMap(KeyValueMapper<? super K, ? super V, ? extends Iterable<? extends KeyValue<? extends K1, ? extends V1>>> mapper); @Override KStream<K, V1> flatMapValues(ValueMapper<? super V, ? extends Iterable<? extends V1>> mapper); @Override @SuppressWarnings("unchecked") KStream<K, V>[] branch(Predicate<? super K, ? super V>... predicates); static KStream<K, V> merge(KStreamBuilder topology, KStream<K, V>[] streams); @Override KStream<K, V> through(Serde<K> keySerde, Serde<V> valSerde, StreamPartitioner<? super K, ? super V> partitioner, String topic); @Override void foreach(ForeachAction<? super K, ? super V> action); @Override KStream<K, V> peek(final ForeachAction<? super K, ? super V> action); @Override KStream<K, V> through(Serde<K> keySerde, Serde<V> valSerde, String topic); @Override KStream<K, V> through(StreamPartitioner<? super K, ? super V> partitioner, String topic); @Override KStream<K, V> through(String topic); @Override void to(String topic); @Override void to(StreamPartitioner<? super K, ? super V> partitioner, String topic); @Override void to(Serde<K> keySerde, Serde<V> valSerde, String topic); @SuppressWarnings("unchecked") @Override void to(final Serde<K> keySerde, final Serde<V> valSerde, StreamPartitioner<? super K, ? super V> partitioner, final String topic); @Override KStream<K1, V1> transform(TransformerSupplier<? super K, ? super V, KeyValue<K1, V1>> transformerSupplier, String... stateStoreNames); @Override KStream<K, V1> transformValues(ValueTransformerSupplier<? super V, ? extends V1> valueTransformerSupplier, String... stateStoreNames); @Override void process(final ProcessorSupplier<? super K, ? super V> processorSupplier, String... stateStoreNames); @Override KStream<K, R> join(
final KStream<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final JoinWindows windows,
final Serde<K> keySerde,
final Serde<V> thisValueSerde,
final Serde<V1> otherValueSerde); @Override KStream<K, R> join(
final KStream<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final JoinWindows windows); @Override KStream<K, R> outerJoin(
final KStream<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final JoinWindows windows,
final Serde<K> keySerde,
final Serde<V> thisValueSerde,
final Serde<V1> otherValueSerde); @Override KStream<K, R> outerJoin(
final KStream<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final JoinWindows windows); @Override KStream<K, R> leftJoin(
final KStream<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final JoinWindows windows,
final Serde<K> keySerde,
final Serde<V> thisValSerde,
final Serde<V1> otherValueSerde); @Override KStream<K, R> leftJoin(
KStream<K, V1> other,
ValueJoiner<? super V, ? super V1, ? extends R> joiner,
JoinWindows windows); @Override KStream<K, R> join(final KTable<K, V1> other, final ValueJoiner<? super V, ? super V1, ? extends R> joiner); @Override KStream<K, R> join(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final Serde<K> keySerde,
final Serde<V> valueSerde); @Override KStream<K, R> leftJoin(final GlobalKTable<K1, V1> globalTable,
final KeyValueMapper<? super K, ? super V, ? extends K1> keyMapper,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner); @Override KStream<K, V2> join(final GlobalKTable<K1, V1> globalTable,
final KeyValueMapper<? super K, ? super V, ? extends K1> keyMapper,
final ValueJoiner<? super V, ? super V1, ? extends V2> joiner); @Override KStream<K, R> leftJoin(final KTable<K, V1> other, final ValueJoiner<? super V, ? super V1, ? extends R> joiner); KStream<K, R> leftJoin(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final Serde<K> keySerde,
final Serde<V> valueSerde); @Override KGroupedStream<K1, V> groupBy(KeyValueMapper<? super K, ? super V, K1> selector); @Override KGroupedStream<K1, V> groupBy(KeyValueMapper<? super K, ? super V, K1> selector,
Serde<K1> keySerde,
Serde<V> valSerde); @Override KGroupedStream<K, V> groupByKey(); @Override KGroupedStream<K, V> groupByKey(Serde<K> keySerde,
Serde<V> valSerde); static final String FILTER_NAME; static final String PEEK_NAME; static final String JOINTHIS_NAME; static final String JOINOTHER_NAME; static final String JOIN_NAME; static final String LEFTJOIN_NAME; static final String MERGE_NAME; static final String OUTERTHIS_NAME; static final String OUTEROTHER_NAME; static final String SINK_NAME; static final String SOURCE_NAME; static final String REPARTITION_TOPIC_SUFFIX; }
|
@Test(expected = NullPointerException.class) public void shouldNotAllowNullSelectorOnGroupBy() throws Exception { testStream.groupBy(null); }
|
KStreamImpl extends AbstractStream<K> implements KStream<K, V> { @Override public void foreach(ForeachAction<? super K, ? super V> action) { Objects.requireNonNull(action, "action can't be null"); String name = topology.newName(FOREACH_NAME); topology.addProcessor(name, new KStreamPeek<>(action, false), this.name); } KStreamImpl(KStreamBuilder topology, String name, Set<String> sourceNodes,
boolean repartitionRequired); @Override KStream<K, V> filter(Predicate<? super K, ? super V> predicate); @Override KStream<K, V> filterNot(final Predicate<? super K, ? super V> predicate); @Override KStream<K1, V> selectKey(final KeyValueMapper<? super K, ? super V, ? extends K1> mapper); @Override KStream<K1, V1> map(KeyValueMapper<? super K, ? super V, ? extends KeyValue<? extends K1, ? extends V1>> mapper); @Override KStream<K, V1> mapValues(ValueMapper<? super V, ? extends V1> mapper); @Override void print(); @Override void print(String streamName); @Override void print(Serde<K> keySerde, Serde<V> valSerde); @Override void print(Serde<K> keySerde, Serde<V> valSerde, String streamName); @Override void writeAsText(String filePath); @Override void writeAsText(String filePath, String streamName); @Override void writeAsText(String filePath, Serde<K> keySerde, Serde<V> valSerde); @Override void writeAsText(String filePath, String streamName, Serde<K> keySerde, Serde<V> valSerde); @Override KStream<K1, V1> flatMap(KeyValueMapper<? super K, ? super V, ? extends Iterable<? extends KeyValue<? extends K1, ? extends V1>>> mapper); @Override KStream<K, V1> flatMapValues(ValueMapper<? super V, ? extends Iterable<? extends V1>> mapper); @Override @SuppressWarnings("unchecked") KStream<K, V>[] branch(Predicate<? super K, ? super V>... predicates); static KStream<K, V> merge(KStreamBuilder topology, KStream<K, V>[] streams); @Override KStream<K, V> through(Serde<K> keySerde, Serde<V> valSerde, StreamPartitioner<? super K, ? super V> partitioner, String topic); @Override void foreach(ForeachAction<? super K, ? super V> action); @Override KStream<K, V> peek(final ForeachAction<? super K, ? super V> action); @Override KStream<K, V> through(Serde<K> keySerde, Serde<V> valSerde, String topic); @Override KStream<K, V> through(StreamPartitioner<? super K, ? super V> partitioner, String topic); @Override KStream<K, V> through(String topic); @Override void to(String topic); @Override void to(StreamPartitioner<? super K, ? super V> partitioner, String topic); @Override void to(Serde<K> keySerde, Serde<V> valSerde, String topic); @SuppressWarnings("unchecked") @Override void to(final Serde<K> keySerde, final Serde<V> valSerde, StreamPartitioner<? super K, ? super V> partitioner, final String topic); @Override KStream<K1, V1> transform(TransformerSupplier<? super K, ? super V, KeyValue<K1, V1>> transformerSupplier, String... stateStoreNames); @Override KStream<K, V1> transformValues(ValueTransformerSupplier<? super V, ? extends V1> valueTransformerSupplier, String... stateStoreNames); @Override void process(final ProcessorSupplier<? super K, ? super V> processorSupplier, String... stateStoreNames); @Override KStream<K, R> join(
final KStream<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final JoinWindows windows,
final Serde<K> keySerde,
final Serde<V> thisValueSerde,
final Serde<V1> otherValueSerde); @Override KStream<K, R> join(
final KStream<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final JoinWindows windows); @Override KStream<K, R> outerJoin(
final KStream<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final JoinWindows windows,
final Serde<K> keySerde,
final Serde<V> thisValueSerde,
final Serde<V1> otherValueSerde); @Override KStream<K, R> outerJoin(
final KStream<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final JoinWindows windows); @Override KStream<K, R> leftJoin(
final KStream<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final JoinWindows windows,
final Serde<K> keySerde,
final Serde<V> thisValSerde,
final Serde<V1> otherValueSerde); @Override KStream<K, R> leftJoin(
KStream<K, V1> other,
ValueJoiner<? super V, ? super V1, ? extends R> joiner,
JoinWindows windows); @Override KStream<K, R> join(final KTable<K, V1> other, final ValueJoiner<? super V, ? super V1, ? extends R> joiner); @Override KStream<K, R> join(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final Serde<K> keySerde,
final Serde<V> valueSerde); @Override KStream<K, R> leftJoin(final GlobalKTable<K1, V1> globalTable,
final KeyValueMapper<? super K, ? super V, ? extends K1> keyMapper,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner); @Override KStream<K, V2> join(final GlobalKTable<K1, V1> globalTable,
final KeyValueMapper<? super K, ? super V, ? extends K1> keyMapper,
final ValueJoiner<? super V, ? super V1, ? extends V2> joiner); @Override KStream<K, R> leftJoin(final KTable<K, V1> other, final ValueJoiner<? super V, ? super V1, ? extends R> joiner); KStream<K, R> leftJoin(final KTable<K, V1> other,
final ValueJoiner<? super V, ? super V1, ? extends R> joiner,
final Serde<K> keySerde,
final Serde<V> valueSerde); @Override KGroupedStream<K1, V> groupBy(KeyValueMapper<? super K, ? super V, K1> selector); @Override KGroupedStream<K1, V> groupBy(KeyValueMapper<? super K, ? super V, K1> selector,
Serde<K1> keySerde,
Serde<V> valSerde); @Override KGroupedStream<K, V> groupByKey(); @Override KGroupedStream<K, V> groupByKey(Serde<K> keySerde,
Serde<V> valSerde); static final String FILTER_NAME; static final String PEEK_NAME; static final String JOINTHIS_NAME; static final String JOINOTHER_NAME; static final String JOIN_NAME; static final String LEFTJOIN_NAME; static final String MERGE_NAME; static final String OUTERTHIS_NAME; static final String OUTEROTHER_NAME; static final String SINK_NAME; static final String SOURCE_NAME; static final String REPARTITION_TOPIC_SUFFIX; }
|
@Test(expected = NullPointerException.class) public void shouldNotAllowNullActionOnForEach() throws Exception { testStream.foreach(null); }
|
KStreamBranch implements ProcessorSupplier<K, V> { @SuppressWarnings("unchecked") public KStreamBranch(Predicate<K, V> ... predicates) { this.predicates = predicates; } @SuppressWarnings("unchecked") KStreamBranch(Predicate<K, V> ... predicates); @Override Processor<K, V> get(); }
|
@SuppressWarnings("unchecked") @Test public void testKStreamBranch() { KStreamBuilder builder = new KStreamBuilder(); builder.setApplicationId("X"); Predicate<Integer, String> isEven = new Predicate<Integer, String>() { @Override public boolean test(Integer key, String value) { return (key % 2) == 0; } }; Predicate<Integer, String> isMultipleOfThree = new Predicate<Integer, String>() { @Override public boolean test(Integer key, String value) { return (key % 3) == 0; } }; Predicate<Integer, String> isOdd = new Predicate<Integer, String>() { @Override public boolean test(Integer key, String value) { return (key % 2) != 0; } }; final int[] expectedKeys = new int[]{1, 2, 3, 4, 5, 6}; KStream<Integer, String> stream; KStream<Integer, String>[] branches; MockProcessorSupplier<Integer, String>[] processors; stream = builder.stream(Serdes.Integer(), Serdes.String(), topicName); branches = stream.branch(isEven, isMultipleOfThree, isOdd); assertEquals(3, branches.length); processors = (MockProcessorSupplier<Integer, String>[]) Array.newInstance(MockProcessorSupplier.class, branches.length); for (int i = 0; i < branches.length; i++) { processors[i] = new MockProcessorSupplier<>(); branches[i].process(processors[i]); } driver = new KStreamTestDriver(builder); for (int expectedKey : expectedKeys) { driver.process(topicName, expectedKey, "V" + expectedKey); } assertEquals(3, processors[0].processed.size()); assertEquals(1, processors[1].processed.size()); assertEquals(2, processors[2].processed.size()); }
|
KGroupedTableImpl extends AbstractStream<K> implements KGroupedTable<K, V> { @Override public KTable<K, Long> count(final String queryableStoreName) { determineIsQueryable(queryableStoreName); return count(keyValueStore(keySerde, Serdes.Long(), getOrCreateName(queryableStoreName, AGGREGATE_NAME))); } KGroupedTableImpl(final KStreamBuilder topology,
final String name,
final String sourceName,
final Serde<? extends K> keySerde,
final Serde<? extends V> valSerde); @Override KTable<K, T> aggregate(final Initializer<T> initializer,
final Aggregator<? super K, ? super V, T> adder,
final Aggregator<? super K, ? super V, T> subtractor,
final Serde<T> aggValueSerde,
final String queryableStoreName); @Override KTable<K, T> aggregate(final Initializer<T> initializer,
final Aggregator<? super K, ? super V, T> adder,
final Aggregator<? super K, ? super V, T> subtractor,
final Serde<T> aggValueSerde); @Override KTable<K, T> aggregate(final Initializer<T> initializer,
final Aggregator<? super K, ? super V, T> adder,
final Aggregator<? super K, ? super V, T> subtractor,
final String queryableStoreName); @Override KTable<K, T> aggregate(final Initializer<T> initializer,
final Aggregator<? super K, ? super V, T> adder,
final Aggregator<? super K, ? super V, T> subtractor); @Override KTable<K, T> aggregate(final Initializer<T> initializer,
final Aggregator<? super K, ? super V, T> adder,
final Aggregator<? super K, ? super V, T> subtractor,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, V> reduce(final Reducer<V> adder,
final Reducer<V> subtractor,
final String queryableStoreName); @Override KTable<K, V> reduce(final Reducer<V> adder,
final Reducer<V> subtractor); @Override KTable<K, V> reduce(final Reducer<V> adder,
final Reducer<V> subtractor,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, Long> count(final String queryableStoreName); @Override KTable<K, Long> count(); @Override KTable<K, Long> count(final StateStoreSupplier<KeyValueStore> storeSupplier); }
|
@Test public void shouldAllowNullStoreNameOnCount() { groupedTable.count((String) null); }
|
KGroupedTableImpl extends AbstractStream<K> implements KGroupedTable<K, V> { @Override public <T> KTable<K, T> aggregate(final Initializer<T> initializer, final Aggregator<? super K, ? super V, T> adder, final Aggregator<? super K, ? super V, T> subtractor, final Serde<T> aggValueSerde, final String queryableStoreName) { determineIsQueryable(queryableStoreName); return aggregate(initializer, adder, subtractor, keyValueStore(keySerde, aggValueSerde, getOrCreateName(queryableStoreName, AGGREGATE_NAME))); } KGroupedTableImpl(final KStreamBuilder topology,
final String name,
final String sourceName,
final Serde<? extends K> keySerde,
final Serde<? extends V> valSerde); @Override KTable<K, T> aggregate(final Initializer<T> initializer,
final Aggregator<? super K, ? super V, T> adder,
final Aggregator<? super K, ? super V, T> subtractor,
final Serde<T> aggValueSerde,
final String queryableStoreName); @Override KTable<K, T> aggregate(final Initializer<T> initializer,
final Aggregator<? super K, ? super V, T> adder,
final Aggregator<? super K, ? super V, T> subtractor,
final Serde<T> aggValueSerde); @Override KTable<K, T> aggregate(final Initializer<T> initializer,
final Aggregator<? super K, ? super V, T> adder,
final Aggregator<? super K, ? super V, T> subtractor,
final String queryableStoreName); @Override KTable<K, T> aggregate(final Initializer<T> initializer,
final Aggregator<? super K, ? super V, T> adder,
final Aggregator<? super K, ? super V, T> subtractor); @Override KTable<K, T> aggregate(final Initializer<T> initializer,
final Aggregator<? super K, ? super V, T> adder,
final Aggregator<? super K, ? super V, T> subtractor,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, V> reduce(final Reducer<V> adder,
final Reducer<V> subtractor,
final String queryableStoreName); @Override KTable<K, V> reduce(final Reducer<V> adder,
final Reducer<V> subtractor); @Override KTable<K, V> reduce(final Reducer<V> adder,
final Reducer<V> subtractor,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, Long> count(final String queryableStoreName); @Override KTable<K, Long> count(); @Override KTable<K, Long> count(final StateStoreSupplier<KeyValueStore> storeSupplier); }
|
@Test public void shouldAllowNullStoreNameOnAggregate() throws Exception { groupedTable.aggregate(MockInitializer.STRING_INIT, MockAggregator.TOSTRING_ADDER, MockAggregator.TOSTRING_REMOVER, (String) null); }
@Test(expected = InvalidTopicException.class) public void shouldNotAllowInvalidStoreNameOnAggregate() throws Exception { groupedTable.aggregate(MockInitializer.STRING_INIT, MockAggregator.TOSTRING_ADDER, MockAggregator.TOSTRING_REMOVER, INVALID_STORE_NAME); }
@Test(expected = NullPointerException.class) public void shouldNotAllowNullInitializerOnAggregate() throws Exception { groupedTable.aggregate(null, MockAggregator.TOSTRING_ADDER, MockAggregator.TOSTRING_REMOVER, "store"); }
@Test(expected = NullPointerException.class) public void shouldNotAllowNullAdderOnAggregate() throws Exception { groupedTable.aggregate(MockInitializer.STRING_INIT, null, MockAggregator.TOSTRING_REMOVER, "store"); }
@Test(expected = NullPointerException.class) public void shouldNotAllowNullSubtractorOnAggregate() throws Exception { groupedTable.aggregate(MockInitializer.STRING_INIT, MockAggregator.TOSTRING_ADDER, null, "store"); }
|
KGroupedTableImpl extends AbstractStream<K> implements KGroupedTable<K, V> { @Override public KTable<K, V> reduce(final Reducer<V> adder, final Reducer<V> subtractor, final String queryableStoreName) { determineIsQueryable(queryableStoreName); return reduce(adder, subtractor, keyValueStore(keySerde, valSerde, getOrCreateName(queryableStoreName, REDUCE_NAME))); } KGroupedTableImpl(final KStreamBuilder topology,
final String name,
final String sourceName,
final Serde<? extends K> keySerde,
final Serde<? extends V> valSerde); @Override KTable<K, T> aggregate(final Initializer<T> initializer,
final Aggregator<? super K, ? super V, T> adder,
final Aggregator<? super K, ? super V, T> subtractor,
final Serde<T> aggValueSerde,
final String queryableStoreName); @Override KTable<K, T> aggregate(final Initializer<T> initializer,
final Aggregator<? super K, ? super V, T> adder,
final Aggregator<? super K, ? super V, T> subtractor,
final Serde<T> aggValueSerde); @Override KTable<K, T> aggregate(final Initializer<T> initializer,
final Aggregator<? super K, ? super V, T> adder,
final Aggregator<? super K, ? super V, T> subtractor,
final String queryableStoreName); @Override KTable<K, T> aggregate(final Initializer<T> initializer,
final Aggregator<? super K, ? super V, T> adder,
final Aggregator<? super K, ? super V, T> subtractor); @Override KTable<K, T> aggregate(final Initializer<T> initializer,
final Aggregator<? super K, ? super V, T> adder,
final Aggregator<? super K, ? super V, T> subtractor,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, V> reduce(final Reducer<V> adder,
final Reducer<V> subtractor,
final String queryableStoreName); @Override KTable<K, V> reduce(final Reducer<V> adder,
final Reducer<V> subtractor); @Override KTable<K, V> reduce(final Reducer<V> adder,
final Reducer<V> subtractor,
final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<K, Long> count(final String queryableStoreName); @Override KTable<K, Long> count(); @Override KTable<K, Long> count(final StateStoreSupplier<KeyValueStore> storeSupplier); }
|
@Test(expected = NullPointerException.class) public void shouldNotAllowNullAdderOnReduce() throws Exception { groupedTable.reduce(null, MockReducer.STRING_REMOVER, "store"); }
@Test(expected = NullPointerException.class) public void shouldNotAllowNullSubtractorOnReduce() throws Exception { groupedTable.reduce(MockReducer.STRING_ADDER, null, "store"); }
@Test public void shouldAllowNullStoreNameOnReduce() throws Exception { groupedTable.reduce(MockReducer.STRING_ADDER, MockReducer.STRING_REMOVER, (String) null); }
@Test(expected = InvalidTopicException.class) public void shouldNotAllowInvalidStoreNameOnReduce() throws Exception { groupedTable.reduce(MockReducer.STRING_ADDER, MockReducer.STRING_REMOVER, INVALID_STORE_NAME); }
@Test(expected = NullPointerException.class) public void shouldNotAllowNullStoreSupplierOnReduce() throws Exception { groupedTable.reduce(MockReducer.STRING_ADDER, MockReducer.STRING_REMOVER, (StateStoreSupplier<KeyValueStore>) null); }
@Test public void shouldReduce() throws Exception { final String topic = "input"; final KeyValueMapper<String, Number, KeyValue<String, Integer>> intProjection = new KeyValueMapper<String, Number, KeyValue<String, Integer>>() { @Override public KeyValue<String, Integer> apply(String key, Number value) { return KeyValue.pair(key, value.intValue()); } }; final KTable<String, Integer> reduced = builder.table(Serdes.String(), Serdes.Double(), topic, "store") .groupBy(intProjection) .reduce(MockReducer.INTEGER_ADDER, MockReducer.INTEGER_SUBTRACTOR, "reduced"); doShouldReduce(reduced, topic); assertEquals(reduced.queryableStoreName(), "reduced"); }
@Test public void shouldReduceWithInternalStoreName() throws Exception { final String topic = "input"; final KeyValueMapper<String, Number, KeyValue<String, Integer>> intProjection = new KeyValueMapper<String, Number, KeyValue<String, Integer>>() { @Override public KeyValue<String, Integer> apply(String key, Number value) { return KeyValue.pair(key, value.intValue()); } }; final KTable<String, Integer> reduced = builder.table(Serdes.String(), Serdes.Double(), topic, "store") .groupBy(intProjection) .reduce(MockReducer.INTEGER_ADDER, MockReducer.INTEGER_SUBTRACTOR); doShouldReduce(reduced, topic); assertNull(reduced.queryableStoreName()); }
|
SessionKeySerde implements Serde<Windowed<K>> { @Override public Serializer<Windowed<K>> serializer() { return new SessionKeySerializer(keySerde.serializer()); } SessionKeySerde(final Serde<K> keySerde); @Override void configure(final Map<String, ?> configs, final boolean isKey); @Override void close(); @Override Serializer<Windowed<K>> serializer(); @Override Deserializer<Windowed<K>> deserializer(); static long extractEnd(final byte[] binaryKey); static long extractStart(final byte[] binaryKey); static byte[] extractKeyBytes(final byte[] binaryKey); static Windowed<K> from(final byte[] binaryKey, final Deserializer<K> keyDeserializer, final String topic); static Windowed<Bytes> fromBytes(Bytes bytesKey); static Bytes toBinary(final Windowed<K> sessionKey, final Serializer<K> serializer, final String topic); static Bytes bytesToBinary(final Windowed<Bytes> sessionKey); }
|
@Test public void shouldSerializeNullToNull() throws Exception { assertNull(sessionKeySerde.serializer().serialize(topic, null)); }
|
SessionKeySerde implements Serde<Windowed<K>> { @Override public Deserializer<Windowed<K>> deserializer() { return new SessionKeyDeserializer(keySerde.deserializer()); } SessionKeySerde(final Serde<K> keySerde); @Override void configure(final Map<String, ?> configs, final boolean isKey); @Override void close(); @Override Serializer<Windowed<K>> serializer(); @Override Deserializer<Windowed<K>> deserializer(); static long extractEnd(final byte[] binaryKey); static long extractStart(final byte[] binaryKey); static byte[] extractKeyBytes(final byte[] binaryKey); static Windowed<K> from(final byte[] binaryKey, final Deserializer<K> keyDeserializer, final String topic); static Windowed<Bytes> fromBytes(Bytes bytesKey); static Bytes toBinary(final Windowed<K> sessionKey, final Serializer<K> serializer, final String topic); static Bytes bytesToBinary(final Windowed<Bytes> sessionKey); }
|
@Test public void shouldDeSerializeEmtpyByteArrayToNull() throws Exception { assertNull(sessionKeySerde.deserializer().deserialize(topic, new byte[0])); }
@Test public void shouldDeSerializeNullToNull() throws Exception { assertNull(sessionKeySerde.deserializer().deserialize(topic, null)); }
|
KStreamMap implements ProcessorSupplier<K, V> { @Override public Processor<K, V> get() { return new KStreamMapProcessor(); } KStreamMap(KeyValueMapper<? super K, ? super V, ? extends KeyValue<? extends K1, ? extends V1>> mapper); @Override Processor<K, V> get(); }
|
@Test public void testMap() { KStreamBuilder builder = new KStreamBuilder(); KeyValueMapper<Integer, String, KeyValue<String, Integer>> mapper = new KeyValueMapper<Integer, String, KeyValue<String, Integer>>() { @Override public KeyValue<String, Integer> apply(Integer key, String value) { return KeyValue.pair(value, key); } }; final int[] expectedKeys = new int[]{0, 1, 2, 3}; KStream<Integer, String> stream = builder.stream(intSerde, stringSerde, topicName); MockProcessorSupplier<String, Integer> processor; processor = new MockProcessorSupplier<>(); stream.map(mapper).process(processor); driver = new KStreamTestDriver(builder); for (int expectedKey : expectedKeys) { driver.process(topicName, expectedKey, "V" + expectedKey); } assertEquals(4, processor.processed.size()); String[] expected = new String[]{"V0:0", "V1:1", "V2:2", "V3:3"}; for (int i = 0; i < expected.length; i++) { assertEquals(expected[i], processor.processed.get(i)); } }
|
KStreamTransform implements ProcessorSupplier<K, V> { @Override public Processor<K, V> get() { return new KStreamTransformProcessor<>(transformerSupplier.get()); } KStreamTransform(TransformerSupplier<? super K, ? super V, ? extends KeyValue<? extends K1, ? extends V1>> transformerSupplier); @Override Processor<K, V> get(); }
|
@Test public void testTransform() { KStreamBuilder builder = new KStreamBuilder(); TransformerSupplier<Number, Number, KeyValue<Integer, Integer>> transformerSupplier = new TransformerSupplier<Number, Number, KeyValue<Integer, Integer>>() { public Transformer<Number, Number, KeyValue<Integer, Integer>> get() { return new Transformer<Number, Number, KeyValue<Integer, Integer>>() { private int total = 0; @Override public void init(ProcessorContext context) { } @Override public KeyValue<Integer, Integer> transform(Number key, Number value) { total += value.intValue(); return KeyValue.pair(key.intValue() * 2, total); } @Override public KeyValue<Integer, Integer> punctuate(long timestamp) { return KeyValue.pair(-1, (int) timestamp); } @Override public void close() { } }; } }; final int[] expectedKeys = {1, 10, 100, 1000}; MockProcessorSupplier<Integer, Integer> processor = new MockProcessorSupplier<>(); KStream<Integer, Integer> stream = builder.stream(intSerde, intSerde, topicName); stream.transform(transformerSupplier).process(processor); driver = new KStreamTestDriver(builder); for (int expectedKey : expectedKeys) { driver.process(topicName, expectedKey, expectedKey * 10); } driver.punctuate(2); driver.punctuate(3); assertEquals(6, processor.processed.size()); String[] expected = {"2:10", "20:110", "200:1110", "2000:11110", "-1:2", "-1:3"}; for (int i = 0; i < expected.length; i++) { assertEquals(expected[i], processor.processed.get(i)); } }
|
KTableKTableLeftJoin extends KTableKTableAbstractJoin<K, R, V1, V2> { @Override public Processor<K, Change<V1>> get() { return new KTableKTableLeftJoinProcessor(valueGetterSupplier2.get()); } KTableKTableLeftJoin(KTableImpl<K, ?, V1> table1, KTableImpl<K, ?, V2> table2, ValueJoiner<? super V1, ? super V2, ? extends R> joiner); @Override Processor<K, Change<V1>> get(); @Override KTableValueGetterSupplier<K, R> view(); }
|
@Test public void testJoin() throws Exception { final KStreamBuilder builder = new KStreamBuilder(); final int[] expectedKeys = new int[]{0, 1, 2, 3}; KTable<Integer, String> table1 = builder.table(intSerde, stringSerde, topic1, storeName1); KTable<Integer, String> table2 = builder.table(intSerde, stringSerde, topic2, storeName2); KTable<Integer, String> joined = table1.leftJoin(table2, MockValueJoiner.TOSTRING_JOINER); MockProcessorSupplier<Integer, String> processor; processor = new MockProcessorSupplier<>(); joined.toStream().process(processor); Collection<Set<String>> copartitionGroups = builder.copartitionGroups(); assertEquals(1, copartitionGroups.size()); assertEquals(new HashSet<>(Arrays.asList(topic1, topic2)), copartitionGroups.iterator().next()); KTableValueGetterSupplier<Integer, String> getterSupplier = ((KTableImpl<Integer, String, String>) joined).valueGetterSupplier(); driver = new KStreamTestDriver(builder, stateDir); driver.setTime(0L); KTableValueGetter<Integer, String> getter = getterSupplier.get(); getter.init(driver.context()); for (int i = 0; i < 2; i++) { driver.process(topic1, expectedKeys[i], "X" + expectedKeys[i]); } driver.process(topic1, null, "SomeVal"); driver.flushState(); processor.checkAndClearProcessResult("0:X0+null", "1:X1+null"); checkJoinedValues(getter, kv(0, "X0+null"), kv(1, "X1+null"), kv(2, null), kv(3, null)); for (int i = 0; i < 2; i++) { driver.process(topic2, expectedKeys[i], "Y" + expectedKeys[i]); } driver.process(topic2, null, "AnotherVal"); driver.flushState(); processor.checkAndClearProcessResult("0:X0+Y0", "1:X1+Y1"); checkJoinedValues(getter, kv(0, "X0+Y0"), kv(1, "X1+Y1"), kv(2, null), kv(3, null)); for (int expectedKey : expectedKeys) { driver.process(topic1, expectedKey, "X" + expectedKey); } driver.flushState(); processor.checkAndClearProcessResult("0:X0+Y0", "1:X1+Y1", "2:X2+null", "3:X3+null"); checkJoinedValues(getter, kv(0, "X0+Y0"), kv(1, "X1+Y1"), kv(2, "X2+null"), kv(3, "X3+null")); for (int expectedKey : expectedKeys) { driver.process(topic2, expectedKey, "YY" + expectedKey); } driver.flushState(); processor.checkAndClearProcessResult("0:X0+YY0", "1:X1+YY1", "2:X2+YY2", "3:X3+YY3"); checkJoinedValues(getter, kv(0, "X0+YY0"), kv(1, "X1+YY1"), kv(2, "X2+YY2"), kv(3, "X3+YY3")); for (int expectedKey : expectedKeys) { driver.process(topic1, expectedKey, "X" + expectedKey); } driver.flushState(); processor.checkAndClearProcessResult("0:X0+YY0", "1:X1+YY1", "2:X2+YY2", "3:X3+YY3"); checkJoinedValues(getter, kv(0, "X0+YY0"), kv(1, "X1+YY1"), kv(2, "X2+YY2"), kv(3, "X3+YY3")); for (int i = 0; i < 2; i++) { driver.process(topic2, expectedKeys[i], null); } driver.flushState(); processor.checkAndClearProcessResult("0:X0+null", "1:X1+null"); checkJoinedValues(getter, kv(0, "X0+null"), kv(1, "X1+null"), kv(2, "X2+YY2"), kv(3, "X3+YY3")); for (int expectedKey : expectedKeys) { driver.process(topic1, expectedKey, "XX" + expectedKey); } driver.flushState(); processor.checkAndClearProcessResult("0:XX0+null", "1:XX1+null", "2:XX2+YY2", "3:XX3+YY3"); checkJoinedValues(getter, kv(0, "XX0+null"), kv(1, "XX1+null"), kv(2, "XX2+YY2"), kv(3, "XX3+YY3")); }
|
KTableSource implements ProcessorSupplier<K, V> { @Override public Processor<K, V> get() { return new KTableSourceProcessor(); } KTableSource(String storeName); @Override Processor<K, V> get(); void enableSendingOldValues(); final String storeName; }
|
@Test public void testValueGetter() throws IOException { final KStreamBuilder builder = new KStreamBuilder(); String topic1 = "topic1"; KTableImpl<String, String, String> table1 = (KTableImpl<String, String, String>) builder.table(stringSerde, stringSerde, topic1, "anyStoreName"); KTableValueGetterSupplier<String, String> getterSupplier1 = table1.valueGetterSupplier(); driver = new KStreamTestDriver(builder, stateDir, null, null); KTableValueGetter<String, String> getter1 = getterSupplier1.get(); getter1.init(driver.context()); driver.process(topic1, "A", "01"); driver.process(topic1, "B", "01"); driver.process(topic1, "C", "01"); assertEquals("01", getter1.get("A")); assertEquals("01", getter1.get("B")); assertEquals("01", getter1.get("C")); driver.process(topic1, "A", "02"); driver.process(topic1, "B", "02"); assertEquals("02", getter1.get("A")); assertEquals("02", getter1.get("B")); assertEquals("01", getter1.get("C")); driver.process(topic1, "A", "03"); assertEquals("03", getter1.get("A")); assertEquals("02", getter1.get("B")); assertEquals("01", getter1.get("C")); driver.process(topic1, "A", null); driver.process(topic1, "B", null); assertNull(getter1.get("A")); assertNull(getter1.get("B")); assertEquals("01", getter1.get("C")); }
|
KTableSource implements ProcessorSupplier<K, V> { public void enableSendingOldValues() { sendOldValues = true; } KTableSource(String storeName); @Override Processor<K, V> get(); void enableSendingOldValues(); final String storeName; }
|
@Test public void testSendingOldValue() throws IOException { final KStreamBuilder builder = new KStreamBuilder(); String topic1 = "topic1"; KTableImpl<String, String, String> table1 = (KTableImpl<String, String, String>) builder.table(stringSerde, stringSerde, topic1, "anyStoreName"); table1.enableSendingOldValues(); assertTrue(table1.sendingOldValueEnabled()); MockProcessorSupplier<String, Integer> proc1 = new MockProcessorSupplier<>(); builder.addProcessor("proc1", proc1, table1.name); driver = new KStreamTestDriver(builder, stateDir, null, null); driver.process(topic1, "A", "01"); driver.process(topic1, "B", "01"); driver.process(topic1, "C", "01"); driver.flushState(); proc1.checkAndClearProcessResult("A:(01<-null)", "B:(01<-null)", "C:(01<-null)"); driver.process(topic1, "A", "02"); driver.process(topic1, "B", "02"); driver.flushState(); proc1.checkAndClearProcessResult("A:(02<-01)", "B:(02<-01)"); driver.process(topic1, "A", "03"); driver.flushState(); proc1.checkAndClearProcessResult("A:(03<-02)"); driver.process(topic1, "A", null); driver.process(topic1, "B", null); driver.flushState(); proc1.checkAndClearProcessResult("A:(null<-03)", "B:(null<-02)"); }
|
KTableMapValues implements KTableProcessorSupplier<K, V, V1> { @Override public void enableSendingOldValues() { parent.enableSendingOldValues(); sendOldValues = true; } KTableMapValues(final KTableImpl<K, ?, V> parent, final ValueMapper<? super V, ? extends V1> mapper,
final String queryableName); @Override Processor<K, Change<V>> get(); @Override KTableValueGetterSupplier<K, V1> view(); @Override void enableSendingOldValues(); }
|
@Test public void testSendingOldValue() throws IOException { KStreamBuilder builder = new KStreamBuilder(); String topic1 = "topic1"; KTableImpl<String, String, String> table1 = (KTableImpl<String, String, String>) builder.table(stringSerde, stringSerde, topic1, "anyStoreName"); KTableImpl<String, String, Integer> table2 = (KTableImpl<String, String, Integer>) table1.mapValues( new ValueMapper<String, Integer>() { @Override public Integer apply(String value) { return new Integer(value); } }); table2.enableSendingOldValues(); MockProcessorSupplier<String, Integer> proc = new MockProcessorSupplier<>(); builder.addProcessor("proc", proc, table2.name); driver = new KStreamTestDriver(builder, stateDir, null, null); assertTrue(table1.sendingOldValueEnabled()); assertTrue(table2.sendingOldValueEnabled()); driver.process(topic1, "A", "01"); driver.process(topic1, "B", "01"); driver.process(topic1, "C", "01"); driver.flushState(); proc.checkAndClearProcessResult("A:(1<-null)", "B:(1<-null)", "C:(1<-null)"); driver.process(topic1, "A", "02"); driver.process(topic1, "B", "02"); driver.flushState(); proc.checkAndClearProcessResult("A:(2<-1)", "B:(2<-1)"); driver.process(topic1, "A", "03"); driver.flushState(); proc.checkAndClearProcessResult("A:(3<-2)"); driver.process(topic1, "A", null); driver.flushState(); proc.checkAndClearProcessResult("A:(null<-3)"); }
|
ByteArrayConverter implements Converter { @Override public byte[] fromConnectData(String topic, Schema schema, Object value) { if (schema != null && schema.type() != Schema.Type.BYTES) throw new DataException("Invalid schema type for ByteArrayConverter: " + schema.type().toString()); if (value != null && !(value instanceof byte[])) throw new DataException("ByteArrayConverter is not compatible with objects of type " + value.getClass()); return (byte[]) value; } @Override void configure(Map<String, ?> configs, boolean isKey); @Override byte[] fromConnectData(String topic, Schema schema, Object value); @Override SchemaAndValue toConnectData(String topic, byte[] value); }
|
@Test public void testFromConnect() { assertArrayEquals( SAMPLE_BYTES, converter.fromConnectData(TOPIC, Schema.BYTES_SCHEMA, SAMPLE_BYTES) ); }
@Test public void testFromConnectSchemaless() { assertArrayEquals( SAMPLE_BYTES, converter.fromConnectData(TOPIC, null, SAMPLE_BYTES) ); }
@Test(expected = DataException.class) public void testFromConnectBadSchema() { converter.fromConnectData(TOPIC, Schema.INT32_SCHEMA, SAMPLE_BYTES); }
@Test(expected = DataException.class) public void testFromConnectInvalidValue() { converter.fromConnectData(TOPIC, Schema.BYTES_SCHEMA, 12); }
@Test public void testFromConnectNull() { assertNull(converter.fromConnectData(TOPIC, Schema.BYTES_SCHEMA, null)); }
|
KStreamTransformValues implements ProcessorSupplier<K, V> { @Override public Processor<K, V> get() { return new KStreamTransformValuesProcessor<>(valueTransformerSupplier.get()); } KStreamTransformValues(ValueTransformerSupplier<V, R> valueTransformerSupplier); @Override Processor<K, V> get(); }
|
@Test public void testTransform() { KStreamBuilder builder = new KStreamBuilder(); ValueTransformerSupplier<Number, Integer> valueTransformerSupplier = new ValueTransformerSupplier<Number, Integer>() { public ValueTransformer<Number, Integer> get() { return new ValueTransformer<Number, Integer>() { private int total = 0; @Override public void init(ProcessorContext context) { } @Override public Integer transform(Number value) { total += value.intValue(); return total; } @Override public Integer punctuate(long timestamp) { return null; } @Override public void close() { } }; } }; final int[] expectedKeys = {1, 10, 100, 1000}; KStream<Integer, Integer> stream; MockProcessorSupplier<Integer, Integer> processor = new MockProcessorSupplier<>(); stream = builder.stream(intSerde, intSerde, topicName); stream.transformValues(valueTransformerSupplier).process(processor); driver = new KStreamTestDriver(builder); for (int expectedKey : expectedKeys) { driver.process(topicName, expectedKey, expectedKey * 10); } assertEquals(4, processor.processed.size()); String[] expected = {"1:10", "10:110", "100:1110", "1000:11110"}; for (int i = 0; i < expected.length; i++) { assertEquals(expected[i], processor.processed.get(i)); } }
@Test public void shouldNotAllowValueTransformerToCallInternalProcessorContextMethods() { final KStreamTransformValues<Integer, Integer, Integer> transformValue = new KStreamTransformValues<>(new ValueTransformerSupplier<Integer, Integer>() { @Override public ValueTransformer<Integer, Integer> get() { return new BadValueTransformer(); } }); final Processor transformValueProcessor = transformValue.get(); transformValueProcessor.init(null); try { transformValueProcessor.process(null, 0); fail("should not allow call to context.forward() within ValueTransformer"); } catch (final StreamsException e) { } try { transformValueProcessor.process(null, 1); fail("should not allow call to context.forward() within ValueTransformer"); } catch (final StreamsException e) { } try { transformValueProcessor.process(null, 2); fail("should not allow call to context.forward() within ValueTransformer"); } catch (final StreamsException e) { } try { transformValueProcessor.punctuate(0); fail("should not allow ValueTransformer#puntuate() to return not-null value"); } catch (final StreamsException e) { } }
|
KStreamMapValues implements ProcessorSupplier<K, V> { @Override public Processor<K, V> get() { return new KStreamMapProcessor(); } KStreamMapValues(ValueMapper<V, V1> mapper); @Override Processor<K, V> get(); }
|
@Test public void testFlatMapValues() { KStreamBuilder builder = new KStreamBuilder(); ValueMapper<CharSequence, Integer> mapper = new ValueMapper<CharSequence, Integer>() { @Override public Integer apply(CharSequence value) { return value.length(); } }; final int[] expectedKeys = {1, 10, 100, 1000}; KStream<Integer, String> stream; MockProcessorSupplier<Integer, Integer> processor = new MockProcessorSupplier<>(); stream = builder.stream(intSerde, stringSerde, topicName); stream.mapValues(mapper).process(processor); driver = new KStreamTestDriver(builder); for (int expectedKey : expectedKeys) { driver.process(topicName, expectedKey, Integer.toString(expectedKey)); } assertEquals(4, processor.processed.size()); String[] expected = {"1:1", "10:2", "100:3", "1000:4"}; for (int i = 0; i < expected.length; i++) { assertEquals(expected[i], processor.processed.get(i)); } }
|
KGroupedStreamImpl extends AbstractStream<K> implements KGroupedStream<K, V> { @Override public KTable<K, V> reduce(final Reducer<V> reducer, final String queryableStoreName) { determineIsQueryable(queryableStoreName); return reduce(reducer, keyValueStore(keySerde, valSerde, getOrCreateName(queryableStoreName, REDUCE_NAME))); } KGroupedStreamImpl(final KStreamBuilder topology,
final String name,
final Set<String> sourceNodes,
final Serde<K> keySerde,
final Serde<V> valSerde,
final boolean repartitionRequired); @Override KTable<K, V> reduce(final Reducer<V> reducer,
final String queryableStoreName); @Override KTable<K, V> reduce(final Reducer<V> reducer); @Override KTable<K, V> reduce(final Reducer<V> reducer,
final StateStoreSupplier<KeyValueStore> storeSupplier); @SuppressWarnings("unchecked") @Override KTable<Windowed<K>, V> reduce(final Reducer<V> reducer,
final Windows<W> windows,
final String queryableStoreName); @SuppressWarnings("unchecked") @Override KTable<Windowed<K>, V> reduce(final Reducer<V> reducer,
final Windows<W> windows); @SuppressWarnings("unchecked") @Override KTable<Windowed<K>, V> reduce(final Reducer<V> reducer,
final Windows<W> windows,
final StateStoreSupplier<WindowStore> storeSupplier); @Override KTable<K, T> aggregate(final Initializer<T> initializer,
final Aggregator<? super K, ? super V, T> aggregator,
final Serde<T> aggValueSerde,
final String queryableStoreName); @Override KTable<K, T> aggregate(final Initializer<T> initializer,
final Aggregator<? super K, ? super V, T> aggregator,
final Serde<T> aggValueSerde); @Override KTable<K, T> aggregate(final Initializer<T> initializer,
final Aggregator<? super K, ? super V, T> aggregator,
final StateStoreSupplier<KeyValueStore> storeSupplier); @SuppressWarnings("unchecked") @Override KTable<Windowed<K>, T> aggregate(final Initializer<T> initializer,
final Aggregator<? super K, ? super V, T> aggregator,
final Windows<W> windows,
final Serde<T> aggValueSerde,
final String queryableStoreName); @SuppressWarnings("unchecked") @Override KTable<Windowed<K>, T> aggregate(final Initializer<T> initializer,
final Aggregator<? super K, ? super V, T> aggregator,
final Windows<W> windows,
final Serde<T> aggValueSerde); @SuppressWarnings("unchecked") @Override KTable<Windowed<K>, T> aggregate(final Initializer<T> initializer,
final Aggregator<? super K, ? super V, T> aggregator,
final Windows<W> windows,
final StateStoreSupplier<WindowStore> storeSupplier); @Override KTable<K, Long> count(final String queryableStoreName); @Override KTable<K, Long> count(); @Override KTable<K, Long> count(final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<Windowed<K>, Long> count(final Windows<W> windows,
final String queryableStoreName); @Override KTable<Windowed<K>, Long> count(final Windows<W> windows); @Override KTable<Windowed<K>, Long> count(final Windows<W> windows,
final StateStoreSupplier<WindowStore> storeSupplier); @SuppressWarnings("unchecked") @Override KTable<Windowed<K>, T> aggregate(final Initializer<T> initializer,
final Aggregator<? super K, ? super V, T> aggregator,
final Merger<? super K, T> sessionMerger,
final SessionWindows sessionWindows,
final Serde<T> aggValueSerde,
final String queryableStoreName); @SuppressWarnings("unchecked") @Override KTable<Windowed<K>, T> aggregate(final Initializer<T> initializer,
final Aggregator<? super K, ? super V, T> aggregator,
final Merger<? super K, T> sessionMerger,
final SessionWindows sessionWindows,
final Serde<T> aggValueSerde); @SuppressWarnings("unchecked") @Override KTable<Windowed<K>, T> aggregate(final Initializer<T> initializer,
final Aggregator<? super K, ? super V, T> aggregator,
final Merger<? super K, T> sessionMerger,
final SessionWindows sessionWindows,
final Serde<T> aggValueSerde,
final StateStoreSupplier<SessionStore> storeSupplier); @SuppressWarnings("unchecked") KTable<Windowed<K>, Long> count(final SessionWindows sessionWindows, final String queryableStoreName); KTable<Windowed<K>, Long> count(final SessionWindows sessionWindows); @SuppressWarnings("unchecked") @Override KTable<Windowed<K>, Long> count(final SessionWindows sessionWindows,
final StateStoreSupplier<SessionStore> storeSupplier); @SuppressWarnings("unchecked") @Override KTable<Windowed<K>, V> reduce(final Reducer<V> reducer,
final SessionWindows sessionWindows,
final String queryableStoreName); @SuppressWarnings("unchecked") @Override KTable<Windowed<K>, V> reduce(final Reducer<V> reducer,
final SessionWindows sessionWindows); @Override KTable<Windowed<K>, V> reduce(final Reducer<V> reducer,
final SessionWindows sessionWindows,
final StateStoreSupplier<SessionStore> storeSupplier); }
|
@Test(expected = NullPointerException.class) public void shouldNotHaveNullReducerOnReduce() throws Exception { groupedStream.reduce(null, "store"); }
@Test public void shouldAllowNullStoreNameOnReduce() throws Exception { groupedStream.reduce(MockReducer.STRING_ADDER, (String) null); }
@Test(expected = InvalidTopicException.class) public void shouldNotHaveInvalidStoreNameOnReduce() throws Exception { groupedStream.reduce(MockReducer.STRING_ADDER, INVALID_STORE_NAME); }
@Test(expected = NullPointerException.class) public void shouldNotHaveNullStoreSupplierOnReduce() throws Exception { groupedStream.reduce(MockReducer.STRING_ADDER, (StateStoreSupplier<KeyValueStore>) null); }
@Test(expected = NullPointerException.class) public void shouldNotHaveNullReducerWithWindowedReduce() throws Exception { groupedStream.reduce(null, TimeWindows.of(10), "store"); }
@Test(expected = NullPointerException.class) public void shouldNotHaveNullWindowsWithWindowedReduce() throws Exception { groupedStream.reduce(MockReducer.STRING_ADDER, (Windows) null, "store"); }
@Test public void shouldAllowNullStoreNameWithWindowedReduce() throws Exception { groupedStream.reduce(MockReducer.STRING_ADDER, TimeWindows.of(10), (String) null); }
@Test(expected = InvalidTopicException.class) public void shouldNotHaveInvalidStoreNameWithWindowedReduce() throws Exception { groupedStream.reduce(MockReducer.STRING_ADDER, TimeWindows.of(10), INVALID_STORE_NAME); }
@Test public void shouldReduceSessionWindows() throws Exception { final Map<Windowed<String>, String> results = new HashMap<>(); KTable table = groupedStream.reduce( new Reducer<String>() { @Override public String apply(final String value1, final String value2) { return value1 + ":" + value2; } }, SessionWindows.with(30), "session-store"); table.foreach(new ForeachAction<Windowed<String>, String>() { @Override public void apply(final Windowed<String> key, final String value) { results.put(key, value); } }); doReduceSessionWindows(results); assertEquals(table.queryableStoreName(), "session-store"); }
@Test public void shouldReduceSessionWindowsWithInternalStoreName() throws Exception { final Map<Windowed<String>, String> results = new HashMap<>(); KTable table = groupedStream.reduce( new Reducer<String>() { @Override public String apply(final String value1, final String value2) { return value1 + ":" + value2; } }, SessionWindows.with(30)); table.foreach(new ForeachAction<Windowed<String>, String>() { @Override public void apply(final Windowed<String> key, final String value) { results.put(key, value); } }); doReduceSessionWindows(results); assertNull(table.queryableStoreName()); }
@Test(expected = NullPointerException.class) public void shouldNotAcceptNullReducerWhenReducingSessionWindows() throws Exception { groupedStream.reduce(null, SessionWindows.with(10), "store"); }
@Test(expected = NullPointerException.class) public void shouldNotAcceptNullSessionWindowsReducingSessionWindows() throws Exception { groupedStream.reduce(MockReducer.STRING_ADDER, (SessionWindows) null, "store"); }
@Test public void shouldAcceptNullStoreNameWhenReducingSessionWindows() throws Exception { groupedStream.reduce(MockReducer.STRING_ADDER, SessionWindows.with(10), (String) null); }
@Test(expected = InvalidTopicException.class) public void shouldNotAcceptInvalidStoreNameWhenReducingSessionWindows() throws Exception { groupedStream.reduce(MockReducer.STRING_ADDER, SessionWindows.with(10), INVALID_STORE_NAME); }
@Test(expected = NullPointerException.class) public void shouldNotAcceptNullStateStoreSupplierWhenReducingSessionWindows() throws Exception { groupedStream.reduce(MockReducer.STRING_ADDER, SessionWindows.with(10), (StateStoreSupplier<SessionStore>) null); }
|
KGroupedStreamImpl extends AbstractStream<K> implements KGroupedStream<K, V> { @Override public KTable<K, Long> count(final String queryableStoreName) { determineIsQueryable(queryableStoreName); return count(keyValueStore(keySerde, Serdes.Long(), getOrCreateName(queryableStoreName, AGGREGATE_NAME))); } KGroupedStreamImpl(final KStreamBuilder topology,
final String name,
final Set<String> sourceNodes,
final Serde<K> keySerde,
final Serde<V> valSerde,
final boolean repartitionRequired); @Override KTable<K, V> reduce(final Reducer<V> reducer,
final String queryableStoreName); @Override KTable<K, V> reduce(final Reducer<V> reducer); @Override KTable<K, V> reduce(final Reducer<V> reducer,
final StateStoreSupplier<KeyValueStore> storeSupplier); @SuppressWarnings("unchecked") @Override KTable<Windowed<K>, V> reduce(final Reducer<V> reducer,
final Windows<W> windows,
final String queryableStoreName); @SuppressWarnings("unchecked") @Override KTable<Windowed<K>, V> reduce(final Reducer<V> reducer,
final Windows<W> windows); @SuppressWarnings("unchecked") @Override KTable<Windowed<K>, V> reduce(final Reducer<V> reducer,
final Windows<W> windows,
final StateStoreSupplier<WindowStore> storeSupplier); @Override KTable<K, T> aggregate(final Initializer<T> initializer,
final Aggregator<? super K, ? super V, T> aggregator,
final Serde<T> aggValueSerde,
final String queryableStoreName); @Override KTable<K, T> aggregate(final Initializer<T> initializer,
final Aggregator<? super K, ? super V, T> aggregator,
final Serde<T> aggValueSerde); @Override KTable<K, T> aggregate(final Initializer<T> initializer,
final Aggregator<? super K, ? super V, T> aggregator,
final StateStoreSupplier<KeyValueStore> storeSupplier); @SuppressWarnings("unchecked") @Override KTable<Windowed<K>, T> aggregate(final Initializer<T> initializer,
final Aggregator<? super K, ? super V, T> aggregator,
final Windows<W> windows,
final Serde<T> aggValueSerde,
final String queryableStoreName); @SuppressWarnings("unchecked") @Override KTable<Windowed<K>, T> aggregate(final Initializer<T> initializer,
final Aggregator<? super K, ? super V, T> aggregator,
final Windows<W> windows,
final Serde<T> aggValueSerde); @SuppressWarnings("unchecked") @Override KTable<Windowed<K>, T> aggregate(final Initializer<T> initializer,
final Aggregator<? super K, ? super V, T> aggregator,
final Windows<W> windows,
final StateStoreSupplier<WindowStore> storeSupplier); @Override KTable<K, Long> count(final String queryableStoreName); @Override KTable<K, Long> count(); @Override KTable<K, Long> count(final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<Windowed<K>, Long> count(final Windows<W> windows,
final String queryableStoreName); @Override KTable<Windowed<K>, Long> count(final Windows<W> windows); @Override KTable<Windowed<K>, Long> count(final Windows<W> windows,
final StateStoreSupplier<WindowStore> storeSupplier); @SuppressWarnings("unchecked") @Override KTable<Windowed<K>, T> aggregate(final Initializer<T> initializer,
final Aggregator<? super K, ? super V, T> aggregator,
final Merger<? super K, T> sessionMerger,
final SessionWindows sessionWindows,
final Serde<T> aggValueSerde,
final String queryableStoreName); @SuppressWarnings("unchecked") @Override KTable<Windowed<K>, T> aggregate(final Initializer<T> initializer,
final Aggregator<? super K, ? super V, T> aggregator,
final Merger<? super K, T> sessionMerger,
final SessionWindows sessionWindows,
final Serde<T> aggValueSerde); @SuppressWarnings("unchecked") @Override KTable<Windowed<K>, T> aggregate(final Initializer<T> initializer,
final Aggregator<? super K, ? super V, T> aggregator,
final Merger<? super K, T> sessionMerger,
final SessionWindows sessionWindows,
final Serde<T> aggValueSerde,
final StateStoreSupplier<SessionStore> storeSupplier); @SuppressWarnings("unchecked") KTable<Windowed<K>, Long> count(final SessionWindows sessionWindows, final String queryableStoreName); KTable<Windowed<K>, Long> count(final SessionWindows sessionWindows); @SuppressWarnings("unchecked") @Override KTable<Windowed<K>, Long> count(final SessionWindows sessionWindows,
final StateStoreSupplier<SessionStore> storeSupplier); @SuppressWarnings("unchecked") @Override KTable<Windowed<K>, V> reduce(final Reducer<V> reducer,
final SessionWindows sessionWindows,
final String queryableStoreName); @SuppressWarnings("unchecked") @Override KTable<Windowed<K>, V> reduce(final Reducer<V> reducer,
final SessionWindows sessionWindows); @Override KTable<Windowed<K>, V> reduce(final Reducer<V> reducer,
final SessionWindows sessionWindows,
final StateStoreSupplier<SessionStore> storeSupplier); }
|
@Test(expected = NullPointerException.class) public void shouldNotHaveNullStoreSupplierOnCount() throws Exception { groupedStream.count((StateStoreSupplier<KeyValueStore>) null); }
@Test(expected = NullPointerException.class) public void shouldNotHaveNullStoreSupplierOnWindowedCount() throws Exception { groupedStream.count(TimeWindows.of(10), (StateStoreSupplier<WindowStore>) null); }
@Test public void shouldCountSessionWindows() throws Exception { final Map<Windowed<String>, Long> results = new HashMap<>(); KTable table = groupedStream.count(SessionWindows.with(30), "session-store"); table.foreach(new ForeachAction<Windowed<String>, Long>() { @Override public void apply(final Windowed<String> key, final Long value) { results.put(key, value); } }); doCountSessionWindows(results); assertEquals(table.queryableStoreName(), "session-store"); }
@Test public void shouldCountSessionWindowsWithInternalStoreName() throws Exception { final Map<Windowed<String>, Long> results = new HashMap<>(); KTable table = groupedStream.count(SessionWindows.with(30)); table.foreach(new ForeachAction<Windowed<String>, Long>() { @Override public void apply(final Windowed<String> key, final Long value) { results.put(key, value); } }); doCountSessionWindows(results); assertNull(table.queryableStoreName()); }
@Test(expected = NullPointerException.class) public void shouldNotAcceptNullSessionWindowsWhenCountingSessionWindows() throws Exception { groupedStream.count((SessionWindows) null, "store"); }
@Test public void shouldAcceptNullStoreNameWhenCountingSessionWindows() throws Exception { groupedStream.count(SessionWindows.with(90), (String) null); }
@Test(expected = InvalidTopicException.class) public void shouldNotAcceptInvalidStoreNameWhenCountingSessionWindows() throws Exception { groupedStream.count(SessionWindows.with(90), INVALID_STORE_NAME); }
@Test(expected = NullPointerException.class) public void shouldNotAcceptNullStateStoreSupplierWhenCountingSessionWindows() throws Exception { groupedStream.count(SessionWindows.with(90), (StateStoreSupplier<SessionStore>) null); }
@Test public void shouldCountWindowed() throws Exception { final List<KeyValue<Windowed<String>, Long>> results = new ArrayList<>(); groupedStream.count( TimeWindows.of(500L), "aggregate-by-key-windowed") .foreach(new ForeachAction<Windowed<String>, Long>() { @Override public void apply(final Windowed<String> key, final Long value) { results.add(KeyValue.pair(key, value)); } }); doCountWindowed(results); }
@Test public void shouldCountWindowedWithInternalStoreName() throws Exception { final List<KeyValue<Windowed<String>, Long>> results = new ArrayList<>(); groupedStream.count( TimeWindows.of(500L)) .foreach(new ForeachAction<Windowed<String>, Long>() { @Override public void apply(final Windowed<String> key, final Long value) { results.add(KeyValue.pair(key, value)); } }); doCountWindowed(results); }
|
KGroupedStreamImpl extends AbstractStream<K> implements KGroupedStream<K, V> { @Override public <T> KTable<K, T> aggregate(final Initializer<T> initializer, final Aggregator<? super K, ? super V, T> aggregator, final Serde<T> aggValueSerde, final String queryableStoreName) { determineIsQueryable(queryableStoreName); return aggregate(initializer, aggregator, keyValueStore(keySerde, aggValueSerde, getOrCreateName(queryableStoreName, AGGREGATE_NAME))); } KGroupedStreamImpl(final KStreamBuilder topology,
final String name,
final Set<String> sourceNodes,
final Serde<K> keySerde,
final Serde<V> valSerde,
final boolean repartitionRequired); @Override KTable<K, V> reduce(final Reducer<V> reducer,
final String queryableStoreName); @Override KTable<K, V> reduce(final Reducer<V> reducer); @Override KTable<K, V> reduce(final Reducer<V> reducer,
final StateStoreSupplier<KeyValueStore> storeSupplier); @SuppressWarnings("unchecked") @Override KTable<Windowed<K>, V> reduce(final Reducer<V> reducer,
final Windows<W> windows,
final String queryableStoreName); @SuppressWarnings("unchecked") @Override KTable<Windowed<K>, V> reduce(final Reducer<V> reducer,
final Windows<W> windows); @SuppressWarnings("unchecked") @Override KTable<Windowed<K>, V> reduce(final Reducer<V> reducer,
final Windows<W> windows,
final StateStoreSupplier<WindowStore> storeSupplier); @Override KTable<K, T> aggregate(final Initializer<T> initializer,
final Aggregator<? super K, ? super V, T> aggregator,
final Serde<T> aggValueSerde,
final String queryableStoreName); @Override KTable<K, T> aggregate(final Initializer<T> initializer,
final Aggregator<? super K, ? super V, T> aggregator,
final Serde<T> aggValueSerde); @Override KTable<K, T> aggregate(final Initializer<T> initializer,
final Aggregator<? super K, ? super V, T> aggregator,
final StateStoreSupplier<KeyValueStore> storeSupplier); @SuppressWarnings("unchecked") @Override KTable<Windowed<K>, T> aggregate(final Initializer<T> initializer,
final Aggregator<? super K, ? super V, T> aggregator,
final Windows<W> windows,
final Serde<T> aggValueSerde,
final String queryableStoreName); @SuppressWarnings("unchecked") @Override KTable<Windowed<K>, T> aggregate(final Initializer<T> initializer,
final Aggregator<? super K, ? super V, T> aggregator,
final Windows<W> windows,
final Serde<T> aggValueSerde); @SuppressWarnings("unchecked") @Override KTable<Windowed<K>, T> aggregate(final Initializer<T> initializer,
final Aggregator<? super K, ? super V, T> aggregator,
final Windows<W> windows,
final StateStoreSupplier<WindowStore> storeSupplier); @Override KTable<K, Long> count(final String queryableStoreName); @Override KTable<K, Long> count(); @Override KTable<K, Long> count(final StateStoreSupplier<KeyValueStore> storeSupplier); @Override KTable<Windowed<K>, Long> count(final Windows<W> windows,
final String queryableStoreName); @Override KTable<Windowed<K>, Long> count(final Windows<W> windows); @Override KTable<Windowed<K>, Long> count(final Windows<W> windows,
final StateStoreSupplier<WindowStore> storeSupplier); @SuppressWarnings("unchecked") @Override KTable<Windowed<K>, T> aggregate(final Initializer<T> initializer,
final Aggregator<? super K, ? super V, T> aggregator,
final Merger<? super K, T> sessionMerger,
final SessionWindows sessionWindows,
final Serde<T> aggValueSerde,
final String queryableStoreName); @SuppressWarnings("unchecked") @Override KTable<Windowed<K>, T> aggregate(final Initializer<T> initializer,
final Aggregator<? super K, ? super V, T> aggregator,
final Merger<? super K, T> sessionMerger,
final SessionWindows sessionWindows,
final Serde<T> aggValueSerde); @SuppressWarnings("unchecked") @Override KTable<Windowed<K>, T> aggregate(final Initializer<T> initializer,
final Aggregator<? super K, ? super V, T> aggregator,
final Merger<? super K, T> sessionMerger,
final SessionWindows sessionWindows,
final Serde<T> aggValueSerde,
final StateStoreSupplier<SessionStore> storeSupplier); @SuppressWarnings("unchecked") KTable<Windowed<K>, Long> count(final SessionWindows sessionWindows, final String queryableStoreName); KTable<Windowed<K>, Long> count(final SessionWindows sessionWindows); @SuppressWarnings("unchecked") @Override KTable<Windowed<K>, Long> count(final SessionWindows sessionWindows,
final StateStoreSupplier<SessionStore> storeSupplier); @SuppressWarnings("unchecked") @Override KTable<Windowed<K>, V> reduce(final Reducer<V> reducer,
final SessionWindows sessionWindows,
final String queryableStoreName); @SuppressWarnings("unchecked") @Override KTable<Windowed<K>, V> reduce(final Reducer<V> reducer,
final SessionWindows sessionWindows); @Override KTable<Windowed<K>, V> reduce(final Reducer<V> reducer,
final SessionWindows sessionWindows,
final StateStoreSupplier<SessionStore> storeSupplier); }
|
@Test(expected = NullPointerException.class) public void shouldNotHaveNullInitializerOnAggregate() throws Exception { groupedStream.aggregate(null, MockAggregator.TOSTRING_ADDER, Serdes.String(), "store"); }
@Test(expected = NullPointerException.class) public void shouldNotHaveNullAdderOnAggregate() throws Exception { groupedStream.aggregate(MockInitializer.STRING_INIT, null, Serdes.String(), "store"); }
@Test public void shouldAllowNullStoreNameOnAggregate() throws Exception { groupedStream.aggregate(MockInitializer.STRING_INIT, MockAggregator.TOSTRING_ADDER, Serdes.String(), null); }
@Test(expected = InvalidTopicException.class) public void shouldNotHaveInvalidStoreNameOnAggregate() throws Exception { groupedStream.aggregate(MockInitializer.STRING_INIT, MockAggregator.TOSTRING_ADDER, Serdes.String(), INVALID_STORE_NAME); }
@Test(expected = NullPointerException.class) public void shouldNotHaveNullInitializerOnWindowedAggregate() throws Exception { groupedStream.aggregate(null, MockAggregator.TOSTRING_ADDER, TimeWindows.of(10), Serdes.String(), "store"); }
@Test(expected = NullPointerException.class) public void shouldNotHaveNullAdderOnWindowedAggregate() throws Exception { groupedStream.aggregate(MockInitializer.STRING_INIT, null, TimeWindows.of(10), Serdes.String(), "store"); }
@Test(expected = NullPointerException.class) public void shouldNotHaveNullWindowsOnWindowedAggregate() throws Exception { groupedStream.aggregate(MockInitializer.STRING_INIT, MockAggregator.TOSTRING_ADDER, null, Serdes.String(), "store"); }
@Test public void shouldAllowNullStoreNameOnWindowedAggregate() throws Exception { groupedStream.aggregate(MockInitializer.STRING_INIT, MockAggregator.TOSTRING_ADDER, TimeWindows.of(10), Serdes.String(), null); }
@Test(expected = InvalidTopicException.class) public void shouldNotHaveInvalidStoreNameOnWindowedAggregate() throws Exception { groupedStream.aggregate(MockInitializer.STRING_INIT, MockAggregator.TOSTRING_ADDER, TimeWindows.of(10), Serdes.String(), INVALID_STORE_NAME); }
@Test(expected = NullPointerException.class) public void shouldNotHaveNullStoreSupplierOnWindowedAggregate() throws Exception { groupedStream.aggregate(MockInitializer.STRING_INIT, MockAggregator.TOSTRING_ADDER, TimeWindows.of(10), (StateStoreSupplier<WindowStore>) null); }
@Test public void shouldAggregateSessionWindows() throws Exception { final Map<Windowed<String>, Integer> results = new HashMap<>(); KTable table = groupedStream.aggregate(new Initializer<Integer>() { @Override public Integer apply() { return 0; } }, new Aggregator<String, String, Integer>() { @Override public Integer apply(final String aggKey, final String value, final Integer aggregate) { return aggregate + 1; } }, new Merger<String, Integer>() { @Override public Integer apply(final String aggKey, final Integer aggOne, final Integer aggTwo) { return aggOne + aggTwo; } }, SessionWindows.with(30), Serdes.Integer(), "session-store"); table.foreach(new ForeachAction<Windowed<String>, Integer>() { @Override public void apply(final Windowed<String> key, final Integer value) { results.put(key, value); } }); doAggregateSessionWindows(results); assertEquals(table.queryableStoreName(), "session-store"); }
@Test public void shouldAggregateSessionWindowsWithInternalStoreName() throws Exception { final Map<Windowed<String>, Integer> results = new HashMap<>(); KTable table = groupedStream.aggregate(new Initializer<Integer>() { @Override public Integer apply() { return 0; } }, new Aggregator<String, String, Integer>() { @Override public Integer apply(final String aggKey, final String value, final Integer aggregate) { return aggregate + 1; } }, new Merger<String, Integer>() { @Override public Integer apply(final String aggKey, final Integer aggOne, final Integer aggTwo) { return aggOne + aggTwo; } }, SessionWindows.with(30), Serdes.Integer()); table.foreach(new ForeachAction<Windowed<String>, Integer>() { @Override public void apply(final Windowed<String> key, final Integer value) { results.put(key, value); } }); doAggregateSessionWindows(results); assertNull(table.queryableStoreName()); }
@Test(expected = NullPointerException.class) public void shouldNotAcceptNullInitializerWhenAggregatingSessionWindows() throws Exception { groupedStream.aggregate(null, MockAggregator.TOSTRING_ADDER, new Merger<String, String>() { @Override public String apply(final String aggKey, final String aggOne, final String aggTwo) { return null; } }, SessionWindows.with(10), Serdes.String(), "storeName"); }
@Test(expected = NullPointerException.class) public void shouldNotAcceptNullAggregatorWhenAggregatingSessionWindows() throws Exception { groupedStream.aggregate(MockInitializer.STRING_INIT, null, new Merger<String, String>() { @Override public String apply(final String aggKey, final String aggOne, final String aggTwo) { return null; } }, SessionWindows.with(10), Serdes.String(), "storeName"); }
@Test(expected = NullPointerException.class) public void shouldNotAcceptNullSessionMergerWhenAggregatingSessionWindows() throws Exception { groupedStream.aggregate(MockInitializer.STRING_INIT, MockAggregator.TOSTRING_ADDER, null, SessionWindows.with(10), Serdes.String(), "storeName"); }
@Test(expected = NullPointerException.class) public void shouldNotAcceptNullSessionWindowsWhenAggregatingSessionWindows() throws Exception { groupedStream.aggregate(MockInitializer.STRING_INIT, MockAggregator.TOSTRING_ADDER, new Merger<String, String>() { @Override public String apply(final String aggKey, final String aggOne, final String aggTwo) { return null; } }, null, Serdes.String(), "storeName"); }
@Test public void shouldAcceptNullStoreNameWhenAggregatingSessionWindows() throws Exception { groupedStream.aggregate(MockInitializer.STRING_INIT, MockAggregator.TOSTRING_ADDER, new Merger<String, String>() { @Override public String apply(final String aggKey, final String aggOne, final String aggTwo) { return null; } }, SessionWindows.with(10), Serdes.String(), (String) null); }
@Test(expected = InvalidTopicException.class) public void shouldNotAcceptInvalidStoreNameWhenAggregatingSessionWindows() throws Exception { groupedStream.aggregate(MockInitializer.STRING_INIT, MockAggregator.TOSTRING_ADDER, new Merger<String, String>() { @Override public String apply(final String aggKey, final String aggOne, final String aggTwo) { return null; } }, SessionWindows.with(10), Serdes.String(), INVALID_STORE_NAME); }
@Test(expected = NullPointerException.class) public void shouldNotAcceptNullStateStoreSupplierNameWhenAggregatingSessionWindows() throws Exception { groupedStream.aggregate(MockInitializer.STRING_INIT, MockAggregator.TOSTRING_ADDER, new Merger<String, String>() { @Override public String apply(final String aggKey, final String aggOne, final String aggTwo) { return null; } }, SessionWindows.with(10), Serdes.String(), (StateStoreSupplier<SessionStore>) null); }
|
ByteArrayConverter implements Converter { @Override public SchemaAndValue toConnectData(String topic, byte[] value) { return new SchemaAndValue(Schema.OPTIONAL_BYTES_SCHEMA, value); } @Override void configure(Map<String, ?> configs, boolean isKey); @Override byte[] fromConnectData(String topic, Schema schema, Object value); @Override SchemaAndValue toConnectData(String topic, byte[] value); }
|
@Test public void testToConnect() { SchemaAndValue data = converter.toConnectData(TOPIC, SAMPLE_BYTES); assertEquals(Schema.OPTIONAL_BYTES_SCHEMA, data.schema()); assertTrue(Arrays.equals(SAMPLE_BYTES, (byte[]) data.value())); }
@Test public void testToConnectNull() { SchemaAndValue data = converter.toConnectData(TOPIC, null); assertEquals(Schema.OPTIONAL_BYTES_SCHEMA, data.schema()); assertNull(data.value()); }
|
SessionWindows { public static SessionWindows with(final long inactivityGapMs) { if (inactivityGapMs <= 0) { throw new IllegalArgumentException("Gap time (inactivityGapMs) cannot be zero or negative."); } return new SessionWindows(inactivityGapMs); } private SessionWindows(final long gapMs); static SessionWindows with(final long inactivityGapMs); SessionWindows until(final long durationMs); long inactivityGap(); long maintainMs(); }
|
@Test(expected = IllegalArgumentException.class) public void windowSizeMustNotBeNegative() { SessionWindows.with(-1); }
@Test(expected = IllegalArgumentException.class) public void windowSizeMustNotBeZero() { SessionWindows.with(0); }
|
JoinWindows extends Windows<Window> { public static JoinWindows of(final long timeDifferenceMs) throws IllegalArgumentException { return new JoinWindows(timeDifferenceMs, timeDifferenceMs); } private JoinWindows(final long beforeMs, final long afterMs); static JoinWindows of(final long timeDifferenceMs); JoinWindows before(final long timeDifferenceMs); JoinWindows after(final long timeDifferenceMs); @Override Map<Long, Window> windowsFor(final long timestamp); @Override long size(); @Override JoinWindows until(final long durationMs); @Override long maintainMs(); @Override final boolean equals(final Object o); @Override int hashCode(); final long beforeMs; final long afterMs; }
|
@Test(expected = IllegalArgumentException.class) public void timeDifferenceMustNotBeNegative() { JoinWindows.of(-1); }
|
DefaultPartitionGrouper implements PartitionGrouper { public Map<TaskId, Set<TopicPartition>> partitionGroups(Map<Integer, Set<String>> topicGroups, Cluster metadata) { Map<TaskId, Set<TopicPartition>> groups = new HashMap<>(); for (Map.Entry<Integer, Set<String>> entry : topicGroups.entrySet()) { Integer topicGroupId = entry.getKey(); Set<String> topicGroup = entry.getValue(); int maxNumPartitions = maxNumPartitions(metadata, topicGroup); for (int partitionId = 0; partitionId < maxNumPartitions; partitionId++) { Set<TopicPartition> group = new HashSet<>(topicGroup.size()); for (String topic : topicGroup) { List<PartitionInfo> partitions = metadata.partitionsForTopic(topic); if (partitionId < partitions.size()) { group.add(new TopicPartition(topic, partitionId)); } } groups.put(new TaskId(topicGroupId, partitionId), Collections.unmodifiableSet(group)); } } return Collections.unmodifiableMap(groups); } Map<TaskId, Set<TopicPartition>> partitionGroups(Map<Integer, Set<String>> topicGroups, Cluster metadata); }
|
@Test public void shouldComputeGroupingForTwoGroups() { final PartitionGrouper grouper = new DefaultPartitionGrouper(); final Map<TaskId, Set<TopicPartition>> expectedPartitionsForTask = new HashMap<>(); final Map<Integer, Set<String>> topicGroups = new HashMap<>(); int topicGroupId = 0; topicGroups.put(topicGroupId, mkSet("topic1")); expectedPartitionsForTask.put(new TaskId(topicGroupId, 0), mkSet(new TopicPartition("topic1", 0))); expectedPartitionsForTask.put(new TaskId(topicGroupId, 1), mkSet(new TopicPartition("topic1", 1))); expectedPartitionsForTask.put(new TaskId(topicGroupId, 2), mkSet(new TopicPartition("topic1", 2))); topicGroups.put(++topicGroupId, mkSet("topic2")); expectedPartitionsForTask.put(new TaskId(topicGroupId, 0), mkSet(new TopicPartition("topic2", 0))); expectedPartitionsForTask.put(new TaskId(topicGroupId, 1), mkSet(new TopicPartition("topic2", 1))); assertEquals(expectedPartitionsForTask, grouper.partitionGroups(topicGroups, metadata)); }
@Test public void shouldComputeGroupingForSingleGroupWithMultipleTopics() { final PartitionGrouper grouper = new DefaultPartitionGrouper(); final Map<TaskId, Set<TopicPartition>> expectedPartitionsForTask = new HashMap<>(); final Map<Integer, Set<String>> topicGroups = new HashMap<>(); final int topicGroupId = 0; topicGroups.put(topicGroupId, mkSet("topic1", "topic2")); expectedPartitionsForTask.put( new TaskId(topicGroupId, 0), mkSet(new TopicPartition("topic1", 0), new TopicPartition("topic2", 0))); expectedPartitionsForTask.put( new TaskId(topicGroupId, 1), mkSet(new TopicPartition("topic1", 1), new TopicPartition("topic2", 1))); expectedPartitionsForTask.put( new TaskId(topicGroupId, 2), mkSet(new TopicPartition("topic1", 2))); assertEquals(expectedPartitionsForTask, grouper.partitionGroups(topicGroups, metadata)); }
@Test public void shouldNotCreateAnyTasksBecauseOneTopicHasUnknownPartitions() { final PartitionGrouper grouper = new DefaultPartitionGrouper(); final Map<TaskId, Set<TopicPartition>> expectedPartitionsForTask = new HashMap<>(); final Map<Integer, Set<String>> topicGroups = new HashMap<>(); final int topicGroupId = 0; topicGroups.put(topicGroupId, mkSet("topic1", "unknownTopic", "topic2")); assertEquals(expectedPartitionsForTask, grouper.partitionGroups(topicGroups, metadata)); }
|
WallclockTimestampExtractor implements TimestampExtractor { @Override public long extract(final ConsumerRecord<Object, Object> record, final long previousTimestamp) { return System.currentTimeMillis(); } @Override long extract(final ConsumerRecord<Object, Object> record, final long previousTimestamp); }
|
@Test public void extractSystemTimestamp() { final TimestampExtractor extractor = new WallclockTimestampExtractor(); final long before = System.currentTimeMillis(); final long timestamp = extractor.extract(new ConsumerRecord<>("anyTopic", 0, 0, null, null), 42); final long after = System.currentTimeMillis(); assertThat(timestamp, is(new InBetween(before, after))); }
|
StateRestorer { void restore(final byte[] key, final byte[] value) { stateRestoreCallback.restore(key, value); } StateRestorer(final TopicPartition partition,
final StateRestoreCallback stateRestoreCallback,
final Long checkpoint,
final long offsetLimit,
final boolean persistent); TopicPartition partition(); }
|
@Test public void shouldCallRestoreOnRestoreCallback() throws Exception { restorer.restore(new byte[0], new byte[0]); assertThat(callback.restored.size(), equalTo(1)); }
|
StateRestorer { boolean hasCompleted(final long recordOffset, final long endOffset) { return endOffset == 0 || recordOffset >= readTo(endOffset); } StateRestorer(final TopicPartition partition,
final StateRestoreCallback stateRestoreCallback,
final Long checkpoint,
final long offsetLimit,
final boolean persistent); TopicPartition partition(); }
|
@Test public void shouldBeCompletedIfRecordOffsetGreaterThanEndOffset() throws Exception { assertTrue(restorer.hasCompleted(11, 10)); }
@Test public void shouldBeCompletedIfRecordOffsetGreaterThanOffsetLimit() throws Exception { assertTrue(restorer.hasCompleted(51, 100)); }
@Test public void shouldBeCompletedIfEndOffsetAndRecordOffsetAreZero() throws Exception { assertTrue(restorer.hasCompleted(0, 0)); }
@Test public void shouldBeCompletedIfOffsetAndOffsetLimitAreZero() throws Exception { final StateRestorer restorer = new StateRestorer(new TopicPartition("topic", 1), callback, null, 0, true); assertTrue(restorer.hasCompleted(0, 10)); }
|
AbstractProcessorContext implements InternalProcessorContext { @Override public void register(final StateStore store, final boolean loggingEnabled, final StateRestoreCallback stateRestoreCallback) { if (initialized) { throw new IllegalStateException("Can only create state stores during initialization."); } Objects.requireNonNull(store, "store must not be null"); stateManager.register(store, loggingEnabled, stateRestoreCallback); } AbstractProcessorContext(final TaskId taskId,
final String applicationId,
final StreamsConfig config,
final StreamsMetrics metrics,
final StateManager stateManager,
final ThreadCache cache); @Override String applicationId(); @Override TaskId taskId(); @Override Serde<?> keySerde(); @Override Serde<?> valueSerde(); @Override File stateDir(); @Override StreamsMetrics metrics(); @Override void register(final StateStore store, final boolean loggingEnabled, final StateRestoreCallback stateRestoreCallback); @Override String topic(); @Override int partition(); @Override long offset(); @Override long timestamp(); @Override Map<String, Object> appConfigs(); @Override Map<String, Object> appConfigsWithPrefix(String prefix); @Override void setRecordContext(final RecordContext recordContext); @Override RecordContext recordContext(); @Override void setCurrentNode(final ProcessorNode currentNode); @Override ProcessorNode currentNode(); @Override ThreadCache getCache(); @Override void initialized(); }
|
@Test public void shouldNotThrowIllegalStateExceptionOnRegisterWhenContextIsNotInitialized() throws Exception { context.register(stateStore, false, null); }
@Test(expected = NullPointerException.class) public void shouldThrowNullPointerOnRegisterIfStateStoreIsNull() { context.register(null, false, null); }
|
AbstractProcessorContext implements InternalProcessorContext { @Override public String topic() { if (recordContext == null) { throw new IllegalStateException("This should not happen as topic() should only be called while a record is processed"); } final String topic = recordContext.topic(); if (topic.equals(NONEXIST_TOPIC)) { return null; } return topic; } AbstractProcessorContext(final TaskId taskId,
final String applicationId,
final StreamsConfig config,
final StreamsMetrics metrics,
final StateManager stateManager,
final ThreadCache cache); @Override String applicationId(); @Override TaskId taskId(); @Override Serde<?> keySerde(); @Override Serde<?> valueSerde(); @Override File stateDir(); @Override StreamsMetrics metrics(); @Override void register(final StateStore store, final boolean loggingEnabled, final StateRestoreCallback stateRestoreCallback); @Override String topic(); @Override int partition(); @Override long offset(); @Override long timestamp(); @Override Map<String, Object> appConfigs(); @Override Map<String, Object> appConfigsWithPrefix(String prefix); @Override void setRecordContext(final RecordContext recordContext); @Override RecordContext recordContext(); @Override void setCurrentNode(final ProcessorNode currentNode); @Override ProcessorNode currentNode(); @Override ThreadCache getCache(); @Override void initialized(); }
|
@Test public void shouldReturnTopicFromRecordContext() throws Exception { assertThat(context.topic(), equalTo(recordContext.topic())); }
|
AbstractProcessorContext implements InternalProcessorContext { @Override public int partition() { if (recordContext == null) { throw new IllegalStateException("This should not happen as partition() should only be called while a record is processed"); } return recordContext.partition(); } AbstractProcessorContext(final TaskId taskId,
final String applicationId,
final StreamsConfig config,
final StreamsMetrics metrics,
final StateManager stateManager,
final ThreadCache cache); @Override String applicationId(); @Override TaskId taskId(); @Override Serde<?> keySerde(); @Override Serde<?> valueSerde(); @Override File stateDir(); @Override StreamsMetrics metrics(); @Override void register(final StateStore store, final boolean loggingEnabled, final StateRestoreCallback stateRestoreCallback); @Override String topic(); @Override int partition(); @Override long offset(); @Override long timestamp(); @Override Map<String, Object> appConfigs(); @Override Map<String, Object> appConfigsWithPrefix(String prefix); @Override void setRecordContext(final RecordContext recordContext); @Override RecordContext recordContext(); @Override void setCurrentNode(final ProcessorNode currentNode); @Override ProcessorNode currentNode(); @Override ThreadCache getCache(); @Override void initialized(); }
|
@Test public void shouldReturnPartitionFromRecordContext() throws Exception { assertThat(context.partition(), equalTo(recordContext.partition())); }
|
AbstractProcessorContext implements InternalProcessorContext { @Override public long offset() { if (recordContext == null) { throw new IllegalStateException("This should not happen as offset() should only be called while a record is processed"); } return recordContext.offset(); } AbstractProcessorContext(final TaskId taskId,
final String applicationId,
final StreamsConfig config,
final StreamsMetrics metrics,
final StateManager stateManager,
final ThreadCache cache); @Override String applicationId(); @Override TaskId taskId(); @Override Serde<?> keySerde(); @Override Serde<?> valueSerde(); @Override File stateDir(); @Override StreamsMetrics metrics(); @Override void register(final StateStore store, final boolean loggingEnabled, final StateRestoreCallback stateRestoreCallback); @Override String topic(); @Override int partition(); @Override long offset(); @Override long timestamp(); @Override Map<String, Object> appConfigs(); @Override Map<String, Object> appConfigsWithPrefix(String prefix); @Override void setRecordContext(final RecordContext recordContext); @Override RecordContext recordContext(); @Override void setCurrentNode(final ProcessorNode currentNode); @Override ProcessorNode currentNode(); @Override ThreadCache getCache(); @Override void initialized(); }
|
@Test public void shouldReturnOffsetFromRecordContext() throws Exception { assertThat(context.offset(), equalTo(recordContext.offset())); }
|
AbstractProcessorContext implements InternalProcessorContext { @Override public long timestamp() { if (recordContext == null) { throw new IllegalStateException("This should not happen as timestamp() should only be called while a record is processed"); } return recordContext.timestamp(); } AbstractProcessorContext(final TaskId taskId,
final String applicationId,
final StreamsConfig config,
final StreamsMetrics metrics,
final StateManager stateManager,
final ThreadCache cache); @Override String applicationId(); @Override TaskId taskId(); @Override Serde<?> keySerde(); @Override Serde<?> valueSerde(); @Override File stateDir(); @Override StreamsMetrics metrics(); @Override void register(final StateStore store, final boolean loggingEnabled, final StateRestoreCallback stateRestoreCallback); @Override String topic(); @Override int partition(); @Override long offset(); @Override long timestamp(); @Override Map<String, Object> appConfigs(); @Override Map<String, Object> appConfigsWithPrefix(String prefix); @Override void setRecordContext(final RecordContext recordContext); @Override RecordContext recordContext(); @Override void setCurrentNode(final ProcessorNode currentNode); @Override ProcessorNode currentNode(); @Override ThreadCache getCache(); @Override void initialized(); }
|
@Test public void shouldReturnTimestampFromRecordContext() throws Exception { assertThat(context.timestamp(), equalTo(recordContext.timestamp())); }
|
TopicAdmin implements AutoCloseable { public boolean createTopic(NewTopic topic) { if (topic == null) return false; Set<String> newTopicNames = createTopics(topic); return newTopicNames.contains(topic.name()); } TopicAdmin(Map<String, Object> adminConfig); TopicAdmin(Map<String, Object> adminConfig, AdminClient adminClient); static NewTopicBuilder defineTopic(String topicName); boolean createTopic(NewTopic topic); Set<String> createTopics(NewTopic... topics); @Override void close(); }
|
@Test public void shouldReturnFalseWhenSuppliedNullTopicDescription() { Cluster cluster = createCluster(1); try (MockKafkaAdminClientEnv env = new MockKafkaAdminClientEnv(cluster)) { env.kafkaClient().setNode(cluster.controller()); env.kafkaClient().setNodeApiVersions(NodeApiVersions.create()); env.kafkaClient().prepareMetadataUpdate(env.cluster(), Collections.<String>emptySet()); TopicAdmin admin = new TopicAdmin(null, env.adminClient()); boolean created = admin.createTopic(null); assertFalse(created); } }
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.