本文整理汇总了Java中org.apache.kafka.streams.state.KeyValueIterator.next方法的典型用法代码示例。如果您正苦于以下问题:Java KeyValueIterator.next方法的具体用法?Java KeyValueIterator.next怎么用?Java KeyValueIterator.next使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.kafka.streams.state.KeyValueIterator
的用法示例。
在下文中一共展示了KeyValueIterator.next方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getLocalMetrics
import org.apache.kafka.streams.state.KeyValueIterator; //导入方法依赖的package包/类
/**
* Query local state store to extract metrics
*
* @return local Metrics
*/
private Metrics getLocalMetrics() {
HostInfo thisInstance = GlobalAppState.getInstance().getHostPortInfo();
KafkaStreams ks = GlobalAppState.getInstance().getKafkaStreams();
String source = thisInstance.host() + ":" + thisInstance.port();
Metrics localMetrics = new Metrics();
ReadOnlyKeyValueStore<String, Double> averageStore = ks
.store(storeName,
QueryableStoreTypes.<String, Double>keyValueStore());
LOGGER.log(Level.INFO, "Entries in store {0}", averageStore.approximateNumEntries());
KeyValueIterator<String, Double> storeIterator = averageStore.all();
while (storeIterator.hasNext()) {
KeyValue<String, Double> kv = storeIterator.next();
localMetrics.add(source, kv.key, String.valueOf(kv.value));
}
LOGGER.log(Level.INFO, "Local store state {0}", localMetrics);
return localMetrics;
}
示例2: hasNextCondition
import org.apache.kafka.streams.state.KeyValueIterator; //导入方法依赖的package包/类
@Override
public HasNextCondition hasNextCondition(final Bytes binaryKeyFrom, final Bytes binaryKeyTo, final long from, final long to) {
return new HasNextCondition() {
@Override
public boolean hasNext(final KeyValueIterator<Bytes, ?> iterator) {
while (iterator.hasNext()) {
final Bytes bytes = iterator.peekNextKey();
final Bytes keyBytes = WindowStoreUtils.bytesKeyFromBinaryKey(bytes.get());
final long time = WindowStoreUtils.timestampFromBinaryKey(bytes.get());
if (keyBytes.compareTo(binaryKeyFrom) >= 0
&& keyBytes.compareTo(binaryKeyTo) <= 0
&& time >= from
&& time <= to) {
return true;
}
iterator.next();
}
return false;
}
};
}
示例3: hasNextCondition
import org.apache.kafka.streams.state.KeyValueIterator; //导入方法依赖的package包/类
@Override
public HasNextCondition hasNextCondition(final Bytes binaryKeyFrom, final Bytes binaryKeyTo, final long from, final long to) {
return new HasNextCondition() {
@Override
public boolean hasNext(final KeyValueIterator<Bytes, ?> iterator) {
while (iterator.hasNext()) {
final Bytes bytes = iterator.peekNextKey();
final Windowed<Bytes> windowedKey = SessionKeySerde.fromBytes(bytes);
if (windowedKey.key().compareTo(binaryKeyFrom) >= 0
&& windowedKey.key().compareTo(binaryKeyTo) <= 0
&& windowedKey.window().end() >= from
&& windowedKey.window().start() <= to) {
return true;
}
iterator.next();
}
return false;
}
};
}
示例4: shouldMergeSessions
import org.apache.kafka.streams.state.KeyValueIterator; //导入方法依赖的package包/类
@Test
public void shouldMergeSessions() throws Exception {
context.setTime(0);
final String sessionId = "mel";
processor.process(sessionId, "first");
assertTrue(sessionStore.findSessions(sessionId, 0, 0).hasNext());
// move time beyond gap
context.setTime(GAP_MS + 1);
processor.process(sessionId, "second");
assertTrue(sessionStore.findSessions(sessionId, GAP_MS + 1, GAP_MS + 1).hasNext());
// should still exist as not within gap
assertTrue(sessionStore.findSessions(sessionId, 0, 0).hasNext());
// move time back
context.setTime(GAP_MS / 2);
processor.process(sessionId, "third");
final KeyValueIterator<Windowed<String>, Long> iterator = sessionStore.findSessions(sessionId, 0, GAP_MS + 1);
final KeyValue<Windowed<String>, Long> kv = iterator.next();
assertEquals(Long.valueOf(3), kv.value);
assertFalse(iterator.hasNext());
}
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:24,代码来源:KStreamSessionWindowAggregateProcessorTest.java
示例5: punctuate
import org.apache.kafka.streams.state.KeyValueIterator; //导入方法依赖的package包/类
@Override
public void punctuate(long timestamp) {
KeyValueIterator<Long, List<OrderGoods>> iter = this.kvStore.all();
while (iter.hasNext()) {
KeyValue<Long, List<OrderGoods>> entry = (KeyValue<Long, List<OrderGoods>>) iter.next();
context.forward(entry.key, entry.value.toString());
}
iter.close();
context.commit();
}
示例6: shouldFlushEvictedItemsIntoUnderlyingStore
import org.apache.kafka.streams.state.KeyValueIterator; //导入方法依赖的package包/类
@Test
public void shouldFlushEvictedItemsIntoUnderlyingStore() throws Exception {
int added = addItemsToCache();
// all dirty entries should have been flushed
final KeyValueIterator<Bytes, byte[]> iter = underlying.fetch(Bytes.wrap("0".getBytes()), DEFAULT_TIMESTAMP, DEFAULT_TIMESTAMP);
final KeyValue<Bytes, byte[]> next = iter.next();
assertEquals(DEFAULT_TIMESTAMP, keySchema.segmentTimestamp(next.key));
assertArrayEquals("0".getBytes(), next.value);
assertFalse(iter.hasNext());
assertEquals(added - 1, cache.size());
}
示例7: shouldFlushItemsToStoreOnEviction
import org.apache.kafka.streams.state.KeyValueIterator; //导入方法依赖的package包/类
@Test
public void shouldFlushItemsToStoreOnEviction() throws Exception {
final List<KeyValue<Windowed<String>, Long>> added = addSessionsUntilOverflow("a", "b", "c", "d");
assertEquals(added.size() - 1, cache.size());
final KeyValueIterator<Bytes, byte[]> iterator = underlying.fetch(Bytes.wrap(added.get(0).key.key().getBytes()), 0, 0);
final KeyValue<Bytes, byte[]> next = iterator.next();
assertEquals(added.get(0).key, SessionKeySerde.from(next.key.get(), Serdes.String().deserializer(), "dummy"));
assertArrayEquals(serdes.rawValue(added.get(0).value), next.value);
}
示例8: toList
import org.apache.kafka.streams.state.KeyValueIterator; //导入方法依赖的package包/类
private List<KeyValue<Windowed<String>, Long>> toList(final KeyValueIterator<Bytes, byte[]> iterator) {
final List<KeyValue<Windowed<String>, Long>> results = new ArrayList<>();
while (iterator.hasNext()) {
final KeyValue<Bytes, byte[]> next = iterator.next();
final KeyValue<Windowed<String>, Long> deserialized
= KeyValue.pair(SessionKeySerde.from(next.key.get(), Serdes.String().deserializer(), "dummy"), Serdes.Long().deserializer().deserialize("", next.value));
results.add(deserialized);
}
return results;
}
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:11,代码来源:RocksDBSegmentedBytesStoreTest.java