@Override protected ScanIteration<Entry<byte[], byte[]>> doScan(byte[] key, long cursorId, ScanOptions options) { if (isQueueing() || isPipelined()) { throw new UnsupportedOperationException("'HSCAN' cannot be called in pipeline / transaction mode."); } List<Object> args = new ArrayList<Object>(); args.add(key); args.add(cursorId); if (options.getPattern() != null) { args.add("MATCH"); args.add(options.getPattern()); } if (options.getCount() != null) { args.add("COUNT"); args.add(options.getCount()); } RFuture<MapScanResult<byte[], byte[]>> f = executorService.readAsync(client, key, ByteArrayCodec.INSTANCE, RedisCommands.HSCAN, args.toArray()); MapScanResult<byte[], byte[]> res = syncFuture(f); client = res.getRedisClient(); return new ScanIteration<Entry<byte[], byte[]>>(res.getPos(), res.getValues()); } }.open();
@Override public MapScanResult<Object, Object> decode(List<Object> parts, State state) { return new MapScanResult<Object, Object>((Long)parts.get(0), (Map<Object, Object>)parts.get(1)); }
if (!keysFinished && (keysIter == null || !keysIter.hasNext())) { MapScanResult<Object, Object> res = map.scanIterator(client, keysIterPos); client = res.getRedisClient(); keysIter = res.getMap().entrySet().iterator(); keysIterPos = res.getPos(); if (res.getPos() == 0) { keysFinished = true;
} else if (o instanceof MapScanResult) { MapScanResult scanResult = (MapScanResult) o; Map oldMap = ((MapScanResult) o).getMap(); Map map = (Map) tryHandleReference(oldMap); if (map != oldMap) { MapScanResult<Object, Object> newScanResult = new MapScanResult<Object, Object>(scanResult.getPos(), map); newScanResult.setRedisClient(scanResult.getRedisClient()); return newScanResult; } else {
protected MapScanResult<Object, Object> scanIterator(String name, RedisClient client, long startPos, String pattern, int count) { MapScanResult<Object, Object> res = ((RedissonMap<?, ?>)map).scanIterator(name, client, startPos, pattern, count); Map<HashValue, MapEntry> newstate = new HashMap<HashValue, MapEntry>(state); for (Iterator<Object> iterator = res.getMap().keySet().iterator(); iterator.hasNext();) { Object entry = iterator.next(); MapEntry mapEntry = newstate.remove(toKeyHash(entry)); if (mapEntry != null) { if (mapEntry == MapEntry.NULL) { iterator.remove(); continue; } res.getMap().put(entry, mapEntry.getValue()); } } if (startPos == 0) { for (Entry<HashValue, MapEntry> entry : newstate.entrySet()) { if (entry.getValue() == MapEntry.NULL) { continue; } res.getMap().put(entry.getValue().getKey(), entry.getValue().getValue()); } } return res; }
} else if (o instanceof MapScanResult) { MapScanResult scanResult = (MapScanResult) o; Map oldMap = ((MapScanResult) o).getMap(); Map map = (Map) tryHandleReference(oldMap); if (map != oldMap) { MapScanResult<Object, Object> newScanResult = new MapScanResult<Object, Object>(scanResult.getPos(), map); newScanResult.setRedisClient(scanResult.getRedisClient()); return newScanResult; } else {
protected MapScanResult<Object, Object> scanIterator(String name, RedisClient client, long startPos, String pattern, int count) { MapScanResult<Object, Object> res = ((RedissonMap<?, ?>)map).scanIterator(name, client, startPos, pattern, count); Map<HashValue, MapEntry> newstate = new HashMap<HashValue, MapEntry>(state); for (Iterator<Object> iterator = res.getMap().keySet().iterator(); iterator.hasNext();) { Object entry = iterator.next(); MapEntry mapEntry = newstate.remove(toKeyHash(entry)); if (mapEntry != null) { if (mapEntry == MapEntry.NULL) { iterator.remove(); continue; } res.getMap().put(entry, mapEntry.getValue()); } } if (startPos == 0) { for (Entry<HashValue, MapEntry> entry : newstate.entrySet()) { if (entry.getValue() == MapEntry.NULL) { continue; } res.getMap().put(entry.getValue().getKey(), entry.getValue().getValue()); } } return res; }
@Override protected ScanIteration<Entry<byte[], byte[]>> doScan(byte[] key, long cursorId, ScanOptions options) { if (isQueueing() || isPipelined()) { throw new UnsupportedOperationException("'HSCAN' cannot be called in pipeline / transaction mode."); } List<Object> args = new ArrayList<Object>(); args.add(key); args.add(cursorId); if (options.getPattern() != null) { args.add("MATCH"); args.add(options.getPattern()); } if (options.getCount() != null) { args.add("COUNT"); args.add(options.getCount()); } RFuture<MapScanResult<byte[], byte[]>> f = executorService.readAsync(client, key, ByteArrayCodec.INSTANCE, RedisCommands.HSCAN, args.toArray()); MapScanResult<byte[], byte[]> res = syncFuture(f); client = res.getRedisClient(); return new ScanIteration<Entry<byte[], byte[]>>(res.getPos(), res.getValues()); } }.open();
} else if (o instanceof MapScanResult) { MapScanResult scanResult = (MapScanResult) o; Map oldMap = ((MapScanResult) o).getMap(); Map map = (Map) tryHandleReference(oldMap); if (map != oldMap) { MapScanResult<Object, Object> newScanResult = new MapScanResult<Object, Object>(scanResult.getPos(), map); newScanResult.setRedisClient(scanResult.getRedisClient()); return newScanResult; } else {
if (!keysFinished && (keysIter == null || !keysIter.hasNext())) { MapScanResult<Object, Object> res = map.scanIterator(client, keysIterPos); client = res.getRedisClient(); keysIter = res.getMap().entrySet().iterator(); keysIterPos = res.getPos(); if (res.getPos() == 0) { keysFinished = true;
@Override public MapScanResult<Object, Object> decode(List<Object> parts, State state) { return new MapScanResult<Object, Object>((Long)parts.get(0), (Map<Object, Object>)parts.get(1)); }
protected MapScanResult<Object, Object> scanIterator(String name, RedisClient client, long startPos, String pattern, int count) { MapScanResult<Object, Object> res = ((RedissonMap<?, ?>)map).scanIterator(name, client, startPos, pattern, count); Map<HashValue, MapEntry> newstate = new HashMap<HashValue, MapEntry>(state); for (Iterator<Object> iterator = res.getMap().keySet().iterator(); iterator.hasNext();) { Object entry = iterator.next(); MapEntry mapEntry = newstate.remove(toKeyHash(entry)); if (mapEntry != null) { if (mapEntry == MapEntry.NULL) { iterator.remove(); continue; } res.getMap().put(entry, mapEntry.getValue()); } } if (startPos == 0) { for (Entry<HashValue, MapEntry> entry : newstate.entrySet()) { if (entry.getValue() == MapEntry.NULL) { continue; } res.getMap().put(entry.getValue().getKey(), entry.getValue().getValue()); } } return res; }
@Override protected ScanIteration<Entry<byte[], byte[]>> doScan(byte[] key, long cursorId, ScanOptions options) { if (isQueueing() || isPipelined()) { throw new UnsupportedOperationException("'HSCAN' cannot be called in pipeline / transaction mode."); } List<Object> args = new ArrayList<Object>(); args.add(key); args.add(cursorId); if (options.getPattern() != null) { args.add("MATCH"); args.add(options.getPattern()); } if (options.getCount() != null) { args.add("COUNT"); args.add(options.getCount()); } RFuture<MapScanResult<byte[], byte[]>> f = executorService.readAsync(client, key, ByteArrayCodec.INSTANCE, RedisCommands.HSCAN, args.toArray()); MapScanResult<byte[], byte[]> res = syncFuture(f); client = res.getRedisClient(); return new ScanIteration<Entry<byte[], byte[]>>(res.getPos(), res.getValues()); } }.open();
if (!keysFinished && (keysIter == null || !keysIter.hasNext())) { MapScanResult<Object, Object> res = map.scanIterator(client, keysIterPos); client = res.getRedisClient(); keysIter = res.getMap().entrySet().iterator(); keysIterPos = res.getPos(); if (res.getPos() == 0) { keysFinished = true;
@Override public MapScanResult<Object, Object> decode(List<Object> parts, State state) { return new MapScanResult<Object, Object>((Long)parts.get(0), (Map<Object, Object>)parts.get(1)); }
@Override protected ScanIteration<Entry<byte[], byte[]>> doScan(byte[] key, long cursorId, ScanOptions options) { if (isQueueing() || isPipelined()) { throw new UnsupportedOperationException("'HSCAN' cannot be called in pipeline / transaction mode."); } List<Object> args = new ArrayList<Object>(); args.add(key); args.add(cursorId); if (options.getPattern() != null) { args.add("MATCH"); args.add(options.getPattern()); } if (options.getCount() != null) { args.add("COUNT"); args.add(options.getCount()); } RFuture<MapScanResult<byte[], byte[]>> f = executorService.readAsync(client, key, ByteArrayCodec.INSTANCE, RedisCommands.HSCAN, args.toArray()); MapScanResult<byte[], byte[]> res = syncFuture(f); client = res.getRedisClient(); return new ScanIteration<Entry<byte[], byte[]>>(res.getPos(), res.getValues()); } }.open();