Skip to content

Commit

Permalink
Fix batch data loading in the ByteReader
Browse files Browse the repository at this point in the history
  • Loading branch information
JD557 committed Mar 1, 2024
1 parent 414f21e commit ade1823
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,22 @@ private[minart] object ByteReader {
/** Read N Bytes */
def readBytes(n: Int): ParseState[Nothing, Array[Int]] = State { bytes =>
val byteArr = Array.ofDim[Byte](n)
bytes.read(byteArr)
var read = bytes.read(byteArr)
while (read >= 0 && read < n) {
byteArr(read) = bytes.read().toByte
read += 1
}
bytes -> byteArr.map(b => java.lang.Byte.toUnsignedInt(b))
}

/** Read N Bytes */
def readRawBytes(n: Int): ParseState[Nothing, Array[Byte]] = State { bytes =>
val byteArr = Array.ofDim[Byte](n)
bytes.read(byteArr)
var read = bytes.read(byteArr)
while (read >= 0 && read < n) {
byteArr(read) = bytes.read().toByte
read += 1
}
bytes -> byteArr
}

Expand Down

0 comments on commit ade1823

Please sign in to comment.