Fix ClassCastException in BinaryComparator for TYPE_BINARY comparisons#2762
Merged
Fix ClassCastException in BinaryComparator for TYPE_BINARY comparisons#2762
Conversation
Co-authored-by: robfrank <413587+robfrank@users.noreply.github.com>
Co-authored-by: robfrank <413587+robfrank@users.noreply.github.com>
Co-authored-by: robfrank <413587+robfrank@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix broken binary index implementation
Fix ClassCastException in BinaryComparator for TYPE_BINARY comparisons
Nov 7, 2025
Contributor
🧪 CI InsightsHere's what we observed from your CI run for 3af475a. 🟢 All jobs passed!But CI Insights is watching 👀 |
Coverage summary from CodacySee diff coverage on Codacy
Coverage variation details
Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: Diff coverage details
Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: See your quality gate settings Change summary preferences |
lvca
approved these changes
Nov 9, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Fixes a
ClassCastExceptioninBinaryComparator.compare()that occurs when comparing TYPE_BINARY values in LSM tree indexes. The comparator incorrectly assumed both operands areBinaryobjects, but deserialized values arebyte[]arrays.Motivation
Binary indexes break in two scenarios:
ClassCastExceptionwhen comparing user-providedbyte[]against indexed valuesbyte[], notBinaryobjectsExample from issue:
Related issues
Fixes issue: Binary index is broken.
Additional Notes
Changes:
BinaryComparator.java: Handle all combinations ofbyte[]andBinaryobjects in TYPE_BINARY comparisonsbyte[]vsbyte[]→UnsignedBytesComparatorbyte[]vsBinary→ compare via Binary's content arrayBinaryvsbyte[]→ compare via Binary's content arrayBinaryvsBinary→ existingBinary.compareTo()BinaryIndexTest.java: Test cases for insert, lookup, and database reopen scenariosRoot cause: TYPE_BINARY values are serialized as either
byte[]orBinary, always deserialized asbyte[], but comparison logic only handledBinaryobjects.Checklist
mvn clean packagecommandWarning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
esm.ubuntu.com/usr/lib/apt/methods/https(dns block)repository.apache.org/usr/lib/jvm/java-21-openjdk-amd64/bin/java --enable-native-access=ALL-UNNAMED -classpath /usr/share/apache-maven-3.9.11/boot/plexus-classworlds-2.9.0.jar -Dclassworlds.conf=/usr/share/apache-maven-3.9.11/bin/m2.conf -Dmaven.home=/usr/share/apache-maven-3.9.11 -Dlibrary.jansi.path=/usr/share/apache-maven-3.9.11/lib/jansi-native -Dmaven.multiModuleProjectDirectory=/home/REDACTED/work/arcadedb/arcadedb org.codehaus.plexus.classworlds.launcher.Launcher clean compile -DskipTests(dns block)/usr/lib/jvm/temurin-17-jdk-amd64/bin/java -classpath /home/REDACTED/.m2/wrapper/dists/apache-maven-3.9.9/3477a4f1/boot/plexus-classworlds-2.8.0.jar -Dclassworlds.conf=/home/REDACTED/.m2/wrapper/dists/apache-maven-3.9.9/3477a4f1/bin/m2.conf -Dmaven.home=/home/REDACTED/.m2/wrapper/dists/apache-maven-3.9.9/3477a4f1 -Dlibrary.jansi.path=/home/REDACTED/.m2/wrapper/dists/apache-maven-3.9.9/3477a4f1/lib/jansi-native -Dmaven.multiModuleProjectDirectory=/home/REDACTED/work/arcadedb/arcadedb org.codehaus.plexus.classworlds.launcher.Launcher -f pom.xml -B -V -e -Dfindbugs.skip -Dcheckstyle.skip -Dpmd.skip=true -Dspotbugs.skip -Denforcer.skip -Dmaven.javadoc.skip -DskipTests -Dmaven.test.skip.exec -Dlicense.skip=true -Drat.skip=true -Dspotless.check.skip=true -s /home/REDACTED/work/arcadedb/.codeql-scratch/dbs/java/working/settings.xml com.github.ferstl:depgraph-maven-plugin:4.0.3-CodeQL:graph -B -DclasspathScopes=compile -DoutputDirectory=/home/REDACTED/work/arcadedb/.codeql-scratch/dbs/java/working/java-standalone-dependency-graph11621566166271152122/${project.groupId}/${project.artifactId} -DgraphFormat=json -Dmaven.ext.class.path=/opt/hostedtoolcache/CodeQL/2.23.3/x64/codeql/java/tools/java-buildless-maven-plugin.jar(dns block)scarf.shnode ./report.js(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.