Skip to content

Binary index is broken. #1534

@JokerXiL

Description

@JokerXiL

ArcadeDB Version:

ArcadeDB Server v24.2.1 (build ce2658d/1710272693676/main)

OS and JDK Version:

Same results on three JDK Versions

Mac OS X 14.0 - OpenJDK 64-Bit Server VM 21.0.2 (Homebrew)
Mac OS X 14.0 - OpenJDK 64-Bit Server VM 17.0.9 (GraalVM CE 17.0.9+9.1)
Mac OS X 14.0 - OpenJDK 64-Bit Server VM 11.0.22 (Corretto-11.0.22.7.1)

Problems

Adding a Binary index breaks other code.

I suspect that it is because the cast to Binary in BinaryComparator is not working properly.

Steps to reproduce

Simple demo code

import com.arcadedb.ContextConfiguration;
import com.arcadedb.schema.Schema;
import com.arcadedb.schema.Type;
import com.arcadedb.server.ArcadeDBServer;

public class Main {
    public static void main(String[] args) {
        var s = new ArcadeDBServer(new ContextConfiguration());

        s.start();

        var db = s.getOrCreateDatabase("db");

        if(db.getSchema().existsType("vt"))
            db.getSchema().dropType("vt");

        db.getSchema()
                .getOrCreateVertexType("vt")
                .getOrCreateProperty("prop", Type.BINARY)
                .setMandatory(true)
                .setNotNull(true)
                .getOrCreateIndex(Schema.INDEX_TYPE.LSM_TREE, false);

        // SUCCESS
        db.newVertex("vt").set("prop", new byte[]{1,2,3}).save();

        // FAIL
        try{
            db.lookupByKey("vt", "prop", new byte[]{1,2,3});
        }
        catch (Exception e) {
            e.printStackTrace();
        }

        // SUCCESS
        db.newVertex("vt").set("prop", new byte[]{1,2,3}).save();
        // SUCCESS
        db.newVertex("vt").set("prop", new byte[]{1,2,3}).save();

        // reopening database
        s.stop();
        s.start();
        db = s.getOrCreateDatabase("db");

        // FAIL
        try{
            db.newVertex("vt").set("prop", new byte[]{1, 2, 3}).save();
        }catch (Exception e) {
            e.printStackTrace();
        }
    }
}

Metadata

Metadata

Labels

No labels
No labels

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions