public byte[] getCacheKey() { final byte[][] pagingKeys = new byte[pagingIdentifiers.size()][]; final byte[][] pagingValues = new byte[pagingIdentifiers.size()][]; int index = 0; int pagingKeysSize = 0; int pagingValuesSize = 0; for (Map.Entry<String, Integer> entry : pagingIdentifiers.entrySet()) { pagingKeys[index] = StringUtils.toUtf8(entry.getKey()); pagingValues[index] = ByteBuffer.allocate(Integer.BYTES).putInt(entry.getValue()).array(); pagingKeysSize += pagingKeys[index].length; pagingValuesSize += Integer.BYTES; index++; } final byte[] thresholdBytes = ByteBuffer.allocate(Integer.BYTES).putInt(threshold).array(); final ByteBuffer queryCacheKey = ByteBuffer.allocate(pagingKeysSize + pagingValuesSize + thresholdBytes.length + 1); for (byte[] pagingKey : pagingKeys) { queryCacheKey.put(pagingKey); } for (byte[] pagingValue : pagingValues) { queryCacheKey.put(pagingValue); } queryCacheKey.put(thresholdBytes); queryCacheKey.put(isFromNext() ? (byte) 0x01 : 0x00); return queryCacheKey.array(); }
public byte[] getCacheKey() { final byte[][] pagingKeys = new byte[pagingIdentifiers.size()][]; final byte[][] pagingValues = new byte[pagingIdentifiers.size()][]; int index = 0; int pagingKeysSize = 0; int pagingValuesSize = 0; for (Map.Entry<String, Integer> entry : pagingIdentifiers.entrySet()) { pagingKeys[index] = StringUtils.toUtf8(entry.getKey()); pagingValues[index] = ByteBuffer.allocate(Integer.BYTES).putInt(entry.getValue()).array(); pagingKeysSize += pagingKeys[index].length; pagingValuesSize += Integer.BYTES; index++; } final byte[] thresholdBytes = ByteBuffer.allocate(Integer.BYTES).putInt(threshold).array(); final ByteBuffer queryCacheKey = ByteBuffer.allocate(pagingKeysSize + pagingValuesSize + thresholdBytes.length + 1); for (byte[] pagingKey : pagingKeys) { queryCacheKey.put(pagingKey); } for (byte[] pagingValue : pagingValues) { queryCacheKey.put(pagingValue); } queryCacheKey.put(thresholdBytes); queryCacheKey.put(isFromNext() ? (byte) 0x01 : 0x00); return queryCacheKey.array(); }