Package com.hazelcast.query

Examples of com.hazelcast.query.Predicate


    @ManagedAnnotation(value = "entrySet", operation = true)
    public String entrySet(String query) {
        Set<Map.Entry> entrySet;
        if (query != null && !query.isEmpty()) {
            Predicate predicate = new SqlPredicate(query);
            entrySet = managedObject.entrySet(predicate);
        } else {
            entrySet = managedObject.entrySet();
        }
View Full Code Here


        assertEquals(size, set.size());
    }

    @Test
    public void testPagingWithFilteringAndComparator() {
        final Predicate lessEqual = Predicates.lessEqual("this", 8);
        final TestComparator comparator = new TestComparator(false, IterationType.VALUE);
        final PagingPredicate predicate = new PagingPredicate(lessEqual, comparator, pageSize);

        Collection<Integer> values = map.values(predicate);
        assertIterableEquals(values, 8, 7, 6, 5, 4);
View Full Code Here

    public void testKeyPaging() {
        map.clear();
        for (int i = 0; i < size; i++) {   // keys [50-1] values [0-49]
            map.put(size - i, i);
        }
        final Predicate lessEqual = Predicates.lessEqual("this", 8); // less than 8
        final TestComparator comparator = new TestComparator(true, IterationType.KEY); //ascending keys
        final PagingPredicate predicate = new PagingPredicate(lessEqual, comparator, pageSize);

        Set<Integer> keySet = map.keySet(predicate);
        assertIterableEquals(keySet, 42, 43, 44, 45, 46);
View Full Code Here

    public void testEqualValuesPaging() {
        for (int i = size; i < 2 * size; i++) { //keys[50-99] values[0-49]
            map.put(i, i - size);
        }

        final Predicate lessEqual = Predicates.lessEqual("this", 8); // entries which has value less than 8
        final TestComparator comparator = new TestComparator(true, IterationType.VALUE); //ascending values
        final PagingPredicate predicate = new PagingPredicate(lessEqual, comparator, pageSize); //pageSize = 5

        Collection<Integer> values = map.values(predicate);
        assertIterableEquals(values, 0, 0, 1, 1, 2);
View Full Code Here

        assertIterableEquals(values, 7, 8, 8);
    }

    @Test
    public void testNextPageAfterResultSetEmpty() {
        final Predicate lessEqual = Predicates.lessEqual("this", 3); // entries which has value less than 3
        final TestComparator comparator = new TestComparator(true, IterationType.VALUE); //ascending values
        final PagingPredicate predicate = new PagingPredicate(lessEqual, comparator, pageSize); //pageSize = 5

        Collection<Integer> values = map.values(predicate);
        assertIterableEquals(values, 0, 1, 2, 3);
View Full Code Here

    private void mapPagingPredicateEmployeeObjectWithOrderedIndex(int maxEmployee) {
        final IMap<Integer, Employee> map = makeEmployeeMap(maxEmployee);

        map.addIndex("id", true);

        Predicate pred = Predicates.lessThan("id", 2);
        PagingPredicate predicate = new PagingPredicate(pred, 2);

        Collection<Employee> values;

        values = map.values(predicate);
View Full Code Here

        final int minId = 10;
        final int maxId = 15;
        final int pageSz = 5;

        IMap<Integer, Employee> map = makeEmployeeMap(1000);
        Predicate p = Predicates.between("id", minId, maxId);

        List<Employee> expected = new ArrayList<Employee>();
        for (Employee e : map.values()) {
            if(e.getId() >= minId && e.getId() <= maxId){
                expected.add(e);
View Full Code Here

    public void lessThanPredicateWithEmployeeTest() {
        final int maxId = 500;
        final int pageSz = 5;

        IMap<Integer, Employee> map = makeEmployeeMap(1000);
        Predicate p = Predicates.lessThan("id", maxId);

        List<Employee> expected = new ArrayList<Employee>();
        for (Employee e : map.values()) {
            if (e.getId() < maxId){
                expected.add(e);
View Full Code Here

    public void equalsPredicateWithEmployeeTest() {
        final String name = Employee.getRandomName();
        final int pageSz = 5;

        IMap<Integer, Employee> map = makeEmployeeMap(1000);
        Predicate p = Predicates.equal("name", name);

        List<Employee> expected = new ArrayList<Employee>();
        for (Employee e : map.values()) {
            if (e.getName().equals(name)) {
                expected.add(e);
View Full Code Here

            map.put(i, new Employee(i));
        }

        map.addIndex("id", true);

        Predicate pred = Predicates.between("id", START_ID_FOR_QUERY, FINISH_ID_FOR_QUERY);

        PagingPredicate predicate = new PagingPredicate(pred, PAGE_SIZE);
        Collection<Employee> values;
        int passedPageCount = 0;
View Full Code Here

TOP

Related Classes of com.hazelcast.query.Predicate

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.