Update stage-compiler version removing limitation that stage names shouldn't be prefixes of each other

This commit is contained in:
leventov
2015-09-12 21:29:49 +03:00
parent 23d94257e1
commit 4606b64a02
11 changed files with 30 additions and 33 deletions
@@ -114,13 +114,13 @@ public abstract class HashEntryStages<K> implements HashEntry<K> {
return entryKey;
}
@Stage("TheEntrySizeInChunks") public int entrySizeInChunks = 0;
@Stage("EntrySizeInChunks") public int entrySizeInChunks = 0;
void initTheEntrySizeInChunks() {
void initEntrySizeInChunks() {
entrySizeInChunks = hh.h().inChunks(entrySize());
}
public void initTheEntrySizeInChunks(int actuallyUsedChunks) {
public void initEntrySizeInChunks(int actuallyUsedChunks) {
entrySizeInChunks = actuallyUsedChunks;
}
@@ -42,20 +42,18 @@ public abstract class SegmentStages implements SegmentLock {
@StageRef public VanillaChronicleHashHolder<?, ?, ?> hh;
@StageRef public CheckOnEachPublicOperation checkOnEachPublicOperation;
@Stage("TheSegmentIndex") public int segmentIndex = -1;
public int segmentIndex = -1;
public void initTheSegmentIndex(int segmentIndex) {
public void initSegmentIndex(int segmentIndex) {
this.segmentIndex = segmentIndex;
}
// "SegHeader" because stage-generator doesn't support stage names - one is a prefix of another
// there is a stage named "Segment"
@Stage("SegHeader") long segmentHeaderAddress;
@Stage("SegHeader") SegmentHeader segmentHeader = null;
@Stage("SegmentHeader") long segmentHeaderAddress;
@Stage("SegmentHeader") SegmentHeader segmentHeader = null;
abstract boolean segHeaderInit();
abstract boolean segmentHeaderInit();
private void initSegHeader() {
private void initSegmentHeader() {
segmentHeaderAddress = hh.h().ms.address() + hh.h().segmentHeaderOffset(segmentIndex);
segmentHeader = BigSegmentHeader.INSTANCE;
}
@@ -188,7 +186,7 @@ public abstract class SegmentStages implements SegmentLock {
@Stage("Locks")
boolean tryFindInitLocksOfThisSegment(Object thisContext, int index) {
SegmentStages c = chaining.contextAtIndexInChain(index);
if (c.segHeaderInit() &&
if (c.segmentHeaderInit() &&
c.segmentHeaderAddress == segmentHeaderAddress &&
c.locksInit()) {
SegmentStages root = c.rootContextOnThisSegment;
@@ -25,7 +25,7 @@ public abstract class QuerySegmentStages extends SegmentStages {
@StageRef HashQuery q;
void initTheSegmentIndex() {
void initSegmentIndex() {
segmentIndex = hh.h().hashSplitting.segmentIndex(q.hashOfKey);
}
}
@@ -635,7 +635,7 @@ public class ReplicatedChronicleMap<K, KI, MKI extends MetaBytesInterop<K, ? sup
int segmentIndex = (int) (position >>> segmentIndexShift);
try (CompiledReplicatedMapIterationContext<K, KI, MKI, V, VI, MVI, R, ?> context =
iterationContext()) {
context.initTheSegmentIndex(segmentIndex);
context.initSegmentIndex(segmentIndex);
context.updateLock().lock();
if (changesForUpdates.get(position)) {
@@ -691,7 +691,7 @@ public class ReplicatedChronicleMap<K, KI, MKI extends MetaBytesInterop<K, ? sup
boolean debugEnabled = LOG.isDebugEnabled();
for (int i = 0; i < actualSegments; i++) {
final int segmentIndex = i;
c.initTheSegmentIndex(segmentIndex);
c.initSegmentIndex(segmentIndex);
c.forEachSegmentReplicableEntry(e -> {
if (debugEnabled) {
LOG.debug("Bootstrap entry: id {}, key {}, value {}", localIdentifier,
@@ -356,7 +356,7 @@ public class VanillaChronicleMap<K, KI, MKI extends MetaBytesInterop<K, ? super
@Override
public MapSegmentContext<K, V, ?> segmentContext(int segmentIndex) {
IterationContextInterface<K, V, ?> c = iterationContext();
c.initTheSegmentIndex(segmentIndex);
c.initSegmentIndex(segmentIndex);
return c;
}
@@ -23,5 +23,5 @@ public interface IterationContextInterface<K, V, R> extends MapEntry<K, V>,
MapSegmentContext<K, V, R> {
long pos();
void initTheSegmentIndex(int segmentIndex);
void initSegmentIndex(int segmentIndex);
}
@@ -38,9 +38,9 @@ public interface QueryContextInterface<K, V, R> extends ExternalMapQueryContext<
Closeable acquireHandle();
void initTheSegmentIndex(int segmentIndex);
void initSegmentIndex(int segmentIndex);
boolean theSegmentIndexInit();
boolean segmentIndexInit();
void clear();
}
@@ -19,8 +19,6 @@ package net.openhft.chronicle.map.impl.stage.entry;
import net.openhft.chronicle.hash.Data;
import net.openhft.chronicle.hash.impl.stage.entry.AllocatedChunks;
import net.openhft.chronicle.hash.impl.stage.entry.HashEntryStages;
import net.openhft.chronicle.hash.impl.stage.query.HashLookupSearch;
import net.openhft.chronicle.hash.impl.stage.query.KeySearch;
import net.openhft.chronicle.map.MapEntry;
import net.openhft.chronicle.map.VanillaChronicleMap;
import net.openhft.chronicle.map.impl.VanillaChronicleMapHolder;
@@ -47,36 +45,36 @@ public abstract class MapEntryStages<K, V> extends HashEntryStages<K>
valueSizeOffset = countValueSizeOffset();
}
@Stage("ValSize") public long valueSize = -1;
@Stage("ValSize") public long valueOffset;
@Stage("ValueSize") public long valueSize = -1;
@Stage("ValueSize") public long valueOffset;
@Stage("ValSize")
@Stage("ValueSize")
private void countValueOffset() {
mh.m().alignment.alignPositionAddr(entryBytes);
valueOffset = entryBytes.position();
}
void initValSize(long valueSize) {
void initValueSize(long valueSize) {
this.valueSize = valueSize;
entryBytes.position(valueSizeOffset);
mh.m().valueSizeMarshaller.writeSize(entryBytes, valueSize);
countValueOffset();
}
void initValSize() {
void initValueSize() {
entryBytes.position(valueSizeOffset);
valueSize = mh.m().readValueSize(entryBytes);
countValueOffset();
}
void initValSizeEqualToOld(long oldValueSizeOffset, long oldValueSize, long oldValueOffset) {
void initValueSize_EqualToOld(long oldValueSizeOffset, long oldValueSize, long oldValueOffset) {
valueSize = oldValueSize;
valueOffset = valueSizeOffset + (oldValueOffset - oldValueSizeOffset);
}
public void initValue(Data<?> value) {
entryBytes.position(valueSizeOffset);
initValSize(value.size());
initValueSize(value.size());
writeValue(value);
}
@@ -84,10 +82,10 @@ public abstract class MapEntryStages<K, V> extends HashEntryStages<K>
value.writeTo(entryBS, valueOffset);
}
public void initValueWithoutSize(
public void initValue_WithoutSize(
Data<?> value, long oldValueSizeOffset, long oldValueSize, long oldValueOffset) {
assert oldValueSize == value.size();
initValSizeEqualToOld(oldValueSizeOffset, oldValueSize, oldValueOffset);
initValueSize_EqualToOld(oldValueSizeOffset, oldValueSize, oldValueOffset);
writeValue(value);
}
@@ -221,7 +219,7 @@ public abstract class MapEntryStages<K, V> extends HashEntryStages<K>
entrySizeInChunks < allocatedChunks.allocatedChunks) {
s.free(pos + entrySizeInChunks, allocatedChunks.allocatedChunks - entrySizeInChunks);
} else {
initTheEntrySizeInChunks(allocatedChunks.allocatedChunks);
initEntrySizeInChunks(allocatedChunks.allocatedChunks);
}
}
}
@@ -65,6 +65,7 @@ public abstract class ReplicatedInput<K, V, R>
replicatedInputStore.setBytes(replicatedInputBytes);
}
// ri for "replication input"
@Stage("ReplicationInput") public long bootstrapTimestamp;
@Stage("ReplicationInput") public long riKeySize = -1;
@Stage("ReplicationInput") public long riValueSize;
@@ -70,7 +70,7 @@ public abstract class QueryMapEntryStages<K, V> extends MapEntryStages<K, V> {
long oldValueSize = valueSize;
long oldValueOffset = valueOffset;
allocatedChunks.initEntryAndKeyCopying(entrySize, valueOffset - entryStartOffset);
initValueWithoutSize(newValue, oldValueSizeOffset, oldValueSize, oldValueOffset);
initValue_WithoutSize(newValue, oldValueSizeOffset, oldValueSize, oldValueOffset);
}
freeExtraAllocatedChunks();
}