use of org.h2.mvstore.Cursor in project ignite by apache.
the class GridH2TreeIndex method findFirstOrLast.
/** {@inheritDoc} */
@Override
public Cursor findFirstOrLast(Session ses, boolean first) {
try {
int seg = threadLocalSegment();
IgniteTree t = treeForRead(seg);
GridH2Row row = (GridH2Row) (first ? t.findFirst() : t.findLast());
return new SingleRowCursor(row);
} catch (IgniteCheckedException e) {
throw DbException.convert(e);
}
}
use of org.h2.mvstore.Cursor 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.h2.mvstore.Cursor in project ignite by apache.
the class GridMergeIndexIterator method advance.
/**
* Advance iterator.
*/
private void advance() {
next = null;
try {
boolean hasNext = false;
while (cursor == null || !(hasNext = cursor.next())) {
if (idxIter.hasNext())
cursor = idxIter.next().findInStream(null, null);
else {
releaseIfNeeded();
break;
}
}
if (hasNext) {
Row row = cursor.get();
int cols = row.getColumnCount();
List<Object> res = new ArrayList<>(cols);
for (int c = 0; c < cols; c++) res.add(row.getValue(c).getObject());
next = res;
}
} catch (Exception e) {
releaseIfNeeded();
throw e;
}
}
use of org.h2.mvstore.Cursor in project ignite by apache.
the class GridH2SpatialIndex method findFirstOrLast.
/**
* {@inheritDoc}
*/
@Override
public Cursor findFirstOrLast(Session ses, 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 int seg = threadLocalSegment();
final MVRTreeMap<Long> segment = segments[seg];
GridCursor<GridH2Row> iter = rowIterator(segment.keySet().iterator(), null);
return new SingleRowCursor(iter.next() ? iter.get() : null);
} catch (IgniteCheckedException e) {
throw DbException.convert(e);
} finally {
l.unlock();
}
}
use of org.h2.mvstore.Cursor in project ignite by apache.
the class H2PkHashIndex method getRowCount.
/**
* {@inheritDoc}
*/
@Override
public long getRowCount(Session ses) {
Cursor cursor = find(ses, null, null);
long res = 0;
while (cursor.next()) res++;
return res;
}
Aggregations