Merge remote-tracking branch 'origin/master'

This commit is contained in:
Rob Austin
2014-12-21 17:28:51 +00:00
3 changed files with 82 additions and 152 deletions
@@ -393,15 +393,16 @@ class VanillaChronicleMap<K, KI, MKI extends MetaBytesInterop<K, ? super KI>,
}
}
final void put(Bytes entry, Bytes output) {
final void put(Bytes entry, TcpReplicator.TcpSocketChannelEntryWriter output) {
put(entry, output, true);
}
final void putIfAbsent(Bytes entry, Bytes output) {
final void putIfAbsent(Bytes entry, TcpReplicator.TcpSocketChannelEntryWriter output) {
put(entry, output, false);
}
private void put(Bytes entry, Bytes output, boolean replaceIfPresent) {
private void put(Bytes entry, TcpReplicator.TcpSocketChannelEntryWriter output,
boolean replaceIfPresent) {
ThreadLocalCopies copies = SegmentState.getCopies(null);
SegmentState segmentState = SegmentState.get(copies);
ReadValueToOutputBytes readValueToOutputBytes = segmentState.readValueToOutputBytes;
@@ -467,28 +468,32 @@ class VanillaChronicleMap<K, KI, MKI extends MetaBytesInterop<K, ? super KI>,
}
private static class ReadValueToOutputBytes extends ReadValueToBytes {
private Bytes outputBytes;
private TcpReplicator.TcpSocketChannelEntryWriter output;
void reuse(SizeMarshaller valueSizeMarshaller, Bytes outputBytes) {
void reuse(SizeMarshaller valueSizeMarshaller,
TcpReplicator.TcpSocketChannelEntryWriter output) {
valueSizeMarshaller(valueSizeMarshaller);
this.outputBytes = outputBytes;
this.output = output;
}
@Override
Bytes bytes(long valueSize) {
return outputBytes;
return output.in();
}
@Override
public Bytes readValue(@NotNull ThreadLocalCopies copies, Bytes entry, Bytes usingBytes,
long valueSize) {
outputBytes.writeBoolean(false);
long totalSize = 1 + valueSizeMarshaller.sizeEncodingSize(valueSize) + valueSize;
output.ensureBufferSize(totalSize);
output.in().writeBoolean(false);
return super.readValue(copies, entry, usingBytes, valueSize);
}
@Override
public Bytes readNull() {
outputBytes.writeBoolean(true);
output.ensureBufferSize(1);
output.in().writeBoolean(true);
return null;
}
}
@@ -578,7 +583,7 @@ class VanillaChronicleMap<K, KI, MKI extends MetaBytesInterop<K, ? super KI>,
return lookupUsing(key, usingValue, true);
}
final void get(Bytes key, Bytes output) {
final void get(Bytes key, TcpReplicator.TcpSocketChannelEntryWriter output) {
ThreadLocalCopies copies = SegmentState.getCopies(null);
SegmentState segmentState = SegmentState.get(copies);
ReadValueToOutputBytes readValueToOutputBytes = segmentState.readValueToOutputBytes;
@@ -1308,7 +1313,7 @@ class VanillaChronicleMap<K, KI, MKI extends MetaBytesInterop<K, ? super KI>,
outputValueBytesToInstance, readValueToLazyBytes, true);
}
final void remove(Bytes key, Bytes output) {
final void remove(Bytes key, TcpReplicator.TcpSocketChannelEntryWriter output) {
ThreadLocalCopies copies = SegmentState.getCopies(null);
SegmentState segmentState = SegmentState.get(copies);
ReadValueToOutputBytes readValueToOutputBytes = segmentState.readValueToOutputBytes;
@@ -1427,7 +1432,7 @@ class VanillaChronicleMap<K, KI, MKI extends MetaBytesInterop<K, ? super KI>,
this, expectedValue, this, newValue, this, valueIdentity());
}
final void replaceKV(Bytes keyAndNewValue, Bytes output) {
final void replaceKV(Bytes keyAndNewValue, TcpReplicator.TcpSocketChannelEntryWriter output) {
ThreadLocalCopies copies = SegmentState.getCopies(null);
SegmentState segmentState = SegmentState.get(copies);
ReadValueToOutputBytes readValueToOutputBytes = segmentState.readValueToOutputBytes;