mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
attempting to get net.openhft.chronicle.map.MissSizedMapsTest to work
This commit is contained in:
@@ -45,7 +45,7 @@
|
||||
<dependency>
|
||||
<groupId>net.openhft</groupId>
|
||||
<artifactId>chronicle-bom</artifactId>
|
||||
<version>2.17.44</version>
|
||||
<version>2.17-SNAPSHOT</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
|
||||
@@ -82,13 +82,7 @@ public interface MapMethods<K, V, R> {
|
||||
// between, that will break ConcurrentMap.put() atomicity guarantee. So, we acquire
|
||||
// update lock from the start:
|
||||
q.updateLock().lock();
|
||||
if (MissSizedMapsTest.COUNT_1.get() == 99504) {
|
||||
assert "9|19633|4|1|1|testHarness".equals(q.queriedKey().toString());
|
||||
System.out.println("");
|
||||
((CompiledMapQueryContext)q).initKeySearch();
|
||||
assert ((CompiledMapQueryContext)q).searchState() == PRESENT;
|
||||
|
||||
}
|
||||
|
||||
MapEntry<K, V> entry = q.entry();
|
||||
if (entry != null) {
|
||||
returnValue.returnValue(entry.value());
|
||||
@@ -97,12 +91,6 @@ public interface MapMethods<K, V, R> {
|
||||
q.insert(q.absentEntry(), value);
|
||||
}
|
||||
|
||||
if ("9|19633|4|1|1|testHarness".equals(q.queriedKey().toString()) ){
|
||||
((CompiledMapQueryContext)q).initKeySearch();
|
||||
assert ((CompiledMapQueryContext)q).searchState() == PRESENT;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -14,6 +14,9 @@ import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import static net.openhft.chronicle.algo.bitset.ReusableBitSet.INSTANCE;
|
||||
import static net.openhft.chronicle.map.VanillaChronicleMap.*;
|
||||
|
||||
/**
|
||||
* Created by catst01 on 24/10/2018.
|
||||
*/
|
||||
@@ -49,10 +52,13 @@ public class MissSizedMapsTest {
|
||||
private static ChronicleMap<String, String> createMapInstance() throws IOException {
|
||||
return ChronicleMapBuilder.of(String.class, String.class)
|
||||
.averageKey("D-6.0149935894066442E18").averageValue("226|16533|4|1|1|testHarness").entries(150 << 10)
|
||||
.actualSegments(1)
|
||||
.createPersistedTo(File.createTempFile("chronicle", "cmap"));
|
||||
}
|
||||
|
||||
AtomicBoolean writtenKey = new AtomicBoolean();
|
||||
AtomicBoolean w30 = new AtomicBoolean();
|
||||
|
||||
String v;
|
||||
|
||||
private boolean check(final ChronicleMap<String, String> actual,
|
||||
String s,
|
||||
@@ -60,44 +66,83 @@ public class MissSizedMapsTest {
|
||||
AtomicInteger count, String lable) {
|
||||
String[] split = s.split("&");
|
||||
String key = split[0];
|
||||
Object old = expected.put(key, split[1]);
|
||||
//System.out.println("old=" + old);
|
||||
//if (old == null)
|
||||
|
||||
if (count.get() == 85124) {
|
||||
boolean before = actual.containsKey("9|19633|4|1|1|testHarness");
|
||||
actual.put(key, split[1].substring(0, split[1].length() - 4));
|
||||
boolean after = actual.containsKey("9|19633|4|1|1|testHarness");
|
||||
|
||||
System.out.println("before=" + before);
|
||||
System.out.println("after=" + after);
|
||||
String value = split[1];
|
||||
|
||||
if (key.equals("30|5235|4|1|1|testHarness")) {
|
||||
System.out.println(INSTANCE.isSet(124851));
|
||||
System.out.println("");
|
||||
}
|
||||
|
||||
if (key.equals("9|19633|4|1|1|testHarness")) {
|
||||
writtenKey.set(true);
|
||||
if ("27|31|4|1|1|testHarness".equals(key)) {
|
||||
System.out.println("");
|
||||
}
|
||||
|
||||
if (count.get() == 99504)
|
||||
actual.put(key, split[1]);
|
||||
else
|
||||
actual.put(key, split[1]);
|
||||
if (count.get() == 52592) {
|
||||
|
||||
System.out.println("BEFORE PUT \t- expected=" + expected.size() + ", actual= " + actual.size());
|
||||
System.out.println(INSTANCE.isSet(124851));
|
||||
|
||||
int start = 4968576;
|
||||
long end = 4968754;
|
||||
System.out.println(bSeg.toHexString(start, end - start));
|
||||
Object old = expected.put(key, value);
|
||||
String old1 = actual.put(key, value);
|
||||
// assert old1 == null;
|
||||
|
||||
System.out.println("AFTER PUT \t- expected=" + expected.size() + ", actual= " + actual.size());
|
||||
printRow(actual, key);
|
||||
|
||||
/* if (expected.size() != actual.size()) {
|
||||
|
||||
String k = actual.keySet()) .forEach(e -> expected.containsKey(e));
|
||||
|
||||
System.out.println("expected keyset=" + expected.keySet());
|
||||
System.out.println("actual keyset=" + actual.keySet());
|
||||
}*/
|
||||
|
||||
} else {
|
||||
Object old = expected.put(key, value);
|
||||
actual.put(key, value);
|
||||
|
||||
if (w30.get() && !actual.containsKey("30|5235|4|1|1|testHarness")) {
|
||||
System.out.println("\n\n\n\n" + key);
|
||||
}
|
||||
printRow(actual, key);
|
||||
}
|
||||
|
||||
if (key.equals("30|5235|4|1|1|testHarness"))
|
||||
w30.set(true);
|
||||
|
||||
|
||||
|
||||
/* if ("5|2311|4|1|1|testHarness".equals(key))
|
||||
System.out.println(expected.containsKey("9|19633|4|1|1|testHarness"));
|
||||
*/
|
||||
count.incrementAndGet();
|
||||
|
||||
if (!actual.containsKey(key))
|
||||
System.out.println("key");
|
||||
|
||||
if (actual.size() != expected.size()) {
|
||||
System.out.println(lable + " count=" + count.get());
|
||||
if (expected.size() != actual.size()) {
|
||||
System.out.println("expected=" + expected.size());
|
||||
System.out.println("actual=" + actual.size());
|
||||
return false;
|
||||
}
|
||||
|
||||
if (writtenKey.get()) {
|
||||
if (!actual.containsKey("9|19633|4|1|1|testHarness"))
|
||||
System.out.println("it got coruppted here");
|
||||
return true;
|
||||
}
|
||||
|
||||
private void printRow(final ChronicleMap<String, String> actual, final String key) {
|
||||
String s1 = actual.get(key);
|
||||
System.out.println(lower + " - " + upper +
|
||||
"\t " +
|
||||
"key=" + key + ",\t value=" + s1 + "\t" + " " +
|
||||
"start=0x" + Long.toHexString(start) + ", end=0x" + Long.toHexString(end + 4));
|
||||
|
||||
if (start >= 0x4bd0c0 && end <= 0x4bd0f6) {
|
||||
int start = 0x4bd0c0 - 64;
|
||||
long end = VanillaChronicleMap.end + 64;
|
||||
System.out.println(bSeg.toHexString(start, end - start));
|
||||
return;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -108,3 +153,4 @@ public class MissSizedMapsTest {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -614,6 +614,7 @@ public class VanillaChronicleMap<K, V, R>
|
||||
}
|
||||
|
||||
long keySizeOffset = entrySpaceOffset + (entryPos * chunkSize);
|
||||
|
||||
bs.readLimit(bs.capacity());
|
||||
bs.readPosition(keySizeOffset);
|
||||
long keySize = keySizeMarshaller.readSize(bs);
|
||||
@@ -625,11 +626,29 @@ public class VanillaChronicleMap<K, V, R>
|
||||
long valueSizeOffset = keyOffset + keySize;
|
||||
bs.readPosition(valueSizeOffset);
|
||||
long valueSize = readValueSize(bs);
|
||||
|
||||
q.initInputKey(inputKey);
|
||||
q.entry();
|
||||
lower = q.pos();
|
||||
long l1 = 4 + (q.entryEnd() - q.keySizeOffset());
|
||||
long l = q.m().inChunks(l1);
|
||||
|
||||
start = q.keySizeOffset();
|
||||
end = q.entryEnd();
|
||||
|
||||
upper = q.pos() + l;
|
||||
bSeg = bs;
|
||||
return q.valueReader.read(bs, valueSize, using);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static long lower;
|
||||
public static long upper;
|
||||
public static long start;
|
||||
public static long end;
|
||||
public static Bytes bSeg;
|
||||
|
||||
@Override
|
||||
public V getUsing(K key, V usingValue) {
|
||||
return defaultEntryOperationsAndMethods ? optimizedGet(key, usingValue) :
|
||||
|
||||
@@ -145,7 +145,7 @@ public abstract class MapEntryStages<K, V> extends HashEntryStages<K>
|
||||
if (s.realloc(pos, entrySizeInChunks, newSizeInChunks)) {
|
||||
break newValueDoesNotFit;
|
||||
}
|
||||
relocation(newValue, newSizeOfEverythingBeforeValue);
|
||||
relocation(newValue, newEntrySize);
|
||||
return;
|
||||
} else if (newSizeInChunks < entrySizeInChunks) {
|
||||
s.freeExtra(pos, entrySizeInChunks, newSizeInChunks);
|
||||
@@ -186,8 +186,8 @@ public abstract class MapEntryStages<K, V> extends HashEntryStages<K>
|
||||
newValueOffset + newValue.size() - entryStartOffset;
|
||||
}
|
||||
|
||||
protected void relocation(Data<V> newValue, long newSizeOfEverythingBeforeValue) {
|
||||
long entrySize = innerEntrySize(newSizeOfEverythingBeforeValue, newValue.size());
|
||||
protected void relocation(Data<V> newValue, long entrySize) {
|
||||
// long entrySize = innerEntrySize(newSizeOfEverythingBeforeValue, newValue.size());
|
||||
// need to copy, because in initEntryAndKeyCopying(), in alloc(), nextTier() called ->
|
||||
// hashLookupPos cleared, as a dependant
|
||||
long oldHashLookupPos = hlp.hashLookupPos;
|
||||
|
||||
+2
-2
@@ -167,10 +167,10 @@ public abstract class ReplicatedMapEntryStages<K, V> extends MapEntryStages<K, V
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void relocation(Data<V> newValue, long newSizeOfEverythingBeforeValue) {
|
||||
protected void relocation(Data<V> newValue, long entrySize) {
|
||||
long oldPos = pos;
|
||||
long oldTierIndex = s.tierIndex;
|
||||
super.relocation(newValue, newSizeOfEverythingBeforeValue);
|
||||
super.relocation(newValue, entrySize);
|
||||
ru.moveChange(oldTierIndex, oldPos, pos);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user