[
https://issues.apache.org/jira/browse/SAMZA-94?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13838432#comment-13838432
]
Jay Kreps commented on SAMZA-94:
--------------------------------
Yeah my intention was that null was not a valid value and that put(k, null) is
defined to be the same as delete. If you guys think this is confusing (I kind
of agree) I recommend we just make put(k, null) be a hard error. In other words
null is not in the set of things that can be stored by the key value store (the
fact that internally the logging store logs a null for deletes is just an
implementation detail).
Specifically what I mean is that we change the implementation of
SerializedKeyValueStore to
{code}
def put(key: K, value: V) {
val keyBytes = keySerde.toBytes(key)
if(keyBytes == null) throw new NullPointerException("null is not a valid
key.")
val valBytes = msgSerde.toBytes(value)
if(valBytes == null) throw new NullPointerException("null is not a valid
value.")
store.put(keyBytes, valBytes)
}
{code}
> State management kv-store delete() does not remove key
> ------------------------------------------------------
>
> Key: SAMZA-94
> URL: https://issues.apache.org/jira/browse/SAMZA-94
> Project: Samza
> Issue Type: Bug
> Components: kv
> Affects Versions: 0.6.0
> Reporter: Alan Li
> Assignee: Chris Riccomini
> Fix For: 0.7.0
>
>
> Sample code snippet:
> {noformat}
> _realtimeStateStore.put("foo", new HashMap());
>
> KeyValueIterator<String, Map<String, State>> realtimeIterator =
> _realtimeStateStore.all();
> while (realtimeIterator.hasNext())
> {
> Entry<String, Map<String, State>> entry = realtimeIterator.next();
> System.out.println("read from leveldb: " + entry.getKey() + "=>" +
> entry.getValue());
> }
> realtimeIterator.close();
>
> _realtimeStateStore.delete("foo");
>
> KeyValueIterator<String, Map<String, State>> iter =
> _realtimeStateStore.all();
> while (iter.hasNext())
> {
> Entry<String, Map<String, State>> entry = iter.next();
> System.out.println("read from leveldb: " + entry.getKey() + "=>" +
> entry.getValue());
> }
> iter.close();
> {noformat}
> Output:
> read from leveldb: foo=>{}
> read from leveldb: foo=>null
> I would expect that the kv would remove both the key & value on delete so
> that subsequent iterators will not return keys that have been deleted.
--
This message was sent by Atlassian JIRA
(v6.1#6144)