mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -823,7 +823,8 @@ public class ChronicleMapBuilder<K, V> implements Cloneable {
|
||||
|
||||
public ChronicleMap<K, V> create() throws IOException {
|
||||
VanillaChronicleMap<K, ?, ?, V, ?, ?> map = newMap();
|
||||
BytesStore bytesStore = new DirectStore(objectSerializer(), map.sizeInBytes(), true);
|
||||
BytesStore bytesStore = new DirectStore(JDKObjectSerializer.INSTANCE,
|
||||
map.sizeInBytes(), true);
|
||||
map.createMappedStoreAndSegments(bytesStore);
|
||||
return establishReplication(map);
|
||||
}
|
||||
|
||||
@@ -200,7 +200,7 @@ class VanillaChronicleMap<K, KI, MKI extends MetaBytesInterop<K, KI>,
|
||||
|
||||
long createMappedStoreAndSegments(File file) throws IOException {
|
||||
return createMappedStoreAndSegments(new MappedStore(file, FileChannel.MapMode.READ_WRITE,
|
||||
sizeInBytes(), objectSerializer));
|
||||
sizeInBytes(), JDKObjectSerializer.INSTANCE));
|
||||
}
|
||||
|
||||
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
|
||||
|
||||
@@ -1,58 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 Higher Frequency Trading http://www.higherfrequencytrading.com
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package net.openhft.chronicle.map.serialization;
|
||||
|
||||
import net.openhft.lang.io.Bytes;
|
||||
import net.openhft.lang.io.DirectBytes;
|
||||
import net.openhft.lang.io.DirectStore;
|
||||
import net.openhft.lang.io.serialization.JDKObjectSerializer;
|
||||
import net.openhft.chronicle.map.threadlocal.StatefulCopyable;
|
||||
|
||||
final class DirectBytesBuffer implements StatefulCopyable<DirectBytesBuffer> {
|
||||
|
||||
private final Object identity;
|
||||
private DirectBytes buffer;
|
||||
|
||||
DirectBytesBuffer(Object identity) {
|
||||
this.identity = identity;
|
||||
}
|
||||
|
||||
private Bytes buffer(long maxSize) {
|
||||
DirectBytes buf;
|
||||
if ((buf = buffer) != null) {
|
||||
if (maxSize <= buf.capacity()) {
|
||||
return buf.clear();
|
||||
} else {
|
||||
DirectStore store = (DirectStore) buf.store();
|
||||
store.resize(maxSize, false);
|
||||
return buffer = store.bytes();
|
||||
}
|
||||
} else {
|
||||
return buffer = new DirectStore(JDKObjectSerializer.INSTANCE, maxSize, false).bytes();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object stateIdentity() {
|
||||
return identity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DirectBytesBuffer copy() {
|
||||
return new DirectBytesBuffer(identity);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user