Skip to content

Commit

Permalink
Fixed rowDecode
Browse files Browse the repository at this point in the history
  • Loading branch information
takapi327 committed Feb 1, 2025
1 parent 0056342 commit d58454c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,9 @@ private[ldbc] case class ResultSetImpl(
for
row <- currentRow
value <- row.values(index - 1)
yield decode(value)
decoded <- try { Option(decode(value)) }
catch case _ => None
yield decoded

private def findByName(columnLabel: String): Int =
columns.zipWithIndex
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,15 @@ object EOFPacket:
* Values for the capabilities flag bitmask used by the MySQL protocol.
*/
def decoder(capabilityFlags: Set[CapabilitiesFlags]): Decoder[EOFPacket] =
new Decoder[EOFPacket]:
override def decode(bits: BitVector): Attempt[DecodeResult[EOFPacket]] =
val hasClientProtocol41Flag = capabilityFlags.contains(CapabilitiesFlags.CLIENT_PROTOCOL_41)
val (statusBits, postStatusBits) = bits.splitAt(4)
val status = statusBits.toInt(false)
val packet = if hasClientProtocol41Flag then
val (warningsBits, postWorningsBits) = postStatusBits.splitAt(4)
val statusFlagsBits = postWorningsBits.take(4)
val warnings = warningsBits.toInt(false)
val statusFlags = statusFlagsBits.toInt(false)
EOFPacket(status, warnings, statusFlags)
else EOFPacket(status, 0, 0)
Attempt.successful(DecodeResult(packet, bits))
(bits: BitVector) =>
val hasClientProtocol41Flag = capabilityFlags.contains(CapabilitiesFlags.CLIENT_PROTOCOL_41)
val (statusBits, postStatusBits) = bits.splitAt(4)
val status = statusBits.toInt(false)
val packet = if hasClientProtocol41Flag then
val (warningsBits, postWarningsBits) = postStatusBits.splitAt(4)
val statusFlagsBits = postWarningsBits.take(4)
val warnings = warningsBits.toInt(false)
val statusFlags = statusFlagsBits.toInt(false)
EOFPacket(status, warnings, statusFlags)
else EOFPacket(status, 0, 0)
Attempt.successful(DecodeResult(packet, bits))

0 comments on commit d58454c

Please sign in to comment.