Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ trait VolumeTracingBucketHelper extends WKWMortonHelper with KeyValueStoreImplic

def bucketStreamWithVersion(dataLayer: VolumeTracingLayer, resolution: Int, version: Option[Long]): Iterator[(BucketPosition, Array[Byte], Long)] = {
val key = buildKeyPrefix(dataLayer.name, resolution)
new VersionedBucketIterator(key, volumeDataStore, version)
new VersionedBucketIterator(key, volumeDataStore, version).flatMap(item => item)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.flatten should do the same thing

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But I am apparently to late to the party :(

}
}



class VersionedBucketIterator(prefix: String, volumeDataStore: FossilDBClient, version: Option[Long] = None) extends Iterator[(BucketPosition, Array[Byte], Long)] with WKWMortonHelper with KeyValueStoreImplicits with FoxImplicits {
class VersionedBucketIterator(prefix: String, volumeDataStore: FossilDBClient, version: Option[Long] = None) extends Iterator[Option[(BucketPosition, Array[Byte], Long)]] with WKWMortonHelper with KeyValueStoreImplicits with FoxImplicits {
val batchSize = 64

var currentStartKey = prefix
Expand All @@ -70,10 +70,10 @@ class VersionedBucketIterator(prefix: String, volumeDataStore: FossilDBClient, v
else fetchNextAndSave.hasNext
}

override def next: (BucketPosition, Array[Byte], Long) = {
override def next: Option[(BucketPosition, Array[Byte], Long)] = {
val nextRes = currentBatchIterator.next
currentStartKey = nextRes.key
parseBucketKey(nextRes.key).map(key => (key._2 , nextRes.value, nextRes.version)).get
parseBucketKey(nextRes.key).map(key => (key._2 , nextRes.value, nextRes.version))
}

private def parseBucketKey(key: String): Option[(String, BucketPosition)] = {
Expand All @@ -96,8 +96,8 @@ class VersionedBucketIterator(prefix: String, volumeDataStore: FossilDBClient, v

}

class BucketIterator(prefix: String, volumeDataStore: FossilDBClient, version: Option[Long] = None) extends Iterator[(BucketPosition, Array[Byte])]{
val versionedBucketIterator = new VersionedBucketIterator(prefix, volumeDataStore, version)
class BucketIterator(prefix: String, volumeDataStore: FossilDBClient, version: Option[Long] = None) extends Iterator[(BucketPosition, Array[Byte])] {
val versionedBucketIterator = new VersionedBucketIterator(prefix, volumeDataStore, version).flatMap(item => item)

override def next: (BucketPosition, Array[Byte]) = {
val tuple = versionedBucketIterator.next
Expand Down