Skip to content

Commit

Permalink
In comparison step of dictionaryBinarySearch(), we are going back to …
Browse files Browse the repository at this point in the history
…doing string comparison (rather than byte-level comparison). This is necessary because the binary search table's layout is being done according to Java's (Unicode-aware) string comparison order, not encoded byte comparison order, so the lookup needs to match. This fixes issue LHNCBC#1; see issue for more complete discussion.
  • Loading branch information
stevenbedrick committed May 6, 2023
1 parent 9b06071 commit 6ba89b3
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/main/java/irutils/MappedMultiKeyIndex.java
Original file line number Diff line number Diff line change
Expand Up @@ -429,10 +429,10 @@ public static class Extent {
bsfp.get(tstwordbuf);
tstword = new String(tstwordbuf, charset);
// System.out.println("index: " + mid + ", address: " + (mid * (wordlen+datalen)) + ", tstword: " + tstword + ", word: " + word);
// cond = word.compareTo(tstword);
ByteBuffer wordByteBuf = ByteBuffer.wrap(word.getBytes(charset));
ByteBuffer tstwordByteBuf = ByteBuffer.wrap(tstwordbuf);
cond = wordByteBuf.compareTo(tstwordByteBuf);
cond = word.compareTo(tstword);
// ByteBuffer wordByteBuf = ByteBuffer.wrap(word.getBytes(charset));
// ByteBuffer tstwordByteBuf = ByteBuffer.wrap(tstwordbuf);
// cond = wordByteBuf.compareTo(tstwordByteBuf);
if (cond < 0) {
high = mid;
} else if (cond > 0) {
Expand Down

0 comments on commit 6ba89b3

Please sign in to comment.