LiangliangSui commented on code in PR #1565:
URL: https://github.com/apache/incubator-fury/pull/1565#discussion_r1577934806
##########
java/fury-core/src/main/java/org/apache/fury/meta/MetaStringDecoder.java:
##########
@@ -66,30 +65,36 @@ public String decode(byte[] encodedData, Encoding encoding,
int numBits) {
}
/** Decoding method for {@link Encoding#LOWER_SPECIAL}. */
- private String decodeLowerSpecial(byte[] data, int numBits) {
+ private String decodeLowerSpecial(byte[] data) {
StringBuilder decoded = new StringBuilder();
- int bitIndex = 0;
- int bitMask = 0b11111; // 5 bits for mask
- while (bitIndex + 5 <= numBits) {
+ int totalBits = data.length * 8; // Total number of bits in the data
+ boolean stripLastChar = (data[0] & 0x80) != 0; // Check the first bit of
the first byte
+ int bitMask = 0b11111; // 5 bits for the mask
+ int bitIndex = 1; // Start from the second bit
+ while (bitIndex + 5 <= totalBits) {
Review Comment:
When `stripLastChar` is true, the while loop will be executed one more time,
and an extra redundant char will be added to `decoded`, and then we will delete
it.
Through this logic, we can delete the `numChars` and `numBits` fields in
`MetaString`, because we can infer these two values through `stripLastChar`.
Can I understand this problem this way?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]