use of org.h2.result.SearchRow in project ignite by apache.
the class GridH2SpatialIndex method getEnvelope.
/**
* @param row Row.
* @param rowId Row id.
* @return Envelope.
*/
private SpatialKey getEnvelope(SearchRow row, long rowId) {
Value v = row.getValue(columnIds[0]);
Geometry g = ((ValueGeometry) v.convertTo(Value.GEOMETRY)).getGeometry();
Envelope env = g.getEnvelopeInternal();
return new SpatialKey(rowId, (float) env.getMinX(), (float) env.getMaxX(), (float) env.getMinY(), (float) env.getMaxY());
}
use of org.h2.result.SearchRow in project ignite by apache.
the class GridH2SpatialIndex method remove.
/** {@inheritDoc} */
@Override
public GridH2Row remove(SearchRow row) {
Lock l = lock.writeLock();
l.lock();
try {
checkClosed();
Value key = row.getValue(KEY_COL);
assert key != null;
Long rowId = keyToId.remove(key);
assert rowId != null;
GridH2Row oldRow = idToRow.remove(rowId);
assert oldRow != null;
final int seg = segmentForRow(row);
if (!segments[seg].remove(getEnvelope(row, rowId), rowId))
throw DbException.throwInternalError("row not found");
rowCnt--;
return oldRow;
} finally {
l.unlock();
}
}
use of org.h2.result.SearchRow 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;
CacheObject key;
if (ctx != null) {
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));
}
assert segmentsCount() == 1;
return 0;
}
use of org.h2.result.SearchRow 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.h2.result.SearchRow 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);
}
Aggregations