当前位置: 首页>>代码示例>>Java>>正文


Java ScanParams.count方法代码示例

本文整理汇总了Java中redis.clients.jedis.ScanParams.count方法的典型用法代码示例。如果您正苦于以下问题:Java ScanParams.count方法的具体用法?Java ScanParams.count怎么用?Java ScanParams.count使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在redis.clients.jedis.ScanParams的用法示例。


在下文中一共展示了ScanParams.count方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: scan

import redis.clients.jedis.ScanParams; //导入方法依赖的package包/类
/**
 * 返回指定数量的匹配值
 * 
 * @param cursor
 * @param count
 * @param patterns
 * @return
 */
public ScanResult<String> scan(final String cursor, final Integer count, final String... patterns) {
	ScanParams params = new ScanParams();
	for (String pattern : patterns) {
		params.match(pattern);
	}
	if (null != count) {
		params.count(count);
	}
	if (RedisConstants.isInUse()) {
		return getTemplate().execute(new JedisCallBackHandler<ScanResult<String>>() {
			public ScanResult<String> invoke(Jedis jedis) {
				return jedis.scan(cursor, params);
			}
		});
	} else {
		return null;
	}
}
 
开发者ID:nince-wyj,项目名称:jahhan,代码行数:27,代码来源:Redis.java

示例2: smembers

import redis.clients.jedis.ScanParams; //导入方法依赖的package包/类
public Set<String> smembers(String key) {
	logger.trace("smembers {}", key);
	JedisCommands client = dynoClient;
	Set<String> r = new HashSet<>();
	int cursor = 0;
	ScanParams sp = new ScanParams();
	sp.count(50);

	do {
		ScanResult<String> sr = client.sscan(key, "" + cursor, sp);
		cursor = Integer.parseInt(sr.getStringCursor());
		r.addAll(sr.getResult());

	} while (cursor > 0);

	return r;

}
 
开发者ID:Netflix,项目名称:conductor,代码行数:19,代码来源:DynoProxy.java

示例3: hscan

import redis.clients.jedis.ScanParams; //导入方法依赖的package包/类
/**
 * 命令用于迭代哈希键中的键值对
 * 
 * @param key
 * @param cursor
 * @param count
 * @param patterns
 * @return
 */
public ScanResult<Entry<String, String>> hscan(final String key, final String cursor, final Integer count,
		final String... patterns) {
	ScanParams params = new ScanParams();
	for (String pattern : patterns) {
		params.match(pattern);
	}
	if (null != count) {
		params.count(count);
	}
	if (RedisConstants.isInUse()) {
		return getTemplate().execute(new JedisCallBackHandler<ScanResult<Entry<String, String>>>() {
			public ScanResult<Entry<String, String>> invoke(Jedis jedis) {
				return jedis.hscan(key, cursor, params);
			}
		});
	} else {
		return null;
	}
}
 
开发者ID:nince-wyj,项目名称:jahhan,代码行数:29,代码来源:Redis.java

示例4: scan

import redis.clients.jedis.ScanParams; //导入方法依赖的package包/类
/**
 * 返回指定数量的匹配值
 * 
 * @param cursor
 * @param count
 * @param patterns
 * @return
 */
public ScanResult<String> scan(final String cursor, final Integer count, final String... patterns) {
	ScanParams params = new ScanParams();
	for (String pattern : patterns) {
		params.match(pattern);
	}
	if (null != count) {
		params.count(count);
	}
	if (RedisConstants.isInUse()) {
		return getTemplate().executeRead(new JedisCallBackHandler<ScanResult<String>>() {
			public ScanResult<String> invoke(Jedis jedis) {
				return jedis.scan(cursor, params);
			}
		});
	} else {
		return null;
	}
}
 
开发者ID:nince-wyj,项目名称:jahhan,代码行数:27,代码来源:Redis.java

示例5: hscan

import redis.clients.jedis.ScanParams; //导入方法依赖的package包/类
/**
 * 命令用于迭代哈希键中的键值对
 * 
 * @param key
 * @param cursor
 * @param count
 * @param patterns
 * @return
 */
