use of org.gridgain.internal.h2.value.Value in project ignite by apache.
the class GridH2IndexBase method segmentForRow.
/**
* @param row Table row.
* @return Segment ID for given row.
*/
protected int segmentForRow(SearchRow row) {
assert row != null;
if (segmentsCount() == 1 || ctx == null)
return 0;
CacheObject key;
final Value keyColValue = row.getValue(KEY_COL);
assert keyColValue != null;
final Object o = keyColValue.getObject();
if (o instanceof CacheObject)
key = (CacheObject) o;
else
key = ctx.toCacheKeyObject(o);
return segmentForPartition(ctx.affinity().partition(key));
}
use of org.gridgain.internal.h2.value.Value in project ignite by apache.
the class GridH2IndexBase method toRow.
/**
* @param msg Message.
* @return Row.
*/
private Row toRow(GridH2RowMessage msg) {
if (msg == null)
return null;
GridKernalContext ctx = kernalContext();
List<GridH2ValueMessage> vals = msg.values();
assert !F.isEmpty(vals) : vals;
Value[] vals0 = new Value[vals.size()];
for (int i = 0; i < vals0.length; i++) {
try {
vals0[i] = vals.get(i).value(ctx);
} catch (IgniteCheckedException e) {
throw new CacheException(e);
}
}
return database.createRow(vals0, MEMORY_CALCULATE);
}
use of org.gridgain.internal.h2.value.Value in project ignite by apache.
the class GridH2IndexBase method toSearchRow.
/**
* @param msg Row message.
* @return Search row.
*/
private SearchRow toSearchRow(GridH2RowMessage msg) {
if (msg == null)
return null;
GridKernalContext ctx = kernalContext();
Value[] vals = new Value[getTable().getColumns().length];
assert vals.length > 0;
List<GridH2ValueMessage> msgVals = msg.values();
for (int i = 0; i < indexColumns.length; i++) {
if (i >= msgVals.size())
continue;
try {
vals[indexColumns[i].column.getColumnId()] = msgVals.get(i).value(ctx);
} catch (IgniteCheckedException e) {
throw new CacheException(e);
}
}
return database.createRow(vals, MEMORY_CALCULATE);
}
use of org.gridgain.internal.h2.value.Value in project ignite by apache.
the class GridH2IndexBase method toSearchRowMessage.
/**
* @param row Search row.
* @return Row message.
*/
private GridH2RowMessage toSearchRowMessage(SearchRow row) {
if (row == null)
return null;
List<GridH2ValueMessage> vals = new ArrayList<>(indexColumns.length);
for (IndexColumn idxCol : indexColumns) {
Value val = row.getValue(idxCol.column.getColumnId());
if (val == null)
break;
try {
vals.add(GridH2ValueMessageFactory.toMessage(val));
} catch (IgniteCheckedException e) {
throw new CacheException(e);
}
}
GridH2RowMessage res = new GridH2RowMessage();
res.values(vals);
return res;
}
use of org.gridgain.internal.h2.value.Value in project ignite by apache.
the class GridH2KeyValueRowOnheap method toString.
/**
* {@inheritDoc}
*/
@Override
public String toString() {
SB sb = new SB("Row@");
sb.a(Integer.toHexString(System.identityHashCode(this)));
Value v = key;
sb.a("[ key: ").a(v == null ? "nil" : v.getString());
v = val;
sb.a(", val: ").a(v == null ? "nil" : v.getString());
v = ver;
sb.a(", ver: ").a(v == null ? "nil" : v.getString());
sb.a(" ][ ");
if (v != null) {
for (int i = DEFAULT_COLUMNS_COUNT, cnt = getColumnCount(); i < cnt; i++) {
v = getValue(i);
if (i != DEFAULT_COLUMNS_COUNT)
sb.a(", ");
if (!desc.isKeyValueOrVersionColumn(i))
sb.a(v == null ? "nil" : v.getString());
}
}
sb.a(" ]");
return sb.toString();
}
Aggregations