use of org.apache.ignite.spi.indexing.IndexingQueryCacheFilter in project ignite by apache.
the class H2PkHashIndex method find.
/**
* {@inheritDoc}
*/
@Override
public Cursor find(Session ses, final SearchRow lower, final SearchRow upper) {
IndexingQueryFilter f = threadLocalFilter();
IndexingQueryCacheFilter p = null;
if (f != null) {
String cacheName = getTable().cacheName();
p = f.forCache(cacheName);
}
KeyCacheObject lowerObj = null;
KeyCacheObject upperObj = null;
if (lower != null)
lowerObj = cctx.toCacheKeyObject(lower.getValue(0).getObject());
if (upper != null)
upperObj = cctx.toCacheKeyObject(upper.getValue(0).getObject());
try {
List<GridCursor<? extends CacheDataRow>> cursors = new ArrayList<>();
for (IgniteCacheOffheapManager.CacheDataStore store : cctx.offheap().cacheDataStores()) cursors.add(store.cursor(cctx.cacheId(), lowerObj, upperObj));
return new H2Cursor(new CompositeGridCursor<>(cursors.iterator()), p);
} catch (IgniteCheckedException e) {
throw DbException.convert(e);
}
}
use of org.apache.ignite.spi.indexing.IndexingQueryCacheFilter in project ignite by apache.
the class H2Tree method getRow.
/**
* {@inheritDoc}
*/
@Override
protected GridH2Row getRow(BPlusIO<SearchRow> io, long pageAddr, int idx, Object filter) throws IgniteCheckedException {
if (filter != null) {
// Filter out not interesting partitions without deserializing the row.
IndexingQueryCacheFilter filter0 = (IndexingQueryCacheFilter) filter;
long link = ((H2RowLinkIO) io).getLink(pageAddr, idx);
int part = PageIdUtils.partId(PageIdUtils.pageId(link));
if (!filter0.applyPartition(part))
return null;
}
return (GridH2Row) io.getLookupRow(this, pageAddr, idx);
}
use of org.apache.ignite.spi.indexing.IndexingQueryCacheFilter in project ignite by apache.
the class H2TreeIndex method find.
/**
* {@inheritDoc}
*/
@Override
public Cursor find(Session ses, SearchRow lower, SearchRow upper) {
try {
IndexingQueryCacheFilter filter = partitionFilter(threadLocalFilter());
int seg = threadLocalSegment();
H2Tree tree = treeForRead(seg);
if (indexType.isPrimaryKey() && lower != null && upper != null && tree.compareRows(lower, upper) == 0) {
GridH2Row row = tree.findOne(lower, filter);
return (row == null) ? EMPTY_CURSOR : new SingleRowCursor(row);
} else {
GridCursor<GridH2Row> cursor = tree.find(lower, upper, filter);
return new H2Cursor(cursor);
}
} catch (IgniteCheckedException e) {
throw DbException.convert(e);
}
}
use of org.apache.ignite.spi.indexing.IndexingQueryCacheFilter in project ignite by apache.
the class H2TreeIndex method doFind0.
/**
* {@inheritDoc}
*/
@Override
protected H2Cursor doFind0(IgniteTree t, @Nullable SearchRow first, boolean includeFirst, @Nullable SearchRow last, IndexingQueryFilter filter) {
try {
IndexingQueryCacheFilter pf = partitionFilter(filter);
GridCursor<GridH2Row> range = t.find(first, last, pf);
if (range == null)
range = GridH2IndexBase.EMPTY_CURSOR;
return new H2Cursor(range);
} catch (IgniteCheckedException e) {
throw DbException.convert(e);
}
}
use of org.apache.ignite.spi.indexing.IndexingQueryCacheFilter in project ignite by apache.
the class GridH2SpatialIndex method rowIterator.
/**
* @param i Spatial key iterator.
* @param filter Table filter.
* @return Iterator over rows.
*/
@SuppressWarnings("unchecked")
private GridCursor<GridH2Row> rowIterator(Iterator<SpatialKey> i, TableFilter filter) {
if (!i.hasNext())
return EMPTY_CURSOR;
long time = System.currentTimeMillis();
IndexingQueryFilter qryFilter = threadLocalFilter();
IndexingQueryCacheFilter qryCacheFilter = qryFilter != null ? qryFilter.forCache(getTable().cacheName()) : null;
List<GridH2Row> rows = new ArrayList<>();
do {
GridH2Row row = idToRow.get(i.next().getId());
assert row != null;
if (row.expireTime() != 0 && row.expireTime() <= time)
continue;
if (qryCacheFilter == null || qryCacheFilter.applyPartition(row.partition()))
rows.add(row);
} while (i.hasNext());
return new GridCursorIteratorWrapper(rows.iterator());
}
Aggregations