use of com.wplatform.ddal.value.Value in project jdbc-shards by wplatform.
the class ConditionNot method optimize.
@Override
public Expression optimize(Session session) {
Expression e2 = condition.getNotIfPossible(session);
if (e2 != null) {
return e2.optimize(session);
}
Expression expr = condition.optimize(session);
if (expr.isConstant()) {
Value v = expr.getValue(session);
if (v == ValueNull.INSTANCE) {
return ValueExpression.getNull();
}
return ValueExpression.get(v.convertTo(Value.BOOLEAN).negate());
}
condition = expr;
return this;
}
use of com.wplatform.ddal.value.Value in project jdbc-shards by wplatform.
the class ResultDiskBuffer method readRow.
private void readRow(ResultDiskTape tape) {
int min = Constants.FILE_BLOCK_SIZE;
Data buff = rowBuff;
buff.reset();
readFully(buff.getBytes(), 0, min);
int len = buff.readInt();
buff.checkCapacity(len);
if (len - min > 0) {
readFully(buff.getBytes(), min, len - min);
}
tape.pos += len;
Value[] row = new Value[columnCount];
for (int k = 0; k < columnCount; k++) {
row[k] = buff.readValue();
}
tape.buffer.add(row);
}
use of com.wplatform.ddal.value.Value in project jdbc-shards by wplatform.
the class ResultDiskBuffer method addRows.
public int addRows(ArrayList<Value[]> rows) {
if (sort != null) {
sort.sort(rows);
}
Data buff = rowBuff;
long start = getFilePointer();
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
int bufferLen = 0;
for (Value[] row : rows) {
buff.reset();
buff.writeInt(0);
for (int j = 0; j < columnCount; j++) {
Value v = row[j];
buff.checkCapacity(Data.getValueLen(v));
buff.writeValue(v);
}
buff.fillAligned();
int len = buff.length();
buff.setInt(0, len);
if (maxBufferSize > 0) {
buffer.write(buff.getBytes(), 0, len);
bufferLen += len;
if (bufferLen > maxBufferSize) {
byte[] data = buffer.toByteArray();
buffer.reset();
write(data, 0, data.length);
bufferLen = 0;
}
} else {
write(buff.getBytes(), 0, len);
}
}
if (bufferLen > 0) {
byte[] data = buffer.toByteArray();
write(data, 0, data.length);
}
if (sort != null) {
ResultDiskTape tape = new ResultDiskTape();
tape.start = start;
tape.end = getFilePointer();
tapes.add(tape);
} else {
mainTape.end = getFilePointer();
}
rowCount += rows.size();
return rowCount;
}
use of com.wplatform.ddal.value.Value in project jdbc-shards by wplatform.
the class Row method toString.
@Override
public String toString() {
StatementBuilder buff = new StatementBuilder("( /* key:");
buff.append(getKey());
if (version != 0) {
buff.append(" v:" + version);
}
if (isDeleted()) {
buff.append(" deleted");
}
buff.append(" */ ");
if (data != null) {
for (Value v : data) {
buff.appendExceptFirst(", ");
buff.append(v == null ? "null" : v.getTraceSQL());
}
}
return buff.append(')').toString();
}
use of com.wplatform.ddal.value.Value in project jdbc-shards by wplatform.
the class Row method getMemory.
@Override
public int getMemory() {
if (memory != MEMORY_CALCULATE) {
return memory;
}
int m = Constants.MEMORY_ROW;
if (data != null) {
int len = data.length;
m += Constants.MEMORY_OBJECT + len * Constants.MEMORY_POINTER;
for (int i = 0; i < len; i++) {
Value v = data[i];
if (v != null) {
m += v.getMemory();
}
}
}
this.memory = m;
return m;
}
Aggregations