public ScanResult<Entry<String, String>> hscan(final String key, final String cursor, final Integer count,
		final String... patterns) {
	ScanParams params = new ScanParams();
	for (String pattern : patterns) {
		params.match(pattern);
	}
	if (null != count) {
		params.count(count);
	}
	if (RedisConstants.isInUse()) {
		return getTemplate().executeRead(new JedisCallBackHandler<ScanResult<Entry<String, String>>>() {
			public ScanResult<Entry<String, String>> invoke(Jedis jedis) {
				return jedis.hscan(key, cursor, params);
			}
		});
	} else {
		return null;
	}
}
 
开发者ID:nince-wyj,项目名称:jahhan,代码行数:29,代码来源:Redis.java

示例6: setup

import redis.clients.jedis.ScanParams; //导入方法依赖的package包/类
@Override
public void setup(OperatorContext context)
{
  super.setup(context);
  sleepTimeMillis = context.getValue(context.SPIN_MILLIS);
  getWindowDataManager().setup(context);
  this.context = context;
  scanOffset = 0;
  scanComplete = false;
  scanParameters = new ScanParams();
  scanParameters.count(scanCount);

  // For the 1st window after checkpoint, windowID - 1 would not have recovery
  // offset stored in windowDataManager
  // But recoveryOffset is non-transient, so will be recovered with
  // checkPointing
  // Offset recovery from idempotency storage can be skipped in this case
  scanOffset = recoveryState.scanOffsetAtBeginWindow;
  skipOffsetRecovery = true;
}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:21,代码来源:AbstractRedisInputOperator.java

示例7: hscan_match_count

import redis.clients.jedis.ScanParams; //导入方法依赖的package包/类
private ScanResult<Map.Entry<String, String>> hscan_match_count(Jedis j, String key, String cursor, String pattern, int count) {
	ScanParams param = new ScanParams();
	param.match(pattern);
	param.count(count);
	redis.clients.jedis.ScanResult<Map.Entry<String, String>> sr = j.hscan(key, cursor, param);
	return new ScanResult<Map.Entry<String, String>>(sr.getStringCursor(), sr.getResult());
}
 
开发者ID:mindwind,项目名称:craft-atom,代码行数:8,代码来源:DefaultRedis.java

示例8: setScanParms

import redis.clients.jedis.ScanParams; //导入方法依赖的package包/类
private ScanParams setScanParms()
{
    if (split.getKeyDataType() == RedisDataType.STRING) {
        ScanParams scanParms = new ScanParams();
        scanParms.count(redisJedisManager.getRedisConnectorConfig().getRedisScanCount());

        // when Redis key string follows "schema:table:*" format
        // scan command can efficiently query tables
        // by returning matching keys
        // the alternative is to set key-prefix-schema-table to false
        // and treat entire redis as single schema , single table
        // redis Hash/Set types are to be supported - they can also be
        // used to filter out table data

        // "default" schema is not prefixed to the key

        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;
}
 
开发者ID:y-lan,项目名称:presto,代码行数:30,代码来源:RedisRecordCursor.java

示例9: scan_match_count

import redis.clients.jedis.ScanParams; //导入方法依赖的package包/类
private ScanResult<String> scan_match_count(Jedis j, String cursor, String pattern, int count) {
	ScanParams param = new ScanParams();
	param.match(pattern);
	param.count(count);
	redis.clients.jedis.ScanResult<String> sr = j.scan(cursor, param);
	return new ScanResult<String>(sr.getStringCursor(), sr.getResult());
}
 
开发者ID:mindwind,项目名称:craft-atom,代码行数:8,代码来源:DefaultRedis.java

示例10: sscan_match_count

import redis.clients.jedis.ScanParams; //导入方法依赖的package包/类
private ScanResult<String> sscan_match_count(Jedis j, String key, String cursor, String pattern, int count) {
	ScanParams param = new ScanParams();
	param.match(pattern);
	param.count(count);
	redis.clients.jedis.ScanResult<String> sr = j.sscan(key, cursor, param);
	return new ScanResult<String>(sr.getStringCursor(), sr.getResult());
}
 
开发者ID:mindwind,项目名称:craft-atom,代码行数:8,代码来源:DefaultRedis.java

示例11: zscan_match_count

import redis.clients.jedis.ScanParams; //导入方法依赖的package包/类
private ScanResult<Map.Entry<String, Double>> zscan_match_count(Jedis j, String key, String cursor, String pattern, int count) {
	ScanParams param = new ScanParams();
	param.match(pattern);
	param.count(count);
	redis.clients.jedis.ScanResult<Tuple> sr = j.zscan(key, cursor, param);
	return new ScanResult<Map.Entry<String, Double>>(sr.getStringCursor(), convert(sr.getResult()));
}
 
开发者ID:mindwind,项目名称:craft-atom,代码行数:8,代码来源:DefaultRedis.java

示例12: testIntputOperator

import redis.clients.jedis.ScanParams; //导入方法依赖的package包/类
@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();
  }
}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:61,代码来源:RedisInputOperatorTest.java

示例13: testRecoveryAndIdempotency

import redis.clients.jedis.ScanParams; //导入方法依赖的package包/类
@Test
public void testRecoveryAndIdempotency() throws Exception
{
  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");

  RedisKeyValueInputOperator operator = new RedisKeyValueInputOperator();
  operator.setWindowDataManager(new FSWindowDataManager());

  operator.setStore(operatorStore);
  operator.setScanCount(1);
  Attribute.AttributeMap attributeMap = new Attribute.AttributeMap.DefaultAttributeMap();
  CollectorTestSink<Object> sink = new CollectorTestSink<Object>();

  operator.outputPort.setSink(sink);
  OperatorContext context = mockOperatorContext(1, attributeMap);

  try {
    operator.setup(context);
    operator.beginWindow(1);
    operator.emitTuples();
    operator.endWindow();

    int numberOfMessagesInWindow1 = sink.collectedTuples.size();
    sink.collectedTuples.clear();

    operator.beginWindow(2);
    operator.emitTuples();
    operator.endWindow();
    int numberOfMessagesInWindow2 = sink.collectedTuples.size();
    sink.collectedTuples.clear();

    // failure and then re-deployment of operator
    // Re-instantiating to reset values
    operator = new RedisKeyValueInputOperator();
    operator.setWindowDataManager(new FSWindowDataManager());
    operator.setStore(operatorStore);
    operator.setScanCount(1);
    operator.outputPort.setSink(sink);
    operator.setup(context);

    Assert.assertEquals("largest recovery window", 2, operator.getWindowDataManager().getLargestCompletedWindow());

    operator.beginWindow(1);
    operator.emitTuples();
    operator.emitTuples();
    operator.endWindow();

    Assert.assertEquals("num of messages in window 1", numberOfMessagesInWindow1, sink.collectedTuples.size());

    sink.collectedTuples.clear();
    operator.beginWindow(2);
    operator.emitTuples();
    operator.endWindow();
    Assert.assertEquals("num of messages in window 2",numberOfMessagesInWindow2, sink.collectedTuples.size());
  } finally {
    for (Object e : sink.collectedTuples) {
      KeyValPair<String, String> entry = (KeyValPair<String, String>)e;
      testStore.remove(entry.getKey());
    }
    sink.collectedTuples.clear();
    operator.getWindowDataManager().committed(5);
    operator.teardown();
  }
}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:74,代码来源:RedisInputOperatorTest.java

示例14: scan_count

import redis.clients.jedis.ScanParams; //导入方法依赖的package包/类
private ScanResult<String> scan_count(Jedis j, String cursor, int count) {
	ScanParams param = new ScanParams();
	param.count(count);
	redis.clients.jedis.ScanResult<String> sr = j.scan(cursor, param);
	return new ScanResult<String>(sr.getStringCursor(), sr.getResult());
}
 
开发者ID:mindwind,项目名称:craft-atom,代码行数:7,代码来源:DefaultRedis.java

示例15: hscan_count

import redis.clients.jedis.ScanParams; //导入方法依赖的package包/类
private ScanResult<Map.Entry<String, String>> hscan_count(Jedis j, String key, String cursor, int count) {
	ScanParams param = new ScanParams();
	param.count(count);
	redis.clients.jedis.ScanResult<Map.Entry<String, String>> sr = j.hscan(key, cursor, param);
	return new ScanResult<Map.Entry<String, String>>(sr.getStringCursor(), sr.getResult());
}
 
开发者ID:mindwind,项目名称:craft-atom,代码行数:7,代码来源:DefaultRedis.java


注:本文中的redis.clients.jedis.ScanParams.count方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。