{
DataInputStream in = null;
try
{
logger.info(String.format("reading saved cache %s", path));
in = new DataInputStream(new LengthAvailableInputStream(new BufferedInputStream(new FileInputStream(path)), path.length()));
Set<ByteBuffer> keys = new HashSet<ByteBuffer>();
while (in.available() > 0)
{
keys.add(ByteBufferUtil.readWithLength(in));
count++;
}
cacheLoader.load(keys, cfs);
}
catch (Exception e)
{
logger.debug(String.format("harmless error reading saved cache %s fully, keys loaded so far: %d", path.getAbsolutePath(), count), e);
return count;
}
finally
{
FileUtils.closeQuietly(in);
}
}
// modern format, allows both key and value (so key cache load can be purely sequential)
path = getCachePath(cfs.keyspace.getName(), cfs.name, CURRENT_VERSION);
if (path.exists())
{
DataInputStream in = null;
try
{
logger.info(String.format("reading saved cache %s", path));
in = new DataInputStream(new LengthAvailableInputStream(new BufferedInputStream(new FileInputStream(path)), path.length()));
List<Future<Pair<K, V>>> futures = new ArrayList<Future<Pair<K, V>>>();
while (in.available() > 0)
{
Future<Pair<K, V>> entry = cacheLoader.deserialize(in, cfs);
// Key cache entry can return null, if the SSTable doesn't exist.