theweipeng commented on code in PR #1313:
URL: https://github.com/apache/incubator-fury/pull/1313#discussion_r1443794087
##########
javascript/packages/fury/lib/reader.ts:
##########
@@ -144,21 +190,67 @@ export const BinaryReader = (config: Config) => {
return (v >> 1) ^ -(v & 1);
}
+ function zigZagBigInt(v: bigint) {
+ return (v >> 1n) ^ -(v & 1n);
+ }
+
function varUInt32() {
- let byte_ = int8();
+ let byte_ = uint8();
let result = byte_ & 0x7f;
if ((byte_ & 0x80) != 0) {
- byte_ = int8();
+ byte_ = uint8();
result |= (byte_ & 0x7f) << 7;
if ((byte_ & 0x80) != 0) {
- byte_ = int8();
+ byte_ = uint8();
result |= (byte_ & 0x7f) << 14;
if ((byte_ & 0x80) != 0) {
- byte_ = int8();
+ byte_ = uint8();
result |= (byte_ & 0x7f) << 21;
if ((byte_ & 0x80) != 0) {
- byte_ = int8();
- result |= (byte_ & 0x7f) << 28;
+ byte_ = uint8();
+ result |= (byte_) << 28;
+ }
+ }
+ }
+ }
+ return result;
+ }
+
+ function bigUInt8() {
+ return BigInt(uint8() >>> 0);
+ }
+
+ function varUInt64() {
+ let byte_ = bigUInt8();
Review Comment:
Great suggestion! Currently, the maximum bit length that the Number type can
safely represent in JavaScript is 53 bits, which is insufficient to decode our
varUInt64. BigInt serves as a workaround; however, its performance in
JavaScript is significantly suboptimal. I plan to address the performance
issues associated with handling 64-bit numbers comprehensively in subsequent
pull requests.
--
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]