public IdentifiedDataSerializable createNew(Integer arg) { return new SqlPredicate(); } };
@Override protected Collection<?> doListKeys(String keyPattern) { Assert.hasText(keyPattern, "'keyPattern' must not be empty"); keyPattern = keyPattern.replaceAll("\\*", "%"); SqlPredicate sqlPredicate = new SqlPredicate("__key like " + keyPattern); return this.map.values(sqlPredicate); }
public void run() { IMap map = hazelcast.getMap("myMap"); Iterator it = map.localKeySet(new SqlPredicate("name=" + random.nextInt(10000))).iterator(); while (it.hasNext()) { it.next(); } } }, 10);
public void run() { IMap map = hazelcast.getMap("myMap"); Iterator it = map.keySet(new SqlPredicate("name=" + random.nextInt(10000))).iterator(); while (it.hasNext()) { it.next(); } } }, 10);
public void run() { IMap map = hazelcast.getMap("myMap"); Iterator it = map.entrySet(new SqlPredicate("year=" + random.nextInt(100))).iterator(); while (it.hasNext()) { it.next(); } } }, 1);
public void run() { IMap map = hazelcast.getMap("myMap"); Iterator it = map.entrySet(new SqlPredicate("name=" + random.nextInt(10000))).iterator(); while (it.hasNext()) { it.next(); } } }, 10);
@Override public Collection<Value> sql(String query) throws NullPointerException { requireNonNull(query, "sql is required"); return sql(new SqlPredicate(query)); }
@Setup public void setUp() { map = targetInstance.getMap(name); innerPredicate = new SqlPredicate(innerPredicateQuery); }
/** * QUERY map with a sql like syntax (see http://www.hazelcast.com/) */ private void query(String query, Exchange exchange) { Collection<Object> result; if (ObjectHelper.isNotEmpty(query)) { result = this.cache.values(new SqlPredicate(query)); } else { result = this.cache.values(); } exchange.getOut().setBody(result); }
@SuppressWarnings("unchecked") @BeforeRun public void beforeRun(ThreadState state) { state.predicate = new SqlPredicate(query.getSql()); }
public static void main(String[] args) { Config config = new Config(); config.setProperty("hazelcast.map.entry.filtering.natural.event.types", "true"); HazelcastInstance hz = Hazelcast.newHazelcastInstance(config); IMap<String, String> map = hz.getMap("map"); map.addEntryListener(new MyEntryListener(), new SqlPredicate("name=peter"), true); System.out.println("EntryListener registered"); }
public static void main(String[] args) { HazelcastInstance hz = Hazelcast.newHazelcastInstance(); IMap<String, Customer> map = hz.getMap("map"); map.put("1", new Customer("peter", true, 36)); map.put("2", new Customer("john", false, 40)); map.put("3", new Customer("roger", true, 20)); Set<Customer> employees = (Set<Customer>) map.values(new SqlPredicate("active AND age < 30")); System.out.println("Employees: " + employees); Hazelcast.shutdownAll(); } }
@Override public Object execute(Object[] parameters) { String queryStringTemplate = queryMethod.getAnnotatedQuery(); String queryString = String.format(queryStringTemplate, parameters); SqlPredicate sqlPredicate = new SqlPredicate(queryString); return getMap(keySpace).values(sqlPredicate); }
@SuppressWarnings({"rawtypes", "unchecked"}) @Override protected void doStart() { setHazelcastRegisteredEventListenerId(((IMap<?, ?>) this.distributedObject) .addEntryListener((MapListener) new HazelcastEntryListener(), new SqlPredicate(this.predicate), this.includeValue)); }
@TimeStep(prob = 0) public void sqlString(ThreadState state) { int id = state.randomInt(itemCount); SqlPredicate predicate = new SqlPredicate("id=" + id); map.values(predicate); }
public static void main(String[] args) throws ParseException { HazelcastInstance hz = Hazelcast.newHazelcastInstance(); IMap<Integer, Customer> map = hz.getMap("customers"); map.put(1, new Customer("James", "Bond", 1975)); map.put(2, new Customer("Eathen", "Hunt", 1965)); map.put(3, new Customer("Roger", "Moore", 1995)); // we're using a custom attribute 'age' which is provided by the 'AgeExtractor' Set<Customer> customers = (Set<Customer>) map.values(new SqlPredicate("age < 50")); System.out.println("Customers: " + customers); Hazelcast.shutdownAll(); } }
public static void main(String[] args) throws ParseException { HazelcastInstance hz = Hazelcast.newHazelcastInstance(); IMap<Integer, Car> map = hz.getMap("cars"); map.put(1, new Car("Audi Q7", 250, 22000)); map.put(2, new Car("BMW X5", 312, 34000)); map.put(3, new Car("Porsche Cayenne", 408, 57000)); // we're using a custom attribute called 'attribute' which is provided by the 'CarAttributeExtractor' // we are also passing an argument 'mileage' to the extractor Set<Car> cars = (Set<Car>) map.values(new SqlPredicate("attribute[mileage] < 30000")); System.out.println("Cars: " + cars); Hazelcast.shutdownAll(); } }
public static void main(String[] args) throws ParseException { HazelcastInstance hz = Hazelcast.newHazelcastInstance(); IMap<Integer, Car> map = hz.getMap("cars"); map.put(1, new Car("Audi Q7").setTrip(1000, 3000)); map.put(2, new Car("BMW X5").setTrip(3000, 5000)); map.put(3, new Car("Porsche Cayenne").setTrip(2000, 8000)); // we're using a custom 'tripDistance' attribute which is provided by the 'CarTripDistanceExtractor' Set<Car> cars = (Set<Car>) map.values(new SqlPredicate("tripDistance < 3000")); System.out.println("Cars: " + cars); Hazelcast.shutdownAll(); } }
public static void main(String[] args) { HazelcastInstance hz = Hazelcast.newHazelcastInstance(); IMap<Integer, Person> map = hz.getMap("map"); map.put(1, new Person("Georg", limb("left-leg"), limb("right-leg"))); map.put(2, new Person("Peter", limb("left-hand"), limb("right-hand"))); map.put(3, new Person("Hans", limb("left-leg"), limb("right-leg"))); map.put(4, new Person("Stefanie", limb("left-arm"), limb("right-arm"))); Set<Person> employees = (Set<Person>) map.values(new SqlPredicate("limbs[any].name == right-leg")); System.out.println("People: " + employees); Hazelcast.shutdownAll(); }
public static void main(String[] args) { Config config = new Config(); config.getSerializationConfig().addPortableFactory(PersonPortableFactory.FACTORY_ID, new PersonPortableFactory()); HazelcastInstance hz = Hazelcast.newHazelcastInstance(config); IMap<Integer, PersonPortable> map = hz.getMap("map"); map.put(1, new PersonPortable("Georg", limb("left-leg"), limb("right-leg"))); map.put(2, new PersonPortable("Peter", limb("left-hand"), limb("right-hand"))); map.put(3, new PersonPortable("Hans", limb("left-leg"), limb("right-leg"))); map.put(4, new PersonPortable("Stefanie", limb("left-arm"), limb("right-arm"))); Set<PersonPortable> employees = (Set<PersonPortable>) map.values(new SqlPredicate("limbs[any].name == right-leg")); System.out.println("People: " + employees); Hazelcast.shutdownAll(); }