This post originated from an RSS feed registered with Java Buzz
by Talip Ozturk.
Original Post: Distributed Query API
Feed Title: Shared Memory
Feed URL: http://www.jroller.com/talipozturk/feed/entries/rss
Feed Description: about java, jcache, jini, javaspaces, distributed data structures and a little bit of me and life.
Hazelcast partitions your data and spreads across cluster of servers. You can, of course, get your map entries by key or iterate all entries but being able to query the distributed map would be very nice. We are working on the query feature these days and we already got most of it working. We are quite flexible in terms of query API and before the release we want to make sure that the default Query API is right. We can surely support more than one API !
Let's say we have a Employee class:
public class Employee implements Serializable {
String name;
int age;
boolean active;
double salary;
public Employee(String name, int age, boolean live, double price) {
this.name = name;
this.age = age;
this.active = live;
this.salary = price;
}
public Employee() {
}
public String getName() {
return name;
}
public int getAge() {
return age;
}
public double getSalary() {
return salary;
}
public boolean isActive() {
return active;
}
}
1. Predicates like and, equal, get, lessThan etc. can be static methods so that they can be imported.
//active employees with age of 23
Set IMap.entrySet(and(equal(get("isActive"), true), equal(get("getAge"), 23)));
2. More like JPA Criteria API:
DomainObject do= IMap.getDomainObject();
Set IMap.entrySet(do.get("isActive").equal(true).and(do.get("getAge").equal(23)));
This is SQL like 'as you speak' kinda lingo.
3. Complete Predicate API like Google Collections or Apache Common Collections have:
Predicate p = new AndPredicate (new EqualPredicate("isActive", true), new EqualPredicate ("getAge", 23));
Set IMap.entrySet(p)
I like standards so I prefer JPA Criteria like API. What do you think? What would you care the most?