Package com.hazelcast.query

Examples of com.hazelcast.query.PredicateBuilder


        int count = 1000;
        Set<String> ages = new HashSet<String>(count);
        for (int i = 0; i < count; i++) {
            ages.add(String.valueOf(i));
        }
        final EntryObject entryObject = new PredicateBuilder().getEntryObject();
        final PredicateBuilder predicate = entryObject.get("name").equal("140Name").and(entryObject.get("age").in(ages.toArray(new String[0])));
        long total = Runtime.getRuntime().totalMemory();
        long free = Runtime.getRuntime().freeMemory();
        long start = Clock.currentTimeMillis();
        for (int i = 0; i < 10000; i++) {
            Set<QueryableEntry> results = indexService.query(predicate);
View Full Code Here


    public void testNullIndexing() {
        TestHazelcastInstanceFactory nodeFactory = createHazelcastInstanceFactory(2);
        HazelcastInstance h1 = nodeFactory.newHazelcastInstance();
        HazelcastInstance h2 = nodeFactory.newHazelcastInstance();

        EntryObject e = new PredicateBuilder().getEntryObject();
        Predicate predicate = e.is("active").and(e.get("name").equal(null).and(e.get("city").isNull()));

        IMap imap1 = h1.getMap("employees");
        IMap imap2 = h2.getMap("employees");
View Full Code Here

                            } catch (InterruptedException e) {
                                break;
                            }
                            Value v1 = map.get(name);
                            assertEquals(v, v1);
                            EntryObject e = new PredicateBuilder().getEntryObject();
                            Predicate<?, ?> predicate = e.get("name").equal(name);
                            Collection<Value> values = map.values(predicate);
                            assertEquals(1, values.size());
                            Value v2 = values.iterator().next();
                            assertEquals(v1, v2);
View Full Code Here

        final int expected = entryPerNode / modulo * nodes;

        for (HazelcastInstance hz : instances) {
            IMap<Object, Object> map = hz.getMap(name);
            EntryObject e = new PredicateBuilder().getEntryObject();
            Predicate p = e.get("name").equal(FIND_ME);
            for (int i = 0; i < 10; i++) {
                int size = map.values(p).size();
                Assert.assertEquals(expected, size);
                Thread.sleep(10);
View Full Code Here

        HazelcastInstance h1 = nodeFactory.newHazelcastInstance(cfg);
        IMap imap = h1.getMap("employees");
        for (int i = 0; i < 5000; i++) {
            imap.put(String.valueOf(i), new SampleObjects.Employee("name" + i, i % 60, ((i & 1) == 1), Double.valueOf(i)));
        }
        EntryObject e = new PredicateBuilder().getEntryObject();
        Predicate predicate = e.is("active").and(e.get("age").equal(23));
        long start = Clock.currentTimeMillis();
        Set<Map.Entry> entries = imap.entrySet(predicate);
        long tookWithout = (Clock.currentTimeMillis() - start);
        assertEquals(83, entries.size());
        for (Map.Entry entry : entries) {
            SampleObjects.Employee c = (SampleObjects.Employee) entry.getValue();
            assertEquals(c.getAge(), 23);
            assertTrue(c.isActive());
        }
        imap.clear();
        imap = h1.getMap("employees2");
        imap.addIndex("name", false);
        imap.addIndex("active", false);
        imap.addIndex("age", true);
        for (int i = 0; i < 5000; i++) {
            imap.put(String.valueOf(i), new SampleObjects.Employee("name" + i, i % 60, ((i & 1) == 1), Double.valueOf(i)));
        }
        e = new PredicateBuilder().getEntryObject();
        predicate = e.is("active").and(e.get("age").equal(23));
        start = Clock.currentTimeMillis();
        entries = imap.entrySet(predicate);
        long tookWithIndex = (Clock.currentTimeMillis() - start);
        assertEquals(83, entries.size());
View Full Code Here

        HazelcastInstance h1 = nodeFactory.newHazelcastInstance(cfg);
        IMap imap = h1.getMap("employees");
        for (int i = 0; i < 5000; i++) {
            imap.put(String.valueOf(i), new SampleObjects.Employee("name" + i, i % 60, ((i & 1) == 1), Double.valueOf(i)));
        }
        EntryObject e = new PredicateBuilder().getEntryObject();
        Predicate predicate = e.is("active").and(e.get("age").equal(23));
        long start = Clock.currentTimeMillis();
        Set<Map.Entry> entries = imap.entrySet(predicate);
        long tookWithout = (Clock.currentTimeMillis() - start);
        assertEquals(83, entries.size());
        for (Map.Entry entry : entries) {
            SampleObjects.Employee c = (SampleObjects.Employee) entry.getValue();
            assertEquals(c.getAge(), 23);
            assertTrue(c.isActive());
        }
        imap.clear();

        imap = h1.getMap("employees2");
        for (int i = 0; i < 5000; i++) {
            imap.put(String.valueOf(i), new SampleObjects.Employee("name" + i, i % 60, ((i & 1) == 1), Double.valueOf(i)));
        }
        e = new PredicateBuilder().getEntryObject();
        predicate = e.is("active").and(e.get("age").equal(23));
        start = Clock.currentTimeMillis();
        entries = imap.entrySet(predicate);
        long tookWithIndex = (Clock.currentTimeMillis() - start);
        assertEquals(83, entries.size());
View Full Code Here

        int size = 10;
        for (int i = 0; i < size; i++) {
            map.put(i, new SampleObjects.Employee(i, "", 0, false, 0D, SampleObjects.State.STATE1));
        }
        EntryProcessor entryProcessor = new ChangeStateEntryProcessor();
        EntryObject e = new PredicateBuilder().getEntryObject();
        Predicate p = e.get("id").lessThan(5);
        Map<Integer, Object> res = map.executeOnEntries(entryProcessor, p);

        for (int i = 0; i < 5; i++) {
            assertEquals(SampleObjects.State.STATE2, map.get(i).getState());
View Full Code Here

        int size = 10;
        for (int i = 0; i < size; i++) {
            map.put(i, new SampleObjects.Employee(i, "", 0, false, 0D, SampleObjects.State.STATE1));
        }
        EntryProcessor entryProcessor = new ChangeStateEntryProcessor();
        EntryObject e = new PredicateBuilder().getEntryObject();
        Predicate p = e.get("id").lessThan(5);

        MapExecuteWithPredicateRequest request = new MapExecuteWithPredicateRequest(map.getName(), entryProcessor, p);
        final SimpleClient client = getClient();
        client.send(request);
View Full Code Here

        IMap map = inst.getMap("default");

        EntryListener<String, Integer> l = new EntryAdapter<String, Integer>() {
        };

        EntryObject e = new PredicateBuilder().getEntryObject();
        Predicate<String, Integer> p = e.equal(1);

        map.addEntryListener(l, p, null, false);

        for (Integer i = 0; i < 100; i++) {
View Full Code Here

TOP

Related Classes of com.hazelcast.query.PredicateBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.