Пример #1
0
    def test_querying_over_keys_with_hazelcast_json_value(self):
        json_value = HazelcastJsonValue({"a": 1})
        json_value2 = HazelcastJsonValue({"a": 3})

        self.map.put(json_value, 1)
        self.map.put(json_value2, 2)

        results = self.map.key_set(greater("__key.a", 2))

        self.assertEqual(1, len(results))
        self.assertEqual(json_value2.to_string(), results[0].to_string())
Пример #2
0
    def test_querying_over_values_with_hazelcast_json_value(self):
        json_value = HazelcastJsonValue({"a": 1})
        json_value2 = HazelcastJsonValue({"a": 3})

        self.map.put(1, json_value)
        self.map.put(2, json_value2)

        results = self.map.values(greater("a", 2))

        self.assertEqual(1, len(results))
        self.assertEqual(json_value2.to_string(), results[0].to_string())
 def test_greater_than(self):
     self.fill_map_numeric()
     predicate = greater("this", 10)
     self.assertCountEqual(self.map.key_set(predicate), list(range(11,
                                                                   100)))
 "APortable":
 _portable,
 "ArrayList": [None, _non_null_list],
 "LinkedList": [None, _non_null_list],
 "TruePredicate":
 predicate.true(),
 "FalsePredicate":
 predicate.false(),
 "SqlPredicate":
 predicate.sql(_sql_string),
 "EqualPredicate":
 predicate.equal(_sql_string, REFERENCE_OBJECTS["Integer"]),
 "NotEqualPredicate":
 predicate.not_equal(_sql_string, REFERENCE_OBJECTS["Integer"]),
 "GreaterLessPredicate":
 predicate.greater(_sql_string, REFERENCE_OBJECTS["Integer"]),
 "BetweenPredicate":
 predicate.between(_sql_string, REFERENCE_OBJECTS["Integer"],
                   REFERENCE_OBJECTS["Integer"]),
 "LikePredicate":
 predicate.like(_sql_string, _sql_string),
 "ILikePredicate":
 predicate.ilike(_sql_string, _sql_string),
 "InPredicate":
 predicate.in_(_sql_string, REFERENCE_OBJECTS["Integer"],
               REFERENCE_OBJECTS["Integer"]),
 "RegexPredicate":
 predicate.regex(_sql_string, _sql_string),
 "AndPredicate":
 predicate.and_(
     predicate.sql(_sql_string),
Пример #5
0
import hazelcast

from hazelcast.core import HazelcastJsonValue
from hazelcast.predicate import and_, greater, sql

client = hazelcast.HazelcastClient()
employees_map = client.get_map("employees").blocking()

alice = "{\"name\": \"Alice\", \"age\": 35}"
andy = "{\"name\": \"Andy\", \"age\": 22}"
bob = {"name": "Bob", "age": 37}

# HazelcastJsonValue can be constructed from JSON strings
employees_map.put(0, HazelcastJsonValue(alice))
employees_map.put(1, HazelcastJsonValue(andy))

# or from JSON serializable objects
employees_map.put(2, HazelcastJsonValue(bob))

# Employees whose name starts with 'A' and age is greater than 30
predicate = and_(sql("name like A%"), greater("age", 30))

values = employees_map.values(predicate)

for value in values:
    print(value.to_string())  # As JSON string
    print(value.loads())  # As Python object

client.shutdown()