use of org.apache.ignite.internal.cache.query.index.sorted.IndexRow in project ignite by apache.
the class InlineIndexImpl method findFirst.
/**
* {@inheritDoc}
*/
@Override
public GridCursor<IndexRow> findFirst(int segment, IndexQueryContext qryCtx) throws IgniteCheckedException {
InlineTreeFilterClosure closure = filterClosure(qryCtx);
IndexRow found = segments[segment].findFirst(closure);
if (found == null || isExpired(found))
return IndexValueCursor.EMPTY;
return new SingleCursor<>(found);
}
use of org.apache.ignite.internal.cache.query.index.sorted.IndexRow in project ignite by apache.
the class GeoSpatialIndexImpl method remove.
/**
*/
private boolean remove(CacheDataRow row) {
checkClosed();
Object key = def.rowHandler().key(row);
assert key != null;
Long rowId = keyToId.remove(key);
assert rowId != null;
IndexRow 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 != null;
}
use of org.apache.ignite.internal.cache.query.index.sorted.IndexRow in project ignite by apache.
the class GeoSpatialIndexImpl method rowIterator.
/**
* @param i Spatial key iterator.
* @param filter Table filter.
* @return Iterator over rows.
*/
@SuppressWarnings("unchecked")
private GridCursor<IndexRow> rowIterator(Iterator<SpatialKey> i, TableFilter filter) {
if (!i.hasNext())
return IndexValueCursor.EMPTY;
long time = System.currentTimeMillis();
IndexingQueryFilter qryFilter = null;
QueryContext qctx = H2Utils.context(filter.getSession());
if (qctx != null)
qryFilter = qctx.filter();
IndexingQueryCacheFilter qryCacheFilter = qryFilter != null ? qryFilter.forCache(def.rowHandler().getTable().cacheName()) : null;
List<IndexRow> rows = new ArrayList<>();
do {
IndexRow row = idToRow.get(i.next().getId());
CacheDataRow cacheRow = row.cacheDataRow();
assert row != null;
if (cacheRow.expireTime() != 0 && cacheRow.expireTime() <= time)
continue;
if (qryCacheFilter == null || qryCacheFilter.applyPartition(cacheRow.partition()))
rows.add(row);
} while (i.hasNext());
return new GridCursorIteratorWrapper(rows.iterator());
}
use of org.apache.ignite.internal.cache.query.index.sorted.IndexRow in project ignite by apache.
the class GeoSpatialIndexImpl method findFirstOrLast.
/**
* {@inheritDoc}
*/
@Override
public GridCursor<IndexRow> findFirstOrLast(int seg, boolean first) {
Lock l = lock.readLock();
l.lock();
try {
checkClosed();
if (!first)
throw DbException.throwInternalError("Spatial Index can only be fetch by ascending order");
final MVRTreeMap<Long> segment = segments[seg];
GridCursor<IndexRow> iter = rowIterator(segment.keySet().iterator(), null);
return new SingleCursor<>(iter.next() ? iter.get() : null);
} catch (IgniteCheckedException e) {
throw DbException.convert(e);
} finally {
l.unlock();
}
}
use of org.apache.ignite.internal.cache.query.index.sorted.IndexRow in project ignite by apache.
the class GridH2SpatialIndex method findByGeometry.
/**
* {@inheritDoc}
*/
@Override
public Cursor findByGeometry(TableFilter filter, SearchRow first, SearchRow last, SearchRow intersection) {
Value v = intersection.getValue(columnIds[0]);
Geometry g = ((ValueGeometry) v.convertTo(Value.GEOMETRY)).getGeometry();
int seg = segmentsCount() == 1 ? 0 : H2Utils.context(filter.getSession()).segment();
GridCursor<IndexRow> cursor = delegate.findByGeometry(seg, filter, g);
GridCursor<H2Row> h2cursor = new IndexValueCursor<>(cursor, this::mapIndexRow);
return new H2Cursor(h2cursor);
}
Aggregations