mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
Returned VanillaContext entry indirection in order to make patterns like map.getUsing(key, byteableValue) working
This commit is contained in:
+1
-1
@@ -146,7 +146,7 @@ public abstract class ByteableMarshaller<E extends Byteable>
|
||||
try {
|
||||
if (toReuse == null)
|
||||
toReuse = getInstance();
|
||||
toReuse.bytes(bytes, bytes.position());
|
||||
setBytesAndOffset(toReuse, bytes);
|
||||
bytes.skip(size);
|
||||
return toReuse;
|
||||
} catch (Exception ex) {
|
||||
|
||||
+2
-1
@@ -492,7 +492,8 @@ public final class DataValueBytesMarshallers {
|
||||
sb.append(" if (toReuse == null)\n");
|
||||
sb.append(" toReuse = getInstance();\n");
|
||||
sb.append(" if (toReuse instanceof Byteable) {\n");
|
||||
sb.append(" ((Byteable) toReuse).bytes(bytes, bytes.position());\n");
|
||||
sb.append(" " +
|
||||
"ByteableMarshaller.setBytesAndOffset(((Byteable) toReuse), bytes);\n");
|
||||
sb.append(" bytes.skip(size);\n");
|
||||
sb.append(" return toReuse;\n");
|
||||
sb.append(" }\n");
|
||||
|
||||
@@ -134,6 +134,7 @@ class VanillaChronicleMap<K, KI, MKI extends MetaBytesInterop<K, ? super KI>,
|
||||
/////////////////////////////////////////////////
|
||||
// Bytes Store (essentially, the base address) and serialization-dependent offsets
|
||||
transient BytesStore ms;
|
||||
transient Bytes bytes;
|
||||
|
||||
transient long headerSize;
|
||||
transient long segmentHeadersOffset;
|
||||
@@ -272,6 +273,7 @@ class VanillaChronicleMap<K, KI, MKI extends MetaBytesInterop<K, ? super KI>,
|
||||
|
||||
final void createMappedStoreAndSegments(BytesStore bytesStore) throws IOException {
|
||||
this.ms = bytesStore;
|
||||
bytes = ms.bytes();
|
||||
|
||||
onHeaderCreated();
|
||||
|
||||
@@ -362,6 +364,8 @@ class VanillaChronicleMap<K, KI, MKI extends MetaBytesInterop<K, ? super KI>,
|
||||
public void close() {
|
||||
if (ms == null)
|
||||
return;
|
||||
bytes.release();
|
||||
bytes = null;
|
||||
ms.free();
|
||||
ms = null;
|
||||
}
|
||||
|
||||
@@ -1807,8 +1807,8 @@ class VanillaContext<K, KI, MKI extends MetaBytesInterop<K, ? super KI>,
|
||||
|
||||
final MultiStoreBytes reuse(MultiStoreBytes entry, long pos) {
|
||||
long offsetWithinEntrySpace = pos * m.chunkSize;
|
||||
entry.storePositionAndSize(m.ms, entrySpaceOffset + offsetWithinEntrySpace,
|
||||
m.segmentEntrySpaceInnerSize - offsetWithinEntrySpace);
|
||||
entry.setBytesOffset(m.bytes, entrySpaceOffset + offsetWithinEntrySpace);
|
||||
entry.limit(m.segmentEntrySpaceInnerSize - offsetWithinEntrySpace);
|
||||
entry.position(m.metaDataBytes);
|
||||
return entry;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user