Package com.hazelcast.query

Examples of com.hazelcast.query.SqlPredicate


        final SampleObjects.Employee emp2 = new SampleObjects.Employee("xvz", 4, true, 10D);

        boolean b = h1.executeTransaction(options, new TransactionalTask<Boolean>() {
            public Boolean execute(TransactionalTaskContext context) throws TransactionException {
                final TransactionalMap<Object, Object> txMap = context.getMap("default");
                assertEquals(0, txMap.values(new SqlPredicate("age <= 10")).size());
                txMap.put(2, emp2);
                Collection coll = txMap.values(new SqlPredicate("age <= 10"));
                Iterator<Object> iterator = coll.iterator();
                while (iterator.hasNext()) {
                    final SampleObjects.Employee e = (SampleObjects.Employee) iterator.next();
                    assertEquals(emp2, e);
                }
                coll = txMap.values(new SqlPredicate("age > 30 "));
                iterator = coll.iterator();
                while (iterator.hasNext()) {
                    final SampleObjects.Employee e = (SampleObjects.Employee) iterator.next();
                    assertEquals(emp1, e);
                }
                txMap.remove(2);
                coll = txMap.values(new SqlPredicate("age <= 10 "));
                assertEquals(0, coll.size());
                return true;
            }
        });
        assertEquals(0, map2.values(new SqlPredicate("age <= 10")).size());
        assertEquals(1, map2.values(new SqlPredicate("age = 34")).size());
        h1.shutdown();
        h2.shutdown();
    }
View Full Code Here


        map.put(1, employeeAtAge22);

        boolean b = h1.executeTransaction(options, new TransactionalTask<Boolean>() {
            public Boolean execute(TransactionalTaskContext context) throws TransactionException {
                final TransactionalMap<Object, Object> txMap = context.getMap(mapName);
                assertEquals(1, txMap.values(new SqlPredicate("age > 21")).size());
                txMap.put(1, employeeAtAge23);
                Collection coll = txMap.values(new SqlPredicate("age > 21"));
                assertEquals(1, coll.size());
                return true;
            }
        });
        h1.shutdown();
View Full Code Here

        node.executeTransaction(options, new TransactionalTask<Boolean>() {
            public Boolean execute(TransactionalTaskContext context) throws TransactionException {
                final TransactionalMap<Object, Object> txMap = context.getMap(mapName);
                txMap.remove(1);
                Collection<Object> coll = txMap.values(new SqlPredicate("age > 70 "));
                assertEquals(0, coll.size());
                return true;
            }
        });
        node.shutdown();
View Full Code Here

        HazelcastInstance h2 = nodeFactory.newHazelcastInstance();
        assertEquals(101, imap.size());
        h1.getLifecycleService().shutdown();
        imap = h2.getMap("employees");
        assertEquals(101, imap.size());
        Set<Map.Entry> entries = imap.entrySet(new SqlPredicate("active and age=23"));
        assertEquals(2, entries.size());
        for (Map.Entry entry : entries) {
            Employee c = (Employee) entry.getValue();
            assertEquals(c.getAge(), 23);
            assertTrue(c.isActive());
View Full Code Here

        for (int i = SAMPLE_SIZE_1; i < TOTAL_SIZE; i++) {
            map.put(i, new ValueType("typex"));
        }

        Collection typexValues = map.values(new SqlPredicate("typeName = typex"));
        assertEquals(SAMPLE_SIZE_2, typexValues.size());

        instances[1].shutdown();

        assertEquals(TOTAL_SIZE, map.size());
        assertTrueEventually(new AssertTask() {
            public void run() {
                final Collection values = map.values(new SqlPredicate("typeName = typex"));
                assertEquals(SAMPLE_SIZE_2, values.size());
            }
        });

        instances[2].shutdown();

        assertEquals(TOTAL_SIZE, map.size());
        assertTrueEventually(new AssertTask() {
            public void run() {
                final Collection values = map.values(new SqlPredicate("typeName = typex"));
                assertEquals(SAMPLE_SIZE_2, values.size());
            }
        });
    }
View Full Code Here

        final IMap map = instance.getMap(name);

        assertTrueEventually(new AssertTask() {
            @Override
            public void run() throws Exception {
                Collection values = map.values(new SqlPredicate("active = true"));
                assertEquals(size, values.size());
            }
        });
    }
View Full Code Here

    @Test
    public void testValues() {
        final IMap map = createMap();
        fillMap(map);

        final Collection values = map.values(new SqlPredicate("this == value1"));
        assertEquals(1, values.size());
        assertEquals("value1", values.iterator().next());
    }
View Full Code Here

    @Test
    public void testBasicPredicate() {
        final IMap map = createMap();
        fillMap(map);
        final Collection collection = map.values(new SqlPredicate("this == value1"));
        assertEquals("value1", collection.iterator().next());
        final Set set = map.keySet(new SqlPredicate("this == value1"));
        assertEquals("key1", set.iterator().next());
        final Set<Map.Entry<String, String>> set1 = map.entrySet(new SqlPredicate("this == value1"));
        assertEquals("key1", set1.iterator().next().getKey());
        assertEquals("value1", set1.iterator().next().getValue());
    }
View Full Code Here

        assertEquals(1, clientMap.size());

        final EntryListener listener = new EntListener(gateAdd, gateRemove, gateEvict, gateUpdate, gateClearAll, gateEvictAll);

        clientMap.addEntryListener(listener, new SqlPredicate("id=1"), 2, true);
        clientMap.put(2, new Deal(1));
        clientMap.put(2, new Deal(1));
        clientMap.remove(2);

        clientMap.put(2, new Deal(1));
View Full Code Here

        super(name, requestType, null, null, null);
        this.predicate = predicate;
    }

    protected Predicate getPredicate() {
        return new SqlPredicate(predicate);
    }
View Full Code Here

TOP

Related Classes of com.hazelcast.query.SqlPredicate

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.