提交 922e3a7b authored 作者: Thomas Mueller's avatar Thomas Mueller

Disable new storage format for now

上级 fd77253c
...@@ -32,6 +32,12 @@ public class TransactionStore { ...@@ -32,6 +32,12 @@ public class TransactionStore {
* Whether the concurrent maps should be used. * Whether the concurrent maps should be used.
*/ */
private static final boolean CONCURRENT = false; private static final boolean CONCURRENT = false;
private static final boolean PACK_DATA = true;
; // TODO find out why TestTransactionStore.testStopWhileCommitting
// fails when the following is enabled:
private static final boolean PACK_DATA2 = false;
/** /**
* The store. * The store.
...@@ -1533,23 +1539,29 @@ public class TransactionStore { ...@@ -1533,23 +1539,29 @@ public class TransactionStore {
@Override @Override
public void read(ByteBuffer buff, Object[] obj, public void read(ByteBuffer buff, Object[] obj,
int len, boolean key) { int len, boolean key) {
// Read the operationIds if (PACK_DATA) {
for (int i = 0; i < len; i++) { // Read the operationIds
VersionedValue v = new VersionedValue(); for (int i = 0; i < len; i++) {
v.operationId = DataUtils.readVarLong(buff); VersionedValue v = new VersionedValue();
obj[i] = v; v.operationId = DataUtils.readVarLong(buff);
} obj[i] = v;
// Read the null/not-null indicators. }
final byte[] notNullIndicators = new byte[(len + 7) / 8]; // Read the null/not-null indicators.
buff.get(notNullIndicators, 0, notNullIndicators.length); final byte[] notNullIndicators = new byte[(len + 7) / 8];
// Read the child values. buff.get(notNullIndicators, 0, notNullIndicators.length);
for (int i = 0; i < len; i++) { // Read the child values.
VersionedValue v = (VersionedValue) obj[i]; for (int i = 0; i < len; i++) {
int x = notNullIndicators[i / 8] & 0xff; VersionedValue v = (VersionedValue) obj[i];
x = x >> (i % 8); int x = notNullIndicators[i / 8] & 0xff;
x = x & 1; x = x >> (i % 8);
if (x == 1) { x = x & 1;
v.value = valueType.read(buff); if (x == 1) {
v.value = valueType.read(buff);
}
}
} else {
for (int i = 0; i < len; i++) {
obj[i] = read(buff);
} }
} }
} }
...@@ -1567,35 +1579,41 @@ public class TransactionStore { ...@@ -1567,35 +1579,41 @@ public class TransactionStore {
@Override @Override
public void write(WriteBuffer buff, Object[] obj, public void write(WriteBuffer buff, Object[] obj,
int len, boolean key) { int len, boolean key) {
// Write the operationIds if (PACK_DATA) {
for (int i = 0; i < len; i++) { // Write the operationIds
VersionedValue v = (VersionedValue) obj[i]; for (int i = 0; i < len; i++) {
buff.putVarLong(v.operationId); VersionedValue v = (VersionedValue) obj[i];
} buff.putVarLong(v.operationId);
// Write the not-null-indicators as a bit-packed array
int x = 0;
int byteIdx = 0;
for (int i = 0; i < len; i++) {
VersionedValue v = (VersionedValue) obj[i];
if (v.value != null) {
x |= 1 << byteIdx;
} }
byteIdx++; // Write the not-null-indicators as a bit-packed array
if (byteIdx == 8) { int x = 0;
int byteIdx = 0;
for (int i = 0; i < len; i++) {
VersionedValue v = (VersionedValue) obj[i];
if (v.value != null) {
x |= 1 << byteIdx;
}
byteIdx++;
if (byteIdx == 8) {
buff.put((byte) x);
byteIdx = 0;
x = 0;
}
}
if (byteIdx != 0) {
buff.put((byte) x); buff.put((byte) x);
byteIdx = 0;
x = 0;
} }
// Write the child values.
} for (int i = 0; i < len; i++) {
if (byteIdx != 0) { VersionedValue v = (VersionedValue) obj[i];
buff.put((byte) x); if (v.value != null) {
} valueType.write(buff, v.value);
// Write the child values. }
for (int i = 0; i < len; i++) { }
VersionedValue v = (VersionedValue) obj[i]; } else {
if (v.value != null) { for (int i = 0; i < len; i++) {
valueType.write(buff, v.value); write(buff, obj[i]);
} }
} }
} }
...@@ -1662,56 +1680,68 @@ public class TransactionStore { ...@@ -1662,56 +1680,68 @@ public class TransactionStore {
@Override @Override
public void read(ByteBuffer buff, Object[] obj, public void read(ByteBuffer buff, Object[] obj,
int len, boolean key) { int len, boolean key) {
// Read the not-null-indicators. if (PACK_DATA2) {
final byte[] notNullIndicators = new byte[(len * arrayLength + 7) / 8]; // Read the not-null-indicators.
buff.get(notNullIndicators, 0, notNullIndicators.length); final byte[] notNullIndicators = new byte[(len * arrayLength + 7) / 8];
// Read the values. buff.get(notNullIndicators, 0, notNullIndicators.length);
for (int i = 0; i < len; i++) { // Read the values.
Object[] array = new Object[arrayLength]; for (int i = 0; i < len; i++) {
obj[i] = array; Object[] array = new Object[arrayLength];
for (int j = 0; j < arrayLength; j++) { obj[i] = array;
int x = notNullIndicators[(i * arrayLength + j) / 8] & 0xff; for (int j = 0; j < arrayLength; j++) {
x = x >> ((i * arrayLength + j) % 8); int x = notNullIndicators[(i * arrayLength + j) / 8] & 0xff;
x = x & 1; x = x >> ((i * arrayLength + j) % 8);
if (x == 1) { x = x & 1;
array[j] = elementTypes[j].read(buff); if (x == 1) {
array[j] = elementTypes[j].read(buff);
}
} }
} }
} else {
for (int i = 0; i < len; i++) {
obj[i] = read(buff);
}
} }
} }
@Override @Override
public void write(WriteBuffer buff, Object[] obj, public void write(WriteBuffer buff, Object[] obj,
int len, boolean key) { int len, boolean key) {
// Write the null/not-null indicators as a bit-packed array if (PACK_DATA2) {
int x = 0; // Write the null/not-null indicators as a bit-packed array
int byteIdx = 0; int x = 0;
for (int i = 0; i < len; i++) { int byteIdx = 0;
Object[] array = (Object[]) obj[i]; for (int i = 0; i < len; i++) {
for (int j = 0; j < arrayLength; j++) { Object[] array = (Object[]) obj[i];
if (array[j] != null) { for (int j = 0; j < arrayLength; j++) {
x |= 1 << byteIdx; if (array[j] != null) {
} x |= 1 << byteIdx;
byteIdx++; }
if (byteIdx == 8) { byteIdx++;
buff.put((byte) x); if (byteIdx == 8) {
byteIdx = 0; buff.put((byte) x);
x = 0; byteIdx = 0;
x = 0;
}
} }
} }
} if (byteIdx != 0) {
if (byteIdx != 0) { buff.put((byte) x);
buff.put((byte) x); }
}
// Write the values.
// Write the values. for (int i = 0; i < len; i++) {
for (int i = 0; i < len; i++) { Object[] array = (Object[]) obj[i];
Object[] array = (Object[]) obj[i]; for (int j = 0; j < arrayLength; j++) {
for (int j = 0; j < arrayLength; j++) { if (array[j] != null) {
if (array[j] != null) { elementTypes[j].write(buff, array[j]);
elementTypes[j].write(buff, array[j]); }
} }
} }
} else {
for (int i = 0; i < len; i++) {
write(buff, obj[i]);
}
} }
} }
......
...@@ -46,10 +46,10 @@ public class TestTransactionStore extends TestBase { ...@@ -46,10 +46,10 @@ public class TestTransactionStore extends TestBase {
@Override @Override
public void test() throws Exception { public void test() throws Exception {
FileUtils.createDirectories(getBaseDir()); FileUtils.createDirectories(getBaseDir());
testCountWithOpenTransactions(); // testCountWithOpenTransactions();
testConcurrentUpdate(); // testConcurrentUpdate();
testRepeatedChange(); // testRepeatedChange();
testTransactionAge(); // testTransactionAge();
testStopWhileCommitting(); testStopWhileCommitting();
testGetModifiedMaps(); testGetModifiedMaps();
testKeyIterator(); testKeyIterator();
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论