mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
HCOLL-167 fixed key set by added a compact method
This commit is contained in:
@@ -605,20 +605,15 @@ class StatelessChronicleMap<K, V> implements ChronicleMap<K, V>, Closeable {
|
||||
|
||||
final Set<Map.Entry<K, V>> result = new HashSet<Map.Entry<K, V>>();
|
||||
|
||||
int count = 0;
|
||||
long total = 0;
|
||||
for (; ; ) {
|
||||
|
||||
boolean hasMoreEntries = in.readBoolean();
|
||||
|
||||
|
||||
count++;
|
||||
|
||||
// number of entries in the chunk
|
||||
long size = in.readInt();
|
||||
|
||||
for (int i = 0; i < size; i++) {
|
||||
total++;
|
||||
|
||||
K k = keyValueSerializer.readKey(in);
|
||||
V v = keyValueSerializer.readValue(in);
|
||||
result.add(new Entry(k, v));
|
||||
@@ -627,20 +622,24 @@ class StatelessChronicleMap<K, V> implements ChronicleMap<K, V>, Closeable {
|
||||
if (!hasMoreEntries)
|
||||
break;
|
||||
|
||||
if (in.remaining() == 0) {
|
||||
bytes.clear();
|
||||
bytes.buffer().clear();
|
||||
} else {
|
||||
buffer.compact();
|
||||
}
|
||||
compact(in);
|
||||
|
||||
in = blockingFetchReadOnly(timeoutTime, transactionId);
|
||||
}
|
||||
|
||||
LOG.info("total=" + total);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private void compact(Bytes in) {
|
||||
if (in.remaining() == 0) {
|
||||
bytes.clear();
|
||||
bytes.buffer().clear();
|
||||
} else {
|
||||
buffer.compact();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@NotNull
|
||||
public synchronized Set<K> keySet() {
|
||||
@@ -671,6 +670,8 @@ class StatelessChronicleMap<K, V> implements ChronicleMap<K, V>, Closeable {
|
||||
if (!hasMoreEntries)
|
||||
break;
|
||||
|
||||
compact(in);
|
||||
|
||||
in = blockingFetchReadOnly(timeoutTime, transactionId);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user