mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
Remove EntryExternalizable.sizeOfEntry()
This commit is contained in:
@@ -88,17 +88,6 @@ final class ChannelProvider implements Closeable {
|
||||
|
||||
private static final byte BOOTSTRAP_MESSAGE = 'B';
|
||||
final EntryExternalizable asEntryExternalizable = new EntryExternalizable() {
|
||||
@Override
|
||||
public int sizeOfEntry(@NotNull Bytes entry, int chronicleChannel) {
|
||||
channelDataReadLock();
|
||||
try {
|
||||
|
||||
return channelEntryExternalizables[chronicleChannel]
|
||||
.sizeOfEntry(entry, chronicleChannel);
|
||||
} finally {
|
||||
channelDataLock.readLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean identifierCheck(@NotNull ReplicableEntry entry, int chronicleChannel) {
|
||||
@@ -549,10 +538,6 @@ final class ChannelProvider implements Closeable {
|
||||
}
|
||||
};
|
||||
final EntryExternalizable asEntryExternalizable = new EntryExternalizable() {
|
||||
@Override
|
||||
public int sizeOfEntry(@NotNull Bytes entry, int chronicleId) {
|
||||
return (int) entry.readRemaining();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean identifierCheck(@NotNull ReplicableEntry entry, int chronicleId) {
|
||||
|
||||
@@ -127,16 +127,6 @@ public interface Replica extends Closeable {
|
||||
*/
|
||||
interface EntryExternalizable {
|
||||
|
||||
/**
|
||||
* The size of entry in bytes
|
||||
*
|
||||
* @param entry an entry in the map
|
||||
* @param chronicleId is the channel id used to identify the canonical map or queue
|
||||
* @return the size of the entry
|
||||
*/
|
||||
int sizeOfEntry(@NotNull Bytes entry, int chronicleId);
|
||||
|
||||
|
||||
/**
|
||||
* check that the identifier in the entry is from this node
|
||||
*
|
||||
@@ -146,7 +136,6 @@ public interface Replica extends Closeable {
|
||||
*/
|
||||
boolean identifierCheck(@NotNull ReplicableEntry entry, int chronicleId);
|
||||
|
||||
|
||||
/**
|
||||
* The map implements this method to save its contents.
|
||||
*
|
||||
@@ -168,8 +157,6 @@ public interface Replica extends Closeable {
|
||||
* @param source bytes to read an entry from
|
||||
*/
|
||||
void readExternalEntry(@NotNull Bytes source);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -205,7 +192,6 @@ public interface Replica extends Closeable {
|
||||
public void onBeforeEntry() {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* its possible that the entry should now be ignored, for example although rare its
|
||||
* identifier may have recently been changed by another thread, so its no longer applicable
|
||||
@@ -218,7 +204,5 @@ public interface Replica extends Closeable {
|
||||
*/
|
||||
public abstract boolean shouldBeIgnored(final ReplicableEntry entry, final int chronicleId);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -362,39 +362,6 @@ public class ReplicatedChronicleMap<K, V, R> extends VanillaChronicleMap<K, V, R
|
||||
return entry.originIdentifier() == identifier();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int sizeOfEntry(@NotNull Bytes entry, int chronicleId) {
|
||||
|
||||
long start = entry.readPosition();
|
||||
try {
|
||||
final long keySize = keySizeMarshaller.readSize(entry);
|
||||
|
||||
entry.readSkip(keySize + 8); // we skip 8 for the timestamp
|
||||
|
||||
final byte identifier = entry.readByte();
|
||||
if (identifier != identifier()) {
|
||||
// although unlikely, this may occur if the entry has been updated
|
||||
return 0;
|
||||
}
|
||||
|
||||
entry.readSkip(1); // is Deleted
|
||||
long valueSize = valueSizeMarshaller.readSize(entry);
|
||||
|
||||
long currentPosition = entry.readPosition();
|
||||
long currentAddr = entry.address(currentPosition);
|
||||
long skip = alignAddr(currentAddr, alignment) - currentAddr;
|
||||
long result = currentPosition + skip + valueSize - start;
|
||||
|
||||
// entries can be larger than Integer.MAX_VALUE as we are restricted to the size we can
|
||||
// make a byte buffer
|
||||
assert result < Integer.MAX_VALUE;
|
||||
|
||||
return (int) result + SIZE_OF_BOOTSTRAP_TIME_STAMP;
|
||||
} finally {
|
||||
entry.readPosition(start);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method does not set a segment lock, A segment lock should be obtained before calling
|
||||
|
||||
Reference in New Issue
Block a user