mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
Removed ByteableIntValueMarshaller and ByteableLongValueMarshalller
This commit is contained in:
@@ -1,75 +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;
|
||||
|
||||
import net.openhft.chronicle.hash.serialization.internal.ByteableMarshaller;
|
||||
import net.openhft.lang.io.Bytes;
|
||||
import net.openhft.lang.io.NativeBytes;
|
||||
import net.openhft.lang.io.serialization.BytesMarshaller;
|
||||
import net.openhft.lang.io.serialization.ObjectFactory;
|
||||
import net.openhft.lang.model.Byteable;
|
||||
import net.openhft.lang.model.DataValueClasses;
|
||||
import net.openhft.lang.values.IntValue;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
enum ByteableIntValueMarshaller implements BytesMarshaller<IntValue> {
|
||||
INSTANCE;
|
||||
|
||||
static final Class DIRECT = DataValueClasses.directClassFor(IntValue.class);
|
||||
|
||||
@Override
|
||||
public void write(Bytes bytes, IntValue intValue) {
|
||||
Byteable biv = (Byteable) intValue;
|
||||
bytes.write(biv.bytes(), biv.offset(), biv.maxSize());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public IntValue read(Bytes bytes) {
|
||||
return read(bytes, null);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public IntValue read(Bytes bytes, @Nullable IntValue intValue) {
|
||||
try {
|
||||
if (intValue == null)
|
||||
intValue = (IntValue) NativeBytes.UNSAFE.allocateInstance(DIRECT);
|
||||
Byteable biv = (Byteable) intValue;
|
||||
ByteableMarshaller.setBytesAndOffset(biv, bytes);
|
||||
bytes.skip(biv.maxSize());
|
||||
return intValue;
|
||||
} catch (Exception e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enum DirectIntValueFactory implements ObjectFactory<IntValue> {
|
||||
INSTANCE;
|
||||
|
||||
@Override
|
||||
public IntValue create() {
|
||||
try {
|
||||
return (IntValue) NativeBytes.UNSAFE.allocateInstance(ByteableIntValueMarshaller.DIRECT);
|
||||
} catch (InstantiationException e) {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,76 +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;
|
||||
|
||||
import net.openhft.chronicle.hash.serialization.internal.ByteableMarshaller;
|
||||
import net.openhft.lang.io.Bytes;
|
||||
import net.openhft.lang.io.NativeBytes;
|
||||
import net.openhft.lang.io.serialization.BytesMarshaller;
|
||||
import net.openhft.lang.io.serialization.ObjectFactory;
|
||||
import net.openhft.lang.model.Byteable;
|
||||
import net.openhft.lang.model.DataValueClasses;
|
||||
import net.openhft.lang.values.LongValue;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
enum ByteableLongValueMarshaller implements BytesMarshaller<LongValue> {
|
||||
INSTANCE;
|
||||
|
||||
static final Class DIRECT = DataValueClasses.directClassFor(LongValue.class);
|
||||
|
||||
@Override
|
||||
public void write(Bytes bytes, LongValue longValue) {
|
||||
Byteable biv = (Byteable) longValue;
|
||||
bytes.write(biv.bytes(), biv.offset(), biv.maxSize());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public LongValue read(Bytes bytes) {
|
||||
return read(bytes, null);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public LongValue read(Bytes bytes, @Nullable LongValue longValue) {
|
||||
try {
|
||||
if (longValue == null)
|
||||
longValue = (LongValue) NativeBytes.UNSAFE.allocateInstance(DIRECT);
|
||||
Byteable biv = (Byteable) longValue;
|
||||
ByteableMarshaller.setBytesAndOffset(biv, bytes);
|
||||
bytes.skip(biv.maxSize());
|
||||
return longValue;
|
||||
} catch (Exception e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enum DirectLongValueFactory implements ObjectFactory<LongValue> {
|
||||
INSTANCE;
|
||||
|
||||
@Override
|
||||
public LongValue create() {
|
||||
try {
|
||||
return (LongValue) NativeBytes.UNSAFE.allocateInstance(ByteableLongValueMarshaller.DIRECT);
|
||||
} catch (InstantiationException e) {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,8 +38,7 @@ public class IntValueMapTest {
|
||||
|
||||
try (final ChronicleMap<IntValue, CharSequence> map = ChronicleMapBuilder
|
||||
.of(IntValue.class, CharSequence.class)
|
||||
.entries(20000)
|
||||
.keyMarshaller(ByteableIntValueMarshaller.INSTANCE).create()) {
|
||||
.entries(20000).create()) {
|
||||
IntValue$$Native value = new IntValue$$Native();
|
||||
value.bytes(new ByteBufferBytes(ByteBuffer.allocateDirect(4)), 0);
|
||||
|
||||
|
||||
@@ -59,13 +59,10 @@ public class TCPSocketReplicationIntValueTest {
|
||||
((Byteable) value).bytes(new ByteBufferBytes(ByteBuffer.allocateDirect(4)), 0);
|
||||
map1Builder = newTcpSocketShmBuilder(IntValue.class, CharSequence.class,
|
||||
(byte) 1, s_port, new InetSocketAddress("localhost", s_port + 1));
|
||||
map1Builder.keyMarshaller(ByteableIntValueMarshaller.INSTANCE);
|
||||
map1 = map1Builder.keyMarshaller(ByteableIntValueMarshaller.INSTANCE)
|
||||
.createPersistedTo(getPersistenceFile());
|
||||
map1 = map1Builder.createPersistedTo(getPersistenceFile());
|
||||
map2 = newTcpSocketShmBuilder(IntValue.class, CharSequence.class,
|
||||
(byte) 2, s_port + 1)
|
||||
.entries(Builder.SIZE)
|
||||
.keyMarshaller(ByteableIntValueMarshaller.INSTANCE)
|
||||
.create();
|
||||
s_port += 2;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user