Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in com.hazelcast.query.Predicates.NotEqualPredicate #262

Closed
steffentemplin opened this issue Sep 4, 2012 · 0 comments

Comments

Projects
None yet
2 participants
@steffentemplin
Copy link

commented Sep 4, 2012

Hi,

i recently started to work with the criteria API for distributed maps and experienced wrong results with a not-equal-comparison between two integer values on indexed fields. This happens for me with Hazelcast 2.3.1:

NotEqualPredicate.filter() calls Index.getSubRecords(false, false, searchValue). In this case the first boolean means "not a less than-comparison" and the second one means "not a equal-comparison". This causes wrong results, because both IndexStore implementations are performing a greater-than-comparison in this case (whats indeed the right implication of the combination of both booleans i think). This can easily be tested:

@Test
public void testNotEqualPredicate() throws Exception {
    HazelcastInstance hazelcast = getHazelcastInstance();
    IMap<String, MapValue> map = hazelcast.getMap("mapName");
    map.addIndex("value", false);
    map.put("key1", new MapValue(1));

    EntryObject entryObject = new PredicateBuilder().getEntryObject().get("value");
    PredicateBuilder notEqualPredicate = entryObject.notEqual(5);
    Collection<MapValue> values = map.values(notEqualPredicate);
    assertTrue(!values.isEmpty());
}

private static final class MapValue implements Serializable {

    private final int value;

    public MapValue(int value) {
        super();
        this.value = value;
    }

    public int getValue() {
        return value;
    }
}

regards,

Steffen

@ghost ghost assigned mdogan Sep 5, 2012

@mdogan mdogan closed this in f037df9 Sep 22, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.