- 
                Notifications
    You must be signed in to change notification settings 
- Fork 10
Home
        ajermakovics edited this page Nov 15, 2014 
        ·
        7 revisions
      
    Welcome to the lambda2sql wiki!
Example using Hazelcast IMap:
    public static void main( String[] args )
    {
    	Lambda2Sql.init();
    	HazelcastInstance hz = Hazelcast.newHazelcastInstance();
    	IMap<Integer, Employee> map = hz.getMap("employees");
    	map.put(1, new Employee("alice", 30, true, 100));
    	map.put(2, new Employee("bob", 40, true, 200));
        // run a type safe, distributed query. quite readable as well!
    	Collection<Employee> vals;
    	vals = values(map, e -> e.isActive() && e.getAge() > 30 );
    	System.out.println(vals.size());
    }
	static <T> Predicate<?, T> toSqlPred(java.util.function.Predicate<T> p) {
    	return new SqlPredicate( Lambda2Sql.toSql( p ) );
	}
	static <T> Collection<T> values(IMap<?, T> map, java.util.function.Predicate<T> p) {
    	return map.values( toSqlPred(p) );
	}