mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
Zero out contents of a newly-created persisted ChronicleHash
This commit is contained in:
@@ -56,6 +56,10 @@ public abstract class VanillaChronicleHash<K, KI, MKI extends MetaBytesInterop<K
|
||||
// Version
|
||||
public final String dataFileVersion;
|
||||
|
||||
/////////////////////////////////////////////////
|
||||
// If the hash was created in the first place, or read from disk
|
||||
public transient boolean created = false;
|
||||
|
||||
/////////////////////////////////////////////////
|
||||
// Key Data model
|
||||
public final Class<K> kClass;
|
||||
@@ -110,10 +114,15 @@ public abstract class VanillaChronicleHash<K, KI, MKI extends MetaBytesInterop<K
|
||||
|
||||
public transient CompactOffHeapLinearHashTable hashLookup;
|
||||
|
||||
public VanillaChronicleHash(ChronicleMapBuilder<K, ?> builder, boolean replicated) {
|
||||
public VanillaChronicleHash(
|
||||
ChronicleMapBuilder<K, ?> builder, boolean replicated) {
|
||||
// Version
|
||||
dataFileVersion = BuildVersion.version();
|
||||
|
||||
// Because we are in constructor. If the Hash is not created, deserialization bypasses
|
||||
// the constructor and created = false
|
||||
this.created = true;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
ChronicleHashBuilderPrivateAPI<K> privateAPI = builder.privateAPI();
|
||||
|
||||
@@ -205,6 +214,9 @@ public abstract class VanillaChronicleHash<K, KI, MKI extends MetaBytesInterop<K
|
||||
//OS.warnOnWindows(sizeInBytes());
|
||||
createMappedStoreAndSegments(new MappedStore(file, FileChannel.MapMode.READ_WRITE,
|
||||
sizeInBytes(), BytesMarshallableSerializer.create()));
|
||||
// newly-extended file contents are not guaranteed to be zero
|
||||
if (created)
|
||||
bytes.zeroOut(headerSize, bytes.capacity(), true);
|
||||
}
|
||||
|
||||
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
|
||||
|
||||
Reference in New Issue
Block a user