use of org.gridgain.internal.h2.mvstore.rtree.SpatialKey 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.gridgain.internal.h2.mvstore.rtree.SpatialKey in project h2database by h2database.
the class MVSpatialIndex method remove.
@Override
public void remove(Session session, Row row) {
SpatialKey key = getKey(row);
if (key.isNull()) {
return;
}
TransactionMap<SpatialKey, Value> map = getMap(session);
try {
Value old = map.remove(key);
if (old == null) {
old = map.remove(key);
throw DbException.get(ErrorCode.ROW_NOT_FOUND_WHEN_DELETING_1, getSQL() + ": " + row.getKey());
}
} catch (IllegalStateException e) {
throw mvTable.convertException(e);
}
}
use of org.gridgain.internal.h2.mvstore.rtree.SpatialKey in project h2database by h2database.
the class MVSpatialIndex method findByGeometry.
@Override
public Cursor findByGeometry(TableFilter filter, SearchRow first, SearchRow last, SearchRow intersection) {
Session session = filter.getSession();
if (intersection == null) {
return find(session, first, last);
}
Iterator<SpatialKey> cursor = spatialMap.findIntersectingKeys(getKey(intersection));
TransactionMap<SpatialKey, Value> map = getMap(session);
Iterator<SpatialKey> it = map.wrapIterator(cursor, false);
return new MVStoreCursor(session, it);
}
use of org.gridgain.internal.h2.mvstore.rtree.SpatialKey in project h2database by h2database.
the class ValueDataType method write.
@Override
public void write(WriteBuffer buff, Object obj) {
if (obj instanceof SpatialKey) {
buff.put((byte) SPATIAL_KEY_2D);
getSpatialDataType().write(buff, obj);
return;
}
Value x = (Value) obj;
writeValue(buff, x);
}
use of org.gridgain.internal.h2.mvstore.rtree.SpatialKey in project h2database by h2database.
the class SpatialTreeIndex method getKey.
private SpatialKey getKey(SearchRow row) {
if (row == null) {
return null;
}
Value v = row.getValue(columnIds[0]);
if (v == ValueNull.INSTANCE) {
return null;
}
Geometry g = ((ValueGeometry) v.convertTo(Value.GEOMETRY)).getGeometryNoCopy();
Envelope env = g.getEnvelopeInternal();
return new SpatialKey(row.getKey(), (float) env.getMinX(), (float) env.getMaxX(), (float) env.getMinY(), (float) env.getMaxY());
}
Aggregations