提交 1654119e authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Remove DataType.memory

上级 0dcbcac1
......@@ -314,7 +314,11 @@ public abstract class Value extends VersionedValue {
* @return the memory used in bytes
*/
public int getMemory() {
return DataType.getDataType(getValueType()).memory;
/*
* Java 11 with -XX:-UseCompressedOops for all values up to ValueLong
* and ValueDouble.
*/
return 24;
}
/**
......
......@@ -50,6 +50,12 @@ public class ValueBoolean extends Value {
return BOOLEAN;
}
@Override
public int getMemory() {
// Singleton TRUE and FALSE values
return 0;
}
@Override
public StringBuilder getSQL(StringBuilder builder) {
return builder.append(getString());
......
......@@ -123,7 +123,7 @@ public abstract class ValueCollectionBase extends Value {
@Override
public int getMemory() {
int memory = 32;
int memory = 72;
for (Value v : values) {
memory += v.getMemory() + Constants.MEMORY_POINTER;
}
......
......@@ -103,6 +103,11 @@ public class ValueEnumBase extends Value {
return ENUM;
}
@Override
public int getMemory() {
return 120;
}
@Override
public int hashCode() {
int results = 31;
......
......@@ -171,6 +171,12 @@ public class ValueInterval extends Value {
return valueType;
}
@Override
public int getMemory() {
// Java 11 with -XX:-UseCompressedOops
return 48;
}
@Override
public Value convertScale(boolean onlyToSmallerScale, int targetScale) {
if (targetScale >= MAXIMUM_SCALE) {
......
......@@ -183,9 +183,9 @@ public class ValueJavaObject extends ValueBytes {
@Override
public int getMemory() {
if (value == null) {
return DataType.getDataType(getValueType()).memory;
return 40;
}
int mem = super.getMemory();
int mem = 40;
if (javaObject != null) {
mem *= 2;
}
......
......@@ -515,7 +515,12 @@ public class ValueLobDb extends Value {
@Override
public int getMemory() {
if (small != null) {
return small.length + 104;
/*
* Java 11 with -XX:-UseCompressedOops
* 0 bytes: 120 bytes
* 1 byte: 128 bytes
*/
return small.length + 127;
}
return 140;
}
......
......@@ -63,6 +63,12 @@ public class ValueNull extends Value {
return NULL;
}
@Override
public int getMemory() {
// Singleton value
return 0;
}
@Override
public String getString() {
return null;
......
......@@ -106,6 +106,11 @@ public class ValueResultSet extends Value {
return RESULT_SET;
}
@Override
public int getMemory() {
return result.getRowCount() * result.getVisibleColumnCount() * 32 + 400;
}
@Override
public String getString() {
StringBuilder buff = new StringBuilder("(");
......
......@@ -69,7 +69,12 @@ public class ValueString extends Value {
@Override
public int getMemory() {
return value.length() * 2 + 48;
/*
* Java 11 with -XX:-UseCompressedOops
* Empty string: 88 bytes
* 1 to 4 UTF-16 chars: 96 bytes
*/
return value.length() * 2 + 94;
}
@Override
......
......@@ -176,6 +176,11 @@ public class ValueTimestamp extends Value {
return TIMESTAMP;
}
@Override
public int getMemory() {
return 32;
}
@Override
public String getString() {
StringBuilder buff = new StringBuilder(MAXIMUM_PRECISION);
......
......@@ -168,6 +168,12 @@ public class ValueTimestampTimeZone extends Value {
return TIMESTAMP_TZ;
}
@Override
public int getMemory() {
// Java 11 with -XX:-UseCompressedOops
return 40;
}
@Override
public String getString() {
StringBuilder builder = new StringBuilder(ValueTimestampTimeZone.MAXIMUM_PRECISION);
......
......@@ -136,6 +136,11 @@ public class ValueUuid extends Value {
return TypeInfo.TYPE_UUID;
}
@Override
public int getMemory() {
return 32;
}
@Override
public int getValueType() {
return UUID;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论