Repository: incubator-samza Updated Branches: refs/heads/master d733ed961 -> 4246137f6
SAMZA-162; remove scala 2.8 cludge in kv store Project: http://git-wip-us.apache.org/repos/asf/incubator-samza/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-samza/commit/4246137f Tree: http://git-wip-us.apache.org/repos/asf/incubator-samza/tree/4246137f Diff: http://git-wip-us.apache.org/repos/asf/incubator-samza/diff/4246137f Branch: refs/heads/master Commit: 4246137f68b006016b7d23b5355ea64adb4d895d Parents: d733ed9 Author: David Chen <[email protected]> Authored: Tue Aug 26 12:07:25 2014 -0700 Committer: Chris Riccomini <[email protected]> Committed: Tue Aug 26 12:07:25 2014 -0700 ---------------------------------------------------------------------- .../samza/storage/kv/TestKeyValueStores.scala | 2 +- .../apache/samza/storage/kv/CachedStore.scala | 21 +++++++++----------- 2 files changed, 10 insertions(+), 13 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-samza/blob/4246137f/samza-kv-leveldb/src/test/scala/org/apache/samza/storage/kv/TestKeyValueStores.scala ---------------------------------------------------------------------- diff --git a/samza-kv-leveldb/src/test/scala/org/apache/samza/storage/kv/TestKeyValueStores.scala b/samza-kv-leveldb/src/test/scala/org/apache/samza/storage/kv/TestKeyValueStores.scala index d6d437a..1f09ae5 100644 --- a/samza-kv-leveldb/src/test/scala/org/apache/samza/storage/kv/TestKeyValueStores.scala +++ b/samza-kv-leveldb/src/test/scala/org/apache/samza/storage/kv/TestKeyValueStores.scala @@ -202,7 +202,7 @@ class TestKeyValueStores(typeOfStore: String, storeConfig: String) { * implementation. The issue is that it doesn't work. More specifically, * creating a DoubleLinkedList from an existing list does not update the * "prev" field of the existing list's head to point to the new head. As a - * result, in Scala 2.8.1, every DoulbeLinkedList node's prev field is null. + * result, in Scala 2.8.1, every DoubleLinkedList node's prev field is null. * Samza gets around this by manually updating the field itself. See SAMZA-80 * for details. * http://git-wip-us.apache.org/repos/asf/incubator-samza/blob/4246137f/samza-kv/src/main/scala/org/apache/samza/storage/kv/CachedStore.scala ---------------------------------------------------------------------- diff --git a/samza-kv/src/main/scala/org/apache/samza/storage/kv/CachedStore.scala b/samza-kv/src/main/scala/org/apache/samza/storage/kv/CachedStore.scala index 7a5e510..1fa96ba 100644 --- a/samza-kv/src/main/scala/org/apache/samza/storage/kv/CachedStore.scala +++ b/samza-kv/src/main/scala/org/apache/samza/storage/kv/CachedStore.scala @@ -72,8 +72,8 @@ class CachedStore[K, V]( } } - // Use counters here, rather than directly accessing variables using .size - // since metrics can be accessed in other threads, and cache.size is not + // Use counters here, rather than directly accessing variables using .size + // since metrics can be accessed in other threads, and cache.size is not // thread safe since we're using a LinkedHashMap, and dirty.size is slow // since it requires a full traversal of the linked list. metrics.setDirtyCount(() => dirtyCount) @@ -109,12 +109,13 @@ class CachedStore[K, V]( def put(key: K, value: V) { metrics.puts.inc - // add the key to the front of the dirty list (and remove any prior occurrences to dedupe) + // Add the key to the front of the dirty list (and remove any prior + // occurrences to dedupe). val found = cache.get(key) if (found == null || found.dirty == null) { this.dirtyCount += 1 } else { - // If we are removing the head of the list, move the head to the next + // If we are removing the head of the list, move the head to the next // element. See SAMZA-45 for details. if (found.dirty.prev == null) { this.dirty = found.dirty.next @@ -123,14 +124,10 @@ class CachedStore[K, V]( found.dirty.remove } } + this.dirty = new mutable.DoubleLinkedList(key, this.dirty) - // We have to manually manage the prev value because Scala 2.8 is totally - // broken. See SAMZA-80 for details. - val oldDirtyList = this.dirty - this.dirty = new mutable.DoubleLinkedList(key, oldDirtyList) - oldDirtyList.prev = this.dirty - - // add the key to the cache (but don't allocate a new cache entry if we already have one) + // Add the key to the cache (but don't allocate a new cache entry if we + // already have one). if (found == null) { cache.put(key, new CacheEntry(value, this.dirty)) cacheCount = cache.size @@ -139,7 +136,7 @@ class CachedStore[K, V]( found.dirty = this.dirty } - // flush the dirty values if the write list is full + // Flush the dirty values if the write list is full. if (dirtyCount >= writeBatchSize) { debug("Dirty count %s >= write batch size %s. Flushing." format (dirtyCount, writeBatchSize))
