use of redis.clients.jedis.ScanParams in project jedis by xetorthio.
the class AllKindOfValuesCommandsTest method scanCount.
@Test
public void scanCount() {
ScanParams params = new ScanParams();
params.count(2);
for (int i = 0; i < 10; i++) {
jedis.set("a" + i, "a" + i);
}
ScanResult<String> result = jedis.scan(SCAN_POINTER_START, params);
assertFalse(result.getResult().isEmpty());
// binary
params = new ScanParams();
params.count(2);
jedis.set(bfoo1, bbar);
jedis.set(bfoo2, bbar);
jedis.set(bfoo3, bbar);
ScanResult<byte[]> bResult = jedis.scan(SCAN_POINTER_START_BINARY, params);
assertFalse(bResult.getResult().isEmpty());
}
use of redis.clients.jedis.ScanParams in project jedis by xetorthio.
the class SetCommandsTest method sscanMatch.
@Test
public void sscanMatch() {
ScanParams params = new ScanParams();
params.match("a*");
jedis.sadd("foo", "b", "a", "aa");
ScanResult<String> result = jedis.sscan("foo", SCAN_POINTER_START, params);
assertEquals(SCAN_POINTER_START, result.getCursor());
assertFalse(result.getResult().isEmpty());
// binary
params = new ScanParams();
params.match(bbarstar);
jedis.sadd(bfoo, bbar1, bbar2, bbar3);
ScanResult<byte[]> bResult = jedis.sscan(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 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());
}
use of redis.clients.jedis.ScanParams in project jedis by xetorthio.
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 apex-malhar by apache.
the class RedisInputOperatorTest method testIntputOperator.
@Test
public void testIntputOperator() throws IOException {
this.operatorStore = new RedisStore();
this.testStore = new RedisStore();
testStore.connect();
ScanParams params = new ScanParams();
params.count(1);
testStore.put("test_abc", "789");
testStore.put("test_def", "456");
testStore.put("test_ghi", "123");
try {
LocalMode lma = LocalMode.newInstance();
DAG dag = lma.getDAG();
RedisKeyValueInputOperator inputOperator = dag.addOperator("input", new RedisKeyValueInputOperator());
final CollectorModule collector = dag.addOperator("collector", new CollectorModule());
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 = 50000L;
try {
Thread.sleep(1000);
while (System.currentTimeMillis() - startTms < timeout) {
if (CollectorModule.resultMap.size() < 3) {
Thread.sleep(10);
} else {
break;
}
}
} catch (InterruptedException ex) {
//
}
lc.shutdown();
}
}.start();
lc.run();
Assert.assertTrue(CollectorModule.resultMap.contains(new KeyValPair<String, String>("test_abc", "789")));
Assert.assertTrue(CollectorModule.resultMap.contains(new KeyValPair<String, String>("test_def", "456")));
Assert.assertTrue(CollectorModule.resultMap.contains(new KeyValPair<String, String>("test_ghi", "123")));
} finally {
for (KeyValPair<String, String> entry : CollectorModule.resultMap) {
testStore.remove(entry.getKey());
}
testStore.disconnect();
}
}
Aggregations