Implemented the start and finish semantic in the getMapStorageRangeFor method
This commit is contained in:
parent
2145b094bd
commit
ca3538df8e
2 changed files with 16 additions and 2 deletions
|
|
@ -233,9 +233,15 @@ private[akka] object HbaseStorageBackend extends MapStorageBackend[Array[Byte],
|
|||
def getMapStorageRangeFor(name: String, start: Option[Array[Byte]], finish: Option[Array[Byte]], count: Int): List[Tuple2[Array[Byte], Array[Byte]]] = {
|
||||
val row = new Get(Bytes.toBytes(name))
|
||||
val result = MAP_TABLE.get(row)
|
||||
val iterator = result.getFamilyMap(Bytes.toBytes(MAP_ELEMENT_COLUMN_FAMILY_NAME)).entrySet.iterator
|
||||
val map = result.getFamilyMap(Bytes.toBytes(MAP_ELEMENT_COLUMN_FAMILY_NAME))
|
||||
|
||||
val startBytes = if (start.isDefined) start.get else map.firstEntry.getKey
|
||||
val finishBytes = if (finish.isDefined) finish.get else map.lastEntry.getKey
|
||||
val submap = map.subMap(startBytes, true, finishBytes, true)
|
||||
|
||||
val iterator = submap.entrySet.iterator
|
||||
val listBuffer = new ListBuffer[Tuple2[Array[Byte], Array[Byte]]]
|
||||
val size = result.size
|
||||
val size = submap.size
|
||||
|
||||
val cnt = if(count > size) size else count
|
||||
var i: Int = 0
|
||||
|
|
|
|||
|
|
@ -81,9 +81,17 @@ BeforeAndAfterEach {
|
|||
("larry wall", "perl"),
|
||||
("guido van rossum", "python"),
|
||||
("james strachan", "groovy"))
|
||||
val rl = List(
|
||||
("james gosling", "java"),
|
||||
("james strachan", "groovy"),
|
||||
("larry wall", "perl"),
|
||||
("martin odersky", "scala"),
|
||||
("ola bini", "ioke"), ("rich hickey", "clojure"),
|
||||
("slava pestov", "factor"))
|
||||
insertMapStorageEntriesFor("t1", l.map { case (k, v) => (k.getBytes, v.getBytes) })
|
||||
getMapStorageSizeFor("t1") should equal(l.size)
|
||||
getMapStorageRangeFor("t1", None, None, 100).map { case (k, v) => (new String(k), new String(v)) } should equal(l.sortWith(_._1 < _._1))
|
||||
getMapStorageRangeFor("t1", Option("james gosling".getBytes), Option("slava pestov".getBytes), 100).map { case (k, v) => (new String(k), new String(v)) } should equal(rl.sortWith(_._1 < _._1))
|
||||
getMapStorageRangeFor("t1", None, None, 5).map { case (k, v) => (new String(k), new String(v)) }.size should equal(5)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue