[
https://issues.apache.org/jira/browse/IGNITE-14369?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Bojidar Marinov updated IGNITE-14369:
-------------------------------------
Description:
The Node.js thin client calculates wrong hashcodes, possibly leading to
duplicated rows and inability to read rows with complex key types written from
other languages:
# BinaryUtils.contentHashCode is called with wrong end parameter at
[BinaryObject.ts:397|https://github.com/apache/ignite-nodejs-thin-client/blob/76c7d7eb2b1856295f877434ef358beaa7155d91/src/BinaryObject.ts#L397].
The second parameter is the end position, not the content length, and thus
should be relative to this._startOffset.
Experimentally confirmed that changing to this._startOffset +
this._schemaOffset - 1 works.
# BinaryUtils.contentHashCode uses unsigned bytes at
[BinaryUtils.ts:632|https://github.com/apache/ignite-nodejs-thin-client/blob/76c7d7eb2b1856295f877434ef358beaa7155d91/src/internal/BinaryUtils.ts#L632].
[buffer[idx]|https://nodejs.org/api/buffer.html#buffer_buf_index] returns a
number between 0..255, while Java's byte is -128..127.
Experimentally confirmed that switching to
[Buffer.readInt8|https://nodejs.org/api/buffer.html#buffer_buf_readint8_offset]
works.
was:
The Node.js thin client calculates wrong hashcodes, possibly leading to
duplicated rows and inability to read rows with complex key types written from
other languages:
# BinaryUtils.contentHashCode is called with wrong end parameter at
[BinaryObject.ts:397|https://github.com/apache/ignite-nodejs-thin-client/blob/76c7d7eb2b1856295f877434ef358beaa7155d91/src/BinaryObject.ts#L397].
The second parameter is the end position, not the content length, and thus
should be relative to this._startOffset.
Experimentally confirmed that changing to this._startOffset +
this._schemaOffset - 1 works.
# BinaryUtils.contentHashCode uses unsigned bytes at
[BinaryUtils.ts:632|https://github.com/apache/ignite-nodejs-thin-client/blob/76c7d7eb2b1856295f877434ef358beaa7155d91/src/internal/BinaryUtils.ts#L632].
[`buffer[idx]`|https://nodejs.org/api/buffer.html#buffer_buf_index] returns a
number between 0..255, while Java's byte is -128..127.
Experimentally confirmed that switching to
[Buffer.readInt8|https://nodejs.org/api/buffer.html#buffer_buf_readint8_offset]
works.
> Node.js: incorrect Hash Code calculcation
> -----------------------------------------
>
> Key: IGNITE-14369
> URL: https://issues.apache.org/jira/browse/IGNITE-14369
> Project: Ignite
> Issue Type: Bug
> Components: thin client
> Affects Versions: 2.10
> Reporter: Bojidar Marinov
> Priority: Major
>
> The Node.js thin client calculates wrong hashcodes, possibly leading to
> duplicated rows and inability to read rows with complex key types written
> from other languages:
> # BinaryUtils.contentHashCode is called with wrong end parameter at
> [BinaryObject.ts:397|https://github.com/apache/ignite-nodejs-thin-client/blob/76c7d7eb2b1856295f877434ef358beaa7155d91/src/BinaryObject.ts#L397].
> The second parameter is the end position, not the content length, and thus
> should be relative to this._startOffset.
> Experimentally confirmed that changing to this._startOffset +
> this._schemaOffset - 1 works.
> # BinaryUtils.contentHashCode uses unsigned bytes at
> [BinaryUtils.ts:632|https://github.com/apache/ignite-nodejs-thin-client/blob/76c7d7eb2b1856295f877434ef358beaa7155d91/src/internal/BinaryUtils.ts#L632].
> [buffer[idx]|https://nodejs.org/api/buffer.html#buffer_buf_index] returns a
> number between 0..255, while Java's byte is -128..127.
> Experimentally confirmed that switching to
> [Buffer.readInt8|https://nodejs.org/api/buffer.html#buffer_buf_readint8_offset]
> works.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)