Package com.hazelcast.query.SampleObjects

Examples of com.hazelcast.query.SampleObjects.Value


    public void issue393() {
        HazelcastInstance instance = createHazelcastInstance();
        IMap<String, SampleObjects.Value> map = instance.getMap("default");
        map.addIndex("name", true);
        for (int i = 0; i < 4; i++) {
            Value v = new Value("name" + i);
            map.put("" + i, v);
        }
        Predicate predicate = new PredicateBuilder().getEntryObject().get("name").in("name0", "name2");
        Collection<SampleObjects.Value> values = map.values(predicate);
        String[] expectedValues = new String[]{"name0", "name2"};
View Full Code Here


        map.addIndex("name", false);
        testPredicateStringAttribute(map);
    }

    private void testPredicateStringAttribute(IMap map) {
        map.put(1, new Value("abc"));
        map.put(2, new Value("xyz"));
        map.put(3, new Value("aaa"));
        map.put(4, new Value("zzz"));
        map.put(5, new Value("klm"));
        map.put(6, new Value("prs"));
        map.put(7, new Value("prs"));
        map.put(8, new Value("def"));
        map.put(9, new Value("qwx"));
        assertEquals(8, map.values(new SqlPredicate("name > 'aac'")).size());
        assertEquals(9, map.values(new SqlPredicate("name between 'aaa' and 'zzz'")).size());
        assertEquals(7, map.values(new SqlPredicate("name < 't'")).size());
        assertEquals(6, map.values(new SqlPredicate("name >= 'gh'")).size());
        assertEquals(8, map.values(new PredicateBuilder().getEntryObject().get("name").greaterThan("aac")).size());
View Full Code Here

        testPredicateNotEqualWithIndex(map2, false);
    }

    private void testPredicateNotEqualWithIndex(IMap map, boolean ordered) {
        map.addIndex("name", ordered);
        map.put(1, new Value("abc", 1));
        map.put(2, new Value("xyz", 2));
        map.put(3, new Value("aaa", 3));
        assertEquals(3, map.values(new SqlPredicate("name != 'aac'")).size());
        assertEquals(2, map.values(new SqlPredicate("index != 2")).size());
        assertEquals(3, map.values(new PredicateBuilder().getEntryObject().get("name").notEqual("aac")).size());
        assertEquals(2, map.values(new PredicateBuilder().getEntryObject().get("index").notEqual(2)).size());
    }
View Full Code Here

    public void testIndexingEnumAttributeIssue597() {
        HazelcastInstance instance = createHazelcastInstance();
        IMap<Integer, SampleObjects.Value> map = instance.getMap("default");
        map.addIndex("state", true);
        for (int i = 0; i < 4; i++) {
            Value v = new Value(i % 2 == 0 ? State.STATE1 : State.STATE2, new ValueType(), i);
            map.put(i, v);
        }
        Predicate predicate = new PredicateBuilder().getEntryObject().get("state").equal(State.STATE1);
        Collection<SampleObjects.Value> values = map.values(predicate);
        int[] expectedValues = new int[]{0, 2};
View Full Code Here

    public void testIndexingEnumAttributeWithSqlIssue597() {
        HazelcastInstance instance = createHazelcastInstance();
        IMap<Integer, SampleObjects.Value> map = instance.getMap("default");
        map.addIndex("state", true);
        for (int i = 0; i < 4; i++) {
            Value v = new Value(i % 2 == 0 ? State.STATE1 : State.STATE2, new ValueType(), i);
            map.put(i, v);
        }

        Collection<SampleObjects.Value> values = map.values(new SqlPredicate("state = 'STATE1'"));
        int[] expectedValues = new int[]{0, 2};
View Full Code Here

            ex.execute(new Runnable() {
                public void run() {
                    final HazelcastInstance hz = nodeFactory.newHazelcastInstance(config);
                    final String name = UuidUtil.buildRandomUuidString();
                    final IMap<Object, Value> map = hz.getMap(mapName);
                    map.put(name, new Value(name, 0));
                    map.size()// helper call on nodes to sync partitions.. see issue github.com/hazelcast/hazelcast/issues/1282
                    try {
                        for (int j = 1; j <= runCount; j++) {
                            Value v = map.get(name);
                            v.setIndex(j);
                            map.put(name, v);

                            try {
                                Thread.sleep(rand.nextInt(100) + 1);
                            } 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);
                            countdown.decrementAndGet();
                        }
                    } catch (AssertionError e) {
                        e.printStackTrace();
View Full Code Here

TOP

Related Classes of com.hazelcast.query.SampleObjects.Value

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.