use of redis.clients.jedis.ScanParams in project jedis by xetorthio.
the class HashesCommandsTest method hscanMatch.
@Test
public void hscanMatch() {
ScanParams params = new ScanParams();
params.match("a*");
jedis.hset("foo", "b", "b");
jedis.hset("foo", "a", "a");
jedis.hset("foo", "aa", "aa");
ScanResult<Map.Entry<String, String>> result = jedis.hscan("foo", SCAN_POINTER_START, params);
assertEquals(SCAN_POINTER_START, result.getCursor());
assertFalse(result.getResult().isEmpty());
// binary
params = new ScanParams();
params.match(bbarstar);
jedis.hset(bfoo, bbar, bcar);
jedis.hset(bfoo, bbar1, bcar);
jedis.hset(bfoo, bbar2, bcar);
jedis.hset(bfoo, bbar3, bcar);
ScanResult<Map.Entry<byte[], byte[]>> bResult = jedis.hscan(bfoo, SCAN_POINTER_START_BINARY, params);
assertArrayEquals(SCAN_POINTER_START_BINARY, bResult.getCursorAsBytes());
assertFalse(bResult.getResult().isEmpty());
}
use of redis.clients.jedis.ScanParams in project jedis by xetorthio.
the class SetCommandsTest method sscanCount.
@Test
public void sscanCount() {
ScanParams params = new ScanParams();
params.count(2);
jedis.sadd("foo", "a1", "a2", "a3", "a4", "a5");
ScanResult<String> result = jedis.sscan("foo", SCAN_POINTER_START, params);
assertFalse(result.getResult().isEmpty());
// binary
params = new ScanParams();
params.count(2);
jedis.sadd(bfoo, bbar1, bbar2, bbar3);
ScanResult<byte[]> bResult = jedis.sscan(bfoo, SCAN_POINTER_START_BINARY, params);
assertFalse(bResult.getResult().isEmpty());
}
use of redis.clients.jedis.ScanParams in project apex-malhar by apache.
the class RedisPOJOOperatorTest method testInputOperator.
@Test
public void testInputOperator() throws IOException {
@SuppressWarnings("unused") Class<?> clazz = org.codehaus.janino.CompilerFactory.class;
this.operatorStore = new RedisStore();
this.testStore = new RedisStore();
testStore.connect();
ScanParams params = new ScanParams();
params.count(100);
Map<String, String> value = new HashMap<String, String>();
value.put("Column1", "abc");
value.put("Column2", "1");
Map<String, String> value1 = new HashMap<String, String>();
value1.put("Column1", "def");
value1.put("Column2", "2");
Map<String, String> value2 = new HashMap<String, String>();
value2.put("Column1", "ghi");
value2.put("Column2", "3");
testStore.put("test_abc_in", value);
testStore.put("test_def_in", value1);
testStore.put("test_ghi_in", value2);
try {
LocalMode lma = LocalMode.newInstance();
DAG dag = lma.getDAG();
RedisPOJOInputOperator inputOperator = dag.addOperator("input", new RedisPOJOInputOperator());
final ObjectCollectorModule collector = dag.addOperator("collector", new ObjectCollectorModule());
ArrayList<FieldInfo> fields = new ArrayList<FieldInfo>();
fields.add(new FieldInfo("Column1", "stringValue", SupportType.STRING));
fields.add(new FieldInfo("Column2", "intValue", SupportType.INTEGER));
inputOperator.setDataColumns(fields);
inputOperator.setOutputClass(TestClass.class.getName());
inputOperator.setStore(operatorStore);
dag.addStream("stream", inputOperator.outputPort, collector.inputPort);
final LocalMode.Controller lc = lma.getController();
new Thread("LocalClusterController") {
@Override
public void run() {
long startTms = System.currentTimeMillis();
long timeout = 10000L;
try {
Thread.sleep(1000);
while (System.currentTimeMillis() - startTms < timeout) {
if (ObjectCollectorModule.resultMap.size() < 3) {
Thread.sleep(10);
} else {
break;
}
}
} catch (InterruptedException ex) {
//
}
lc.shutdown();
}
}.start();
lc.run();
Assert.assertTrue(ObjectCollectorModule.resultMap.containsKey("test_abc_in"));
Assert.assertTrue(ObjectCollectorModule.resultMap.containsKey("test_def_in"));
Assert.assertTrue(ObjectCollectorModule.resultMap.containsKey("test_ghi_in"));
TestClass a = (TestClass) ObjectCollectorModule.resultMap.get("test_abc_in");
Assert.assertNotNull(a);
Assert.assertEquals("abc", a.stringValue);
Assert.assertEquals("1", a.intValue.toString());
} finally {
for (KeyValPair<String, String> entry : CollectorModule.resultMap) {
testStore.remove(entry.getKey());
}
testStore.disconnect();
}
}
use of redis.clients.jedis.ScanParams in project new-cloud by xie-summer.
the class SortedSetCommandsTest method zscanCount.
@Test
public void zscanCount() {
ScanParams params = new ScanParams();
params.count(2);
jedis.zadd("foo", 1, "a1");
jedis.zadd("foo", 2, "a2");
jedis.zadd("foo", 3, "a3");
jedis.zadd("foo", 4, "a4");
jedis.zadd("foo", 5, "a5");
ScanResult<Tuple> result = jedis.zscan("foo", SCAN_POINTER_START, params);
assertFalse(result.getResult().isEmpty());
// binary
params = new ScanParams();
params.count(2);
jedis.zadd(bfoo, 2, bbar1);
jedis.zadd(bfoo, 1, bbar2);
jedis.zadd(bfoo, 11, bbar3);
ScanResult<Tuple> bResult = jedis.zscan(bfoo, SCAN_POINTER_START_BINARY, params);
assertFalse(bResult.getResult().isEmpty());
}
use of redis.clients.jedis.ScanParams in project new-cloud by xie-summer.
the class SortedSetCommandsTest method zscanMatch.
@Test
public void zscanMatch() {
ScanParams params = new ScanParams();
params.match("a*");
jedis.zadd("foo", 2, "b");
jedis.zadd("foo", 1, "a");
jedis.zadd("foo", 11, "aa");
ScanResult<Tuple> result = jedis.zscan("foo", SCAN_POINTER_START, params);
assertEquals(SCAN_POINTER_START, result.getCursor());
assertFalse(result.getResult().isEmpty());
// binary
params = new ScanParams();
params.match(bbarstar);
jedis.zadd(bfoo, 2, bbar1);
jedis.zadd(bfoo, 1, bbar2);
jedis.zadd(bfoo, 11, bbar3);
ScanResult<Tuple> bResult = jedis.zscan(bfoo, SCAN_POINTER_START_BINARY, params);
assertArrayEquals(SCAN_POINTER_START_BINARY, bResult.getCursorAsBytes());
assertFalse(bResult.getResult().isEmpty());
}
Aggregations