@Override public List<Future<Cursor>> find() { if (!full) { return Collections.emptyList(); } Cursor c = filter.getIndex().find(filter, first, last); result.set(0, new DoneFuture<>(c)); full = false; first = last = null; return result; } }
@Override public Cursor find(Session session, SearchRow first, SearchRow last) { synchronized (sync) { Cursor baseCursor = base.find(session, first, last); Cursor deltaCursor = delta.find(session, first, last); return new MultiVersionCursor(session, this, baseCursor, deltaCursor, sync); } }
/** * Re-evaluate the start and end values of the index search for rows. * * @param s the session * @param indexConditions the index conditions */ public void find(Session s, ArrayList<IndexCondition> indexConditions) { prepare(s, indexConditions); if (inColumn != null) { return; } if (!alwaysFalse) { if (intersects != null && index instanceof SpatialIndex) { cursor = ((SpatialIndex) index).findByGeometry(tableFilter, start, end, intersects); } else { cursor = index.find(tableFilter, start, end); } } }
@Override public Cursor find(TableFilter filter, SearchRow first, SearchRow last) { synchronized (sync) { Cursor baseCursor = base.find(filter, first, last); Cursor deltaCursor = delta.find(filter, first, last); return new MultiVersionCursor(filter.getSession(), this, baseCursor, deltaCursor, sync); } }
private void find(Value v) { v = inColumn.convert(v); int id = inColumn.getColumnId(); start.setValue(id, v); cursor = index.find(tableFilter, start, start); }
@Override public Value[] next() { if (resultCursor == null) { Index idx; if (distinct || sort != null) { idx = index; } else { idx = table.getScanIndex(session); } if (session.getDatabase().getMvStore() != null) { // sometimes the transaction is already committed, // in which case we can't use the session if (idx.getRowCount(session) == 0 && rowCount > 0) { // this means querying is not transactional resultCursor = idx.find((Session) null, null, null); } else { // the transaction is still open resultCursor = idx.find(session, null, null); } } else { resultCursor = idx.find(session, null, null); } } if (!resultCursor.next()) { return null; } Row row = resultCursor.get(); return row.getValueList(); }
/** {@inheritDoc} */ @Override public Cursor find(Session session, SearchRow first, SearchRow last) { GridH2RowDescriptor desc = ((GridH2Table)idx.getTable()).rowDescriptor(); return idx.find(session, desc.prepareProxyIndexRow(first), desc.prepareProxyIndexRow(last)); }
private void checkMetaFree(Session session, int id) { SearchRow r = meta.getTemplateSimpleRow(false); r.setValue(0, ValueInt.get(id)); Cursor cursor = metaIdIndex.find(session, r, r); if (cursor.next()) { DbException.throwInternalError(); } }
private void rebuildIndexBuffered(Session session, Index index) { Index scan = getScanIndex(session); long remaining = scan.getRowCount(session); long total = remaining; Cursor cursor = scan.find(session, null, null); long i = 0; int bufferSize = (int) Math.min(total, database.getMaxMemoryRows()); ArrayList<Row> buffer = new ArrayList<>(bufferSize); String n = getName() + ":" + index.getName(); int t = MathUtils.convertLongToInt(total); while (cursor.next()) { Row row = cursor.get(); buffer.add(row); database.setProgress(DatabaseEventListener.STATE_CREATE_INDEX, n, MathUtils.convertLongToInt(i++), t); if (buffer.size() >= bufferSize) { addRowsToIndex(session, buffer, index); } remaining--; } addRowsToIndex(session, buffer, index); if (SysProperties.CHECK && remaining != 0) { DbException.throwInternalError("rowcount remaining=" + remaining + " " + getName()); } }
long remaining = scan.getRowCount(session); long total = remaining; Cursor cursor = scan.find(session, null, null); long i = 0; Store store = session.getDatabase().getMvStore();
private Cursor find(Row row) { if (index == null) { // for the case "in(select ...)", the query might // use an optimization and not create the index // up front createIndex(); } Cursor cursor = index.find(session, row, row); while (cursor.next()) { SearchRow found = cursor.getSearchRow(); boolean ok = true; Database db = session.getDatabase(); for (int i = 0; i < row.getColumnCount(); i++) { if (!db.areEqual(row.getValue(i), found.getValue(i))) { ok = false; break; } } if (ok) { return cursor; } } return null; }
private boolean existsRow(Session session, Index searchIndex, SearchRow check, Row excluding) { Table searchTable = searchIndex.getTable(); searchTable.lock(session, false, false); Cursor cursor = searchIndex.find(session, check, check); while (cursor.next()) { SearchRow found; found = cursor.getSearchRow(); if (excluding != null && found.getKey() == excluding.getKey()) { continue; } Column[] cols = searchIndex.getColumns(); boolean allEqual = true; int len = Math.min(columns.length, cols.length); for (int i = 0; i < len; i++) { int idx = cols[i].getColumnId(); Value c = check.getValue(idx); Value f = found.getValue(idx); if (searchTable.compareTypeSafe(c, f) != 0) { allEqual = false; break; } } if (allEqual) { return true; } } return false; }
r.setValue(0, ValueInt.get(id)); boolean wasLocked = lockMeta(session); Cursor cursor = metaIdIndex.find(session, r, r); if (cursor.next()) { if (SysProperties.CHECK) {
return ValueNull.INSTANCE; Cursor cursor = index.find(session, null, null); cursor.next(); int columnId = index.getColumns()[0].getColumnId(); SearchRow check = tableFilter.getTable().getTemplateSimpleRow(true); check.setValue(columnId, ValueNull.INSTANCE); Cursor nullsCursor = index.find(session, check, check); while (nullsCursor.next()) { count--;
Cursor cursor = idx.find((Session) null, h2Row, h2Row);
cursor = idx.find((Session)null, null, null);
objectIds.set(0); starting = true; Cursor cursor = metaIdIndex.find(systemSession, null, null); ArrayList<MetaRecord> records = New.arrayList(); while (cursor.next()) {
long remaining = scan.getRowCount(session); long total = remaining; Cursor cursor = scan.find(session, null, null); long i = 0; int bufferSize = (int) Math.min(rowCount, database.getMaxMemoryRows());
private int generateInsertValues(int count, Table table) throws IOException { PlanItem plan = table.getBestPlanItem(session, null, null, -1, null, null); Index index = plan.getIndex(); Cursor cursor = index.find(session, null, null); Column[] columns = table.getColumns(); StatementBuilder buff = new StatementBuilder("INSERT INTO ");