use of krati.array.DataArray in project voldemort by voldemort.
the class KratiStorageEngine method entries.
@Override
public ClosableIterator<Pair<ByteArray, Versioned<byte[]>>> entries() {
List<Pair<ByteArray, Versioned<byte[]>>> returnedList = new ArrayList<Pair<ByteArray, Versioned<byte[]>>>();
DataArray array = datastore.getDataArray();
for (int index = 0; index < array.length(); index++) {
byte[] returnedBytes = array.get(index);
if (returnedBytes != null) {
// Extract the key value pair from this
// TODO: Move to DynamicDataStore code
ByteBuffer bb = ByteBuffer.wrap(returnedBytes);
int cnt = bb.getInt();
// Loop over all keys at this index
for (int i = 0; i < cnt; i++) {
int keyLen = bb.getInt();
byte[] key = new byte[keyLen];
bb.get(key);
int valueLen = bb.getInt();
byte[] value = new byte[valueLen];
bb.get(value);
List<Versioned<byte[]>> versions;
try {
versions = disassembleValues(value);
} catch (IOException e) {
versions = null;
}
if (versions != null) {
Iterator<Versioned<byte[]>> iterVersions = versions.iterator();
while (iterVersions.hasNext()) {
Versioned<byte[]> currentVersion = iterVersions.next();
returnedList.add(Pair.create(new ByteArray(key), currentVersion));
}
}
}
}
}
return new KratiClosableIterator(returnedList);
}
Aggregations