mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
Remove deprecated classes and a test
This commit is contained in:
+2
-7
@@ -26,17 +26,12 @@ import net.openhft.chronicle.wire.WireOut;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class CharSequenceSizedReader implements SizedReader<CharSequence>,
|
||||
public final class CharSequenceSizedReader implements SizedReader<CharSequence>,
|
||||
StatefulCopyable<CharSequenceSizedReader>, ReadResolvable<CharSequenceSizedReader> {
|
||||
|
||||
public static final CharSequenceSizedReader INSTANCE = new CharSequenceSizedReader();
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #INSTANCE} as {@code CharSequenceSizedReader} is immutable and
|
||||
* stateless
|
||||
*/
|
||||
@Deprecated(/* to be removed in x.22 */)
|
||||
public CharSequenceSizedReader() {
|
||||
private CharSequenceSizedReader() {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
-55
@@ -1,55 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2018 Chronicle Map Contributors
|
||||
*
|
||||
* 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.hash.serialization.impl;
|
||||
|
||||
import net.openhft.chronicle.bytes.AppendableUtil;
|
||||
import net.openhft.chronicle.bytes.Bytes;
|
||||
import net.openhft.chronicle.bytes.BytesUtil;
|
||||
import net.openhft.chronicle.hash.serialization.SizedWriter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @deprecated use one of {@link AbstractCharSequenceUtf8DataAccess} subclasses instead. This class
|
||||
* is not removed, because users who created a chronicleMap with older version of the library with
|
||||
* this class as the key or value writer should be able to read and access the map with the present
|
||||
* version of the library.
|
||||
*/
|
||||
@Deprecated(/* to be removed in x.22 */)
|
||||
@SuppressWarnings("deprecation")
|
||||
public final class CharSequenceSizedWriter
|
||||
implements SizedWriter<CharSequence>, EnumMarshallable<CharSequenceSizedWriter> {
|
||||
public static final CharSequenceSizedWriter INSTANCE = new CharSequenceSizedWriter();
|
||||
|
||||
private CharSequenceSizedWriter() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public long size(@NotNull CharSequence toWrite) {
|
||||
return AppendableUtil.findUtf8Length(toWrite);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(@NotNull Bytes out, long size, @NotNull CharSequence toWrite) {
|
||||
BytesUtil.appendUtf8(out, toWrite);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public CharSequenceSizedWriter readResolve() {
|
||||
return INSTANCE;
|
||||
}
|
||||
}
|
||||
@@ -1,135 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2018 Chronicle Map Contributors
|
||||
*
|
||||
* 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.hash.serialization.impl;
|
||||
|
||||
import net.openhft.chronicle.algo.hashing.LongHashFunction;
|
||||
import net.openhft.chronicle.bytes.BytesStore;
|
||||
import net.openhft.chronicle.bytes.RandomDataInput;
|
||||
import net.openhft.chronicle.bytes.RandomDataOutput;
|
||||
import net.openhft.chronicle.hash.AbstractData;
|
||||
import net.openhft.chronicle.hash.Data;
|
||||
import net.openhft.chronicle.hash.serialization.DataAccess;
|
||||
import net.openhft.chronicle.wire.WireIn;
|
||||
import net.openhft.chronicle.wire.WireOut;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @deprecated use {@link IntegerDataAccess_3_13} instead. This class is not removed only because
|
||||
* users who created a Chronicle Map with older version of the library with this class as the key or
|
||||
* value data access should be able to read and access the map with the present version of the
|
||||
* Chronicle Map library.
|
||||
*/
|
||||
@SuppressWarnings("DeprecatedIsStillUsed")
|
||||
@Deprecated(/* to be removed in x.22 */)
|
||||
public final class IntegerDataAccess extends AbstractData<Integer>
|
||||
implements DataAccess<Integer>, Data<Integer> {
|
||||
|
||||
// Cache fields
|
||||
private transient boolean bsInit;
|
||||
private transient BytesStore bs;
|
||||
|
||||
/**
|
||||
* State field
|
||||
*/
|
||||
private transient Integer instance;
|
||||
|
||||
public IntegerDataAccess() {
|
||||
initTransients();
|
||||
}
|
||||
|
||||
private void initTransients() {
|
||||
bs = BytesStore.wrap(new byte[4]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RandomDataInput bytes() {
|
||||
if (!bsInit) {
|
||||
bs.writeInt(0, instance);
|
||||
bsInit = true;
|
||||
}
|
||||
return bs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long offset() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long size() {
|
||||
return 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer get() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getUsing(@Nullable Integer using) {
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long hash(LongHashFunction f) {
|
||||
if (f == LongHashFunction.xx_r39()) {
|
||||
return WrongXxHash.hashInt(instance);
|
||||
} else {
|
||||
return f.hashInt(instance);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equivalent(RandomDataInput source, long sourceOffset) {
|
||||
return source.readInt(sourceOffset) == instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTo(RandomDataOutput target, long targetOffset) {
|
||||
target.writeInt(targetOffset, instance);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Data<Integer> getData(@NotNull Integer instance) {
|
||||
this.instance = instance;
|
||||
bsInit = false;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void uninit() {
|
||||
instance = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readMarshallable(@NotNull WireIn wireIn) {
|
||||
// no config fields to read
|
||||
initTransients();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeMarshallable(@NotNull WireOut wireOut) {
|
||||
// no config fields to write
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public DataAccess<Integer> copy() {
|
||||
return new IntegerDataAccess();
|
||||
}
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2018 Chronicle Map Contributors
|
||||
*
|
||||
* 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.hash.serialization.impl;
|
||||
|
||||
/**
|
||||
* @deprecated this class exists for compatibility with old versions of Chronicle Map, which used
|
||||
* wrong version of xxHash.
|
||||
*/
|
||||
@Deprecated(/* to be removed in x.22 */)
|
||||
public final class WrongXxHash {
|
||||
|
||||
// xxHash constants
|
||||
private static final long P1 = -7046029288634856825L;
|
||||
private static final long P2 = -4417276706812531889L;
|
||||
private static final long P3 = 1609587929392839161L;
|
||||
private static final long P5 = 2870177450012600261L;
|
||||
|
||||
private WrongXxHash() {
|
||||
}
|
||||
|
||||
public static long hashInt(int input) {
|
||||
long hash = P5 + 4;
|
||||
// Preserve old, wrong behaviour. In the correct version, input is widened to long as
|
||||
// unsigned here.
|
||||
hash ^= input * P1;
|
||||
hash = Long.rotateLeft(hash, 23) * P2 + P3;
|
||||
return finalize(hash);
|
||||
}
|
||||
|
||||
private static long finalize(long hash) {
|
||||
hash ^= hash >>> 33;
|
||||
hash *= P2;
|
||||
hash ^= hash >>> 29;
|
||||
hash *= P3;
|
||||
hash ^= hash >>> 32;
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
@@ -130,15 +130,6 @@ public interface Replica extends Closeable {
|
||||
*/
|
||||
boolean nextEntry(@NotNull final Callback callback, final int chronicleId);
|
||||
|
||||
/**
|
||||
* Synchronous version which is kept for binary API compatibility.
|
||||
*
|
||||
* @deprecated see {@link #dirtyEntries(long, EventLoop)}
|
||||
* @param fromTimeStamp the timestamp from which all entries should be dirty
|
||||
*/
|
||||
@Deprecated(/* to be removed in x.22 */)
|
||||
void dirtyEntries(long fromTimeStamp);
|
||||
|
||||
/**
|
||||
* Dirties all entries with a modification time equal to {@code fromTimeStamp} or newer and
|
||||
* origin identifier equal to the current node identifier. It means all these entries will
|
||||
|
||||
@@ -1051,22 +1051,6 @@ public class ReplicatedChronicleMap<K, V, R> extends VanillaChronicleMap<K, V, R
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated(/* to be removed in x.22 */)
|
||||
public void dirtyEntries(long fromTimeStamp) {
|
||||
throwExceptionIfClosed();
|
||||
|
||||
final DirtyEntriesHandler syncHandler = new DirtyEntriesHandler(segment -> true, fromTimeStamp);
|
||||
|
||||
try {
|
||||
for (int i = 0; i < actualSegments + 1; i++) // Call [actualSegments + 1] times to trigger context close
|
||||
syncHandler.action();
|
||||
} catch (InvalidEventHandlerException e) {
|
||||
if (e.getCause() instanceof ChronicleHashClosedException)
|
||||
throw (ChronicleHashClosedException) e.getCause();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dirtyEntries(long fromTimeStamp, @NotNull EventLoop eventLoop) {
|
||||
throwExceptionIfClosed();
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2018 Chronicle Map Contributors
|
||||
*
|
||||
* 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 com.google.common.io.Files;
|
||||
import net.openhft.chronicle.set.Builder;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
public class ChronicleMap3_8FormatCompatibilityTest {
|
||||
|
||||
@Test
|
||||
public void testChronicleMap3_8FormatCompatibility() throws URISyntaxException, IOException {
|
||||
ClassLoader cl = Thread.currentThread().getContextClassLoader();
|
||||
URL fileUrl = cl.getResource("chronicle-map-3-8-file.dat");
|
||||
File file = new File(fileUrl.toURI());
|
||||
File persistenceFile = Builder.getPersistenceFile();
|
||||
Files.copy(file, persistenceFile);
|
||||
try (ChronicleMap<Integer, String> map = ChronicleMap.of(Integer.class, String.class)
|
||||
.averageValue("1")
|
||||
.entries(1)
|
||||
.createPersistedTo(persistenceFile)) {
|
||||
assertEquals(1, map.size());
|
||||
assertEquals("1", map.get(1));
|
||||
assertNull(map.put(2, "2"));
|
||||
assertEquals("2", map.remove(2));
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Reference in New Issue
Block a user