re-fix for read-only indices (rewrite assignment of read-only status for ValueContainerMap)

This commit is contained in:
Dmitry Batkovich
2017-03-22 23:04:43 +03:00
parent 76c6022769
commit 9496fd7ad9
2 changed files with 7 additions and 11 deletions
@@ -80,7 +80,12 @@ public abstract class MapIndexStorage<Key, Value> implements IndexStorage<Key, V
});
PersistentHashMapValueStorage.CreationTimeOptions.COMPACT_CHUNKS_WITH_VALUE_DESERIALIZATION.set(Boolean.TRUE);
try {
map = new ValueContainerMap<Key, Value>(getStorageFile(), myKeyDescriptor, myDataExternalizer, myKeyIsUniqueForIndexedFile, myReadOnly);
map = new ValueContainerMap<Key, Value>(getStorageFile(), myKeyDescriptor, myDataExternalizer, myKeyIsUniqueForIndexedFile) {
@Override
protected boolean isReadOnly() {
return myReadOnly;
}
};
} finally {
PersistentHashMapValueStorage.CreationTimeOptions.EXCEPTIONAL_IO_CANCELLATION.set(null);
PersistentHashMapValueStorage.CreationTimeOptions.COMPACT_CHUNKS_WITH_VALUE_DESERIALIZATION.set(null);
@@ -29,18 +29,14 @@ import java.io.*;
class ValueContainerMap<Key, Value> extends PersistentHashMap<Key, UpdatableValueContainer<Value>> {
@NotNull private final DataExternalizer<Value> myValueExternalizer;
private final boolean myKeyIsUniqueForIndexedFile;
private final boolean myReadOnly;
ValueContainerMap(@NotNull final File file,
@NotNull KeyDescriptor<Key> keyKeyDescriptor,
@NotNull DataExternalizer<Value> valueExternalizer,
boolean keyIsUniqueForIndexedFile,
boolean readOnly
) throws IOException {
boolean keyIsUniqueForIndexedFile) throws IOException {
super(file, keyKeyDescriptor, new ValueContainerExternalizer<Value>(valueExternalizer));
myValueExternalizer = valueExternalizer;
myKeyIsUniqueForIndexedFile = keyIsUniqueForIndexedFile;
myReadOnly = readOnly;
}
@NotNull
@@ -71,11 +67,6 @@ class ValueContainerMap<Key, Value> extends PersistentHashMap<Key, UpdatableValu
}
}
@Override
protected boolean isReadOnly() {
return myReadOnly;
}
private static final class ValueContainerExternalizer<T> implements DataExternalizer<UpdatableValueContainer<T>> {
@NotNull private final DataExternalizer<T> myValueExternalizer;