From 4606b64a02ccbfae7bb4d6fe3ad76f39557511cb Mon Sep 17 00:00:00 2001 From: leventov Date: Sat, 12 Sep 2015 21:29:49 +0300 Subject: [PATCH] Update stage-compiler version removing limitation that stage names shouldn't be prefixes of each other --- pom.xml | 2 +- .../impl/stage/entry/HashEntryStages.java | 6 ++--- .../hash/impl/stage/entry/SegmentStages.java | 16 ++++++-------- .../impl/stage/query/QuerySegmentStages.java | 2 +- .../chronicle/map/ReplicatedChronicleMap.java | 4 ++-- .../chronicle/map/VanillaChronicleMap.java | 2 +- .../map/impl/IterationContextInterface.java | 2 +- .../map/impl/QueryContextInterface.java | 4 ++-- .../map/impl/stage/entry/MapEntryStages.java | 22 +++++++++---------- .../map/impl/stage/input/ReplicatedInput.java | 1 + .../impl/stage/query/QueryMapEntryStages.java | 2 +- 11 files changed, 30 insertions(+), 33 deletions(-) diff --git a/pom.xml b/pom.xml index fa0f3426d..1f0319ac3 100755 --- a/pom.xml +++ b/pom.xml @@ -148,7 +148,7 @@ net.openhft stage-compiler - 1.1 + 1.2 provided diff --git a/src/main/java/net/openhft/chronicle/hash/impl/stage/entry/HashEntryStages.java b/src/main/java/net/openhft/chronicle/hash/impl/stage/entry/HashEntryStages.java index 68bcc7c65..ae31aeaf7 100644 --- a/src/main/java/net/openhft/chronicle/hash/impl/stage/entry/HashEntryStages.java +++ b/src/main/java/net/openhft/chronicle/hash/impl/stage/entry/HashEntryStages.java @@ -114,13 +114,13 @@ public abstract class HashEntryStages implements HashEntry { 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; } diff --git a/src/main/java/net/openhft/chronicle/hash/impl/stage/entry/SegmentStages.java b/src/main/java/net/openhft/chronicle/hash/impl/stage/entry/SegmentStages.java index 06977fd5b..ebce419a1 100644 --- a/src/main/java/net/openhft/chronicle/hash/impl/stage/entry/SegmentStages.java +++ b/src/main/java/net/openhft/chronicle/hash/impl/stage/entry/SegmentStages.java @@ -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; diff --git a/src/main/java/net/openhft/chronicle/hash/impl/stage/query/QuerySegmentStages.java b/src/main/java/net/openhft/chronicle/hash/impl/stage/query/QuerySegmentStages.java index 10f7ba325..befe27c5a 100644 --- a/src/main/java/net/openhft/chronicle/hash/impl/stage/query/QuerySegmentStages.java +++ b/src/main/java/net/openhft/chronicle/hash/impl/stage/query/QuerySegmentStages.java @@ -25,7 +25,7 @@ public abstract class QuerySegmentStages extends SegmentStages { @StageRef HashQuery q; - void initTheSegmentIndex() { + void initSegmentIndex() { segmentIndex = hh.h().hashSplitting.segmentIndex(q.hashOfKey); } } diff --git a/src/main/java/net/openhft/chronicle/map/ReplicatedChronicleMap.java b/src/main/java/net/openhft/chronicle/map/ReplicatedChronicleMap.java index 9afb5c0f2..a0956893f 100644 --- a/src/main/java/net/openhft/chronicle/map/ReplicatedChronicleMap.java +++ b/src/main/java/net/openhft/chronicle/map/ReplicatedChronicleMap.java @@ -635,7 +635,7 @@ public class ReplicatedChronicleMap>> segmentIndexShift); try (CompiledReplicatedMapIterationContext context = iterationContext()) { - context.initTheSegmentIndex(segmentIndex); + context.initSegmentIndex(segmentIndex); context.updateLock().lock(); if (changesForUpdates.get(position)) { @@ -691,7 +691,7 @@ public class ReplicatedChronicleMap { if (debugEnabled) { LOG.debug("Bootstrap entry: id {}, key {}, value {}", localIdentifier, diff --git a/src/main/java/net/openhft/chronicle/map/VanillaChronicleMap.java b/src/main/java/net/openhft/chronicle/map/VanillaChronicleMap.java index a923b3aef..bf0975614 100755 --- a/src/main/java/net/openhft/chronicle/map/VanillaChronicleMap.java +++ b/src/main/java/net/openhft/chronicle/map/VanillaChronicleMap.java @@ -356,7 +356,7 @@ public class VanillaChronicleMap segmentContext(int segmentIndex) { IterationContextInterface c = iterationContext(); - c.initTheSegmentIndex(segmentIndex); + c.initSegmentIndex(segmentIndex); return c; } diff --git a/src/main/java/net/openhft/chronicle/map/impl/IterationContextInterface.java b/src/main/java/net/openhft/chronicle/map/impl/IterationContextInterface.java index 9ea29c25a..6c2d01b05 100644 --- a/src/main/java/net/openhft/chronicle/map/impl/IterationContextInterface.java +++ b/src/main/java/net/openhft/chronicle/map/impl/IterationContextInterface.java @@ -23,5 +23,5 @@ public interface IterationContextInterface extends MapEntry, MapSegmentContext { long pos(); - void initTheSegmentIndex(int segmentIndex); + void initSegmentIndex(int segmentIndex); } diff --git a/src/main/java/net/openhft/chronicle/map/impl/QueryContextInterface.java b/src/main/java/net/openhft/chronicle/map/impl/QueryContextInterface.java index 993c11b9d..bdf13f07c 100644 --- a/src/main/java/net/openhft/chronicle/map/impl/QueryContextInterface.java +++ b/src/main/java/net/openhft/chronicle/map/impl/QueryContextInterface.java @@ -38,9 +38,9 @@ public interface QueryContextInterface extends ExternalMapQueryContext< Closeable acquireHandle(); - void initTheSegmentIndex(int segmentIndex); + void initSegmentIndex(int segmentIndex); - boolean theSegmentIndexInit(); + boolean segmentIndexInit(); void clear(); } diff --git a/src/main/java/net/openhft/chronicle/map/impl/stage/entry/MapEntryStages.java b/src/main/java/net/openhft/chronicle/map/impl/stage/entry/MapEntryStages.java index 7455c4506..850af9548 100644 --- a/src/main/java/net/openhft/chronicle/map/impl/stage/entry/MapEntryStages.java +++ b/src/main/java/net/openhft/chronicle/map/impl/stage/entry/MapEntryStages.java @@ -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 extends HashEntryStages 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 extends HashEntryStages 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 extends HashEntryStages entrySizeInChunks < allocatedChunks.allocatedChunks) { s.free(pos + entrySizeInChunks, allocatedChunks.allocatedChunks - entrySizeInChunks); } else { - initTheEntrySizeInChunks(allocatedChunks.allocatedChunks); + initEntrySizeInChunks(allocatedChunks.allocatedChunks); } } } diff --git a/src/main/java/net/openhft/chronicle/map/impl/stage/input/ReplicatedInput.java b/src/main/java/net/openhft/chronicle/map/impl/stage/input/ReplicatedInput.java index 73d7ecb2b..23d9e467c 100644 --- a/src/main/java/net/openhft/chronicle/map/impl/stage/input/ReplicatedInput.java +++ b/src/main/java/net/openhft/chronicle/map/impl/stage/input/ReplicatedInput.java @@ -65,6 +65,7 @@ public abstract class ReplicatedInput replicatedInputStore.setBytes(replicatedInputBytes); } + // ri for "replication input" @Stage("ReplicationInput") public long bootstrapTimestamp; @Stage("ReplicationInput") public long riKeySize = -1; @Stage("ReplicationInput") public long riValueSize; diff --git a/src/main/java/net/openhft/chronicle/map/impl/stage/query/QueryMapEntryStages.java b/src/main/java/net/openhft/chronicle/map/impl/stage/query/QueryMapEntryStages.java index 45d0439de..8985b2de6 100644 --- a/src/main/java/net/openhft/chronicle/map/impl/stage/query/QueryMapEntryStages.java +++ b/src/main/java/net/openhft/chronicle/map/impl/stage/query/QueryMapEntryStages.java @@ -70,7 +70,7 @@ public abstract class QueryMapEntryStages extends MapEntryStages { long oldValueSize = valueSize; long oldValueOffset = valueOffset; allocatedChunks.initEntryAndKeyCopying(entrySize, valueOffset - entryStartOffset); - initValueWithoutSize(newValue, oldValueSizeOffset, oldValueSize, oldValueOffset); + initValue_WithoutSize(newValue, oldValueSizeOffset, oldValueSize, oldValueOffset); } freeExtraAllocatedChunks(); }