当前位置: 首页>>代码示例>>Java>>正文


Java KeyValueStore.put方法代码示例

本文整理汇总了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();
}
 
开发者ID:apache,项目名称:samza,代码行数:21,代码来源:PartialJoinOperatorImpl.java

示例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));
}
 
开发者ID:theduderog,项目名称:hello-samza-confluent,代码行数:7,代码来源:InMemoryTaskContextTest.java


注:本文中的org.apache.samza.storage.kv.KeyValueStore.put方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。