本文整理汇总了Java中org.apache.samza.storage.kv.KeyValueStore.put方法的典型用法代码示例。如果您正苦于以下问题:Java KeyValueStore.put方法的具体用法?Java KeyValueStore.put怎么用?Java KeyValueStore.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.samza.storage.kv.KeyValueStore
的用法示例。
在下文中一共展示了KeyValueStore.put方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleMessage
import org.apache.samza.storage.kv.KeyValueStore; //导入方法依赖的package包/类
@Override
public Collection<JM> handleMessage(M message, MessageCollector collector, TaskCoordinator coordinator) {
try {
KeyValueStore<K, TimestampedValue<M>> thisState = thisPartialJoinFn.getState();
KeyValueStore<K, TimestampedValue<OM>> otherState = otherPartialJoinFn.getState();
K key = thisPartialJoinFn.getKey(message);
thisState.put(key, new TimestampedValue<>(message, clock.currentTimeMillis()));
TimestampedValue<OM> otherMessage = otherState.get(key);
long now = clock.currentTimeMillis();
if (otherMessage != null && otherMessage.getTimestamp() > now - ttlMs) {
JM joinResult = thisPartialJoinFn.apply(message, otherMessage.getValue());
return Collections.singletonList(joinResult);
}
} catch (Exception e) {
throw new SamzaException("Error handling message in PartialJoinOperatorImpl " + getOpImplId(), e);
}
return Collections.emptyList();
}
示例2: testStore
import org.apache.samza.storage.kv.KeyValueStore; //导入方法依赖的package包/类
@Test
public void testStore() {
KeyValueStore<String, String> store = taskContext.getStore(testString);
store.put(testString, testString);
assertEquals(taskContext.getStore(testString).get(testString), store.get(testString));
}