void ClientTxnMapTest::testKeySetAndValuesWithPredicates() { std::string name = "testKeysetAndValuesWithPredicates"; IMap<Employee, Employee> map = client->getMap<Employee, Employee>(name); Employee emp1("abc-123-xvz", 34); Employee emp2("abc-123-xvz", 20); map.put(emp1, emp1); TransactionContext context = client->newTransactionContext(); context.beginTransaction(); TransactionalMap<Employee, Employee> txMap = context.getMap<Employee, Employee>(name); assertNull(txMap.put(emp2, emp2).get()); assertEqual(2, (int)txMap.size()); assertEqual(2, (int)txMap.keySet().size()); query::SqlPredicate predicate("a = 10"); assertEqual(0, (int)txMap.keySet(&predicate).size()); assertEqual(0, (int)txMap.values(&predicate).size()); predicate.setSql("a >= 10"); assertEqual(2, (int)txMap.keySet(&predicate).size()); assertEqual(2, (int)txMap.values(&predicate).size()); context.commitTransaction(); assertEqual(2, (int)map.size()); assertEqual(2, (int)map.values().size()); }
void ClientTxnMapTest::testKeySetValues() { std::string name = "testKeySetValues"; IMap<std::string, std::string> map = client->getMap<std::string, std::string>(name); map.put("key1", "value1"); map.put("key2", "value2"); TransactionContext context = client->newTransactionContext(); context.beginTransaction(); TransactionalMap<std::string, std::string> txMap = context.getMap<std::string, std::string>(name); assertNull(txMap.put("key3", "value3").get()); assertEqual(3, (int)txMap.size()); assertEqual(3, (int)txMap.keySet().size()); assertEqual(3, (int)txMap.values().size()); context.commitTransaction(); assertEqual(3, (int)map.size()); assertEqual(3, (int)map.keySet().size()); assertEqual(3, (int)map.values().size()); }