Search in sources :

Example 11 with ScanParams

use of redis.clients.jedis.ScanParams in project presto by prestodb.

the class RedisRecordCursor method setScanParms.

private ScanParams setScanParms() {
    if (split.getKeyDataType() == RedisDataType.STRING) {
        ScanParams scanParms = new ScanParams();
        scanParms.count(redisJedisManager.getRedisConnectorConfig().getRedisScanCount());
        if (redisJedisManager.getRedisConnectorConfig().isKeyPrefixSchemaTable()) {
            String keyMatch = "";
            if (!split.getSchemaName().equals("default")) {
                keyMatch = split.getSchemaName() + Character.toString(redisJedisManager.getRedisConnectorConfig().getRedisKeyDelimiter());
            }
            keyMatch = keyMatch + split.getTableName() + Character.toString(redisJedisManager.getRedisConnectorConfig().getRedisKeyDelimiter()) + "*";
            scanParms.match(keyMatch);
        }
        return scanParms;
    }
    return null;
}
Also used : ScanParams(redis.clients.jedis.ScanParams)

Example 12 with ScanParams

use of redis.clients.jedis.ScanParams in project cachecloud by sohutv.

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());
}
Also used : ScanParams(redis.clients.jedis.ScanParams) Test(org.junit.Test)

Example 13 with ScanParams

use of redis.clients.jedis.ScanParams in project cachecloud by sohutv.

the class AllKindOfValuesCommandsTest method scanMatch.

@Test
public void scanMatch() {
    ScanParams params = new ScanParams();
    params.match("a*");
    jedis.set("b", "b");
    jedis.set("a", "a");
    jedis.set("aa", "aa");
    ScanResult<String> result = jedis.scan(SCAN_POINTER_START, params);
    assertEquals(SCAN_POINTER_START, result.getCursor());
    assertFalse(result.getResult().isEmpty());
    // binary
    params = new ScanParams();
    params.match(bfoostar);
    jedis.set(bfoo1, bbar);
    jedis.set(bfoo2, bbar);
    jedis.set(bfoo3, bbar);
    ScanResult<byte[]> bResult = jedis.scan(SCAN_POINTER_START_BINARY, params);
    assertArrayEquals(SCAN_POINTER_START_BINARY, bResult.getCursorAsBytes());
    assertFalse(bResult.getResult().isEmpty());
}
Also used : ScanParams(redis.clients.jedis.ScanParams) Test(org.junit.Test)

Example 14 with ScanParams

use of redis.clients.jedis.ScanParams in project jedis by xetorthio.

the class AllKindOfValuesCommandsTest method scanMatch.

@Test
public void scanMatch() {
    ScanParams params = new ScanParams();
    params.match("a*");
    jedis.set("b", "b");
    jedis.set("a", "a");
    jedis.set("aa", "aa");
    ScanResult<String> result = jedis.scan(SCAN_POINTER_START, params);
    assertEquals(SCAN_POINTER_START, result.getCursor());
    assertFalse(result.getResult().isEmpty());
    // binary
    params = new ScanParams();
    params.match(bfoostar);
    jedis.set(bfoo1, bbar);
    jedis.set(bfoo2, bbar);
    jedis.set(bfoo3, bbar);
    ScanResult<byte[]> bResult = jedis.scan(SCAN_POINTER_START_BINARY, params);
    assertArrayEquals(SCAN_POINTER_START_BINARY, bResult.getCursorAsBytes());
    assertFalse(bResult.getResult().isEmpty());
}
Also used : ScanParams(redis.clients.jedis.ScanParams) Test(org.junit.Test)

Example 15 with ScanParams

use of redis.clients.jedis.ScanParams in project jedis by xetorthio.

the class HashesCommandsTest method hscanCount.

@Test
public void hscanCount() {
    ScanParams params = new ScanParams();
    params.count(2);
    for (int i = 0; i < 10; i++) {
        jedis.hset("foo", "a" + i, "a" + i);
    }
    ScanResult<Map.Entry<String, String>> result = jedis.hscan("foo", SCAN_POINTER_START, params);
    assertFalse(result.getResult().isEmpty());
    // binary
    params = new ScanParams();
    params.count(2);
    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);
    assertFalse(bResult.getResult().isEmpty());
}
Also used : ScanParams(redis.clients.jedis.ScanParams) Test(org.junit.Test)

Aggregations

ScanParams (redis.clients.jedis.ScanParams)31 Test (org.junit.Test)27 Tuple (redis.clients.jedis.Tuple)6 DAG (com.datatorrent.api.DAG)2 LocalMode (com.datatorrent.api.LocalMode)2 KeyValPair (org.apache.apex.malhar.lib.util.KeyValPair)2 JSONObject (com.alibaba.fastjson.JSONObject)1 Attribute (com.datatorrent.api.Attribute)1 OperatorContext (com.datatorrent.api.Context.OperatorContext)1 CacheConfigBean (info.xiancloud.core.support.cache.CacheConfigBean)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1 OperatorContextTestHelper.mockOperatorContext (org.apache.apex.malhar.lib.helper.OperatorContextTestHelper.mockOperatorContext)1 CollectorTestSink (org.apache.apex.malhar.lib.testbench.CollectorTestSink)1 FieldInfo (org.apache.apex.malhar.lib.util.FieldInfo)1 FSWindowDataManager (org.apache.apex.malhar.lib.wal.FSWindowDataManager)1 SecurityInfo (org.eclipse.leshan.server.security.SecurityInfo)1 Jedis (redis.clients.jedis.Jedis)1