Skip to content

Commit

Permalink
Fixes a bug in moveTo().
Browse files Browse the repository at this point in the history
  • Loading branch information
Ralph Gasser committed Jul 10, 2024
1 parent baaf9a8 commit aac6b20
Showing 1 changed file with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ class VariableLengthCursor<T: Value>(column: VariableLengthColumn<T>.Tx): Cursor
/** */
private var valueRaw: ByteIterable? = null

override fun moveNext(): Boolean = this.moveTo(this.tupleId + 1)
override fun movePrevious(): Boolean = this.moveTo(this.tupleId - 1)
override fun moveNext(): Boolean = this.moveTo(this.tupleId + 1L)
override fun movePrevious(): Boolean = this.moveTo(this.tupleId - 1L)
override fun moveTo(tupleId: TupleId): Boolean {
if (tupleId < 0) return false
if (tupleId < 0L) return false
return when (tupleId) {
this.tupleId -> true
this.tupleId + 1 -> {
this.tupleId + 1L -> {
if (this.cursor.next) {
this.tupleId = tupleId
this.valueRaw = this.cursor.value
Expand All @@ -54,7 +54,7 @@ class VariableLengthCursor<T: Value>(column: VariableLengthColumn<T>.Tx): Cursor
false
}
}
this.tupleId - 1 -> {
this.tupleId - 1L -> {
if (this.cursor.prev) {
this.tupleId = tupleId
this.valueRaw = this.cursor.value
Expand All @@ -65,7 +65,12 @@ class VariableLengthCursor<T: Value>(column: VariableLengthColumn<T>.Tx): Cursor
}
else -> {
this.valueRaw = this.cursor.getSearchKey(LongBinding.longToCompressedEntry(tupleId))
return this.valueRaw != null
if (this.valueRaw != null) {
this.tupleId = tupleId
return true
} else {
return false
}
}
}
}
Expand Down

0 comments on commit aac6b20

Please sign in to comment.