@Override public Row get() { if (cursor == null) { return null; } return cursor.get(); }
/** * Load the current row. */ void loadCurrent() { synchronized (sync) { baseRow = baseCursor.getSearchRow(); deltaRow = deltaCursor.get(); needNewDelta = false; needNewBase = false; } }
private void loadNext(boolean base) { synchronized (sync) { if (base) { if (step(baseCursor)) { baseRow = baseCursor.getSearchRow(); } else { baseRow = null; } } else { if (step(deltaCursor)) { deltaRow = deltaCursor.get(); } else { deltaRow = null; } } } }
/** * @param rangeId Requested range ID. * @return Current row. */ public Row get(int rangeId) { assert rangeId == cursorRangeId; return cursor.get(); } }
@Override public int removeRow(Value[] values) { Row row = convertToRow(values); Cursor cursor = find(row); if (cursor != null) { row = cursor.get(); table.removeRow(session, row); rowCount--; } return rowCount; }
/** * Check if there is an uncommitted row with the given key * within a different session. * * @param session the original session * @param row the row (only the key is checked) * @return true if there is an uncommitted row */ public boolean isUncommittedFromOtherSession(Session session, Row row) { Cursor c = delta.find(session, row, row); while (c.next()) { Row r = c.get(); return r.getSessionId() != session.getId(); } return false; }
/** * 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; } }
public BitField getObjectIds() { BitField f = new BitField(); Cursor cursor = metaIndex.find(pageStoreSession, null, null); while (cursor.next()) { Row row = cursor.get(); int id = row.getValue(0).getInt(); if (id > 0) { f.set(id); } } return f; }
private void readMetaData() { Cursor cursor = metaIndex.find(pageStoreSession, null, null); // first, create all tables while (cursor.next()) { Row row = cursor.get(); int type = row.getValue(1).getInt(); if (type == META_TYPE_DATA_INDEX) { addMeta(row, pageStoreSession, false); } } // now create all secondary indexes // otherwise the table might not be created yet cursor = metaIndex.find(pageStoreSession, null, null); while (cursor.next()) { Row row = cursor.get(); int type = row.getValue(1).getInt(); if (type != META_TYPE_DATA_INDEX) { addMeta(row, pageStoreSession, false); } } }
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()); } }
ArrayList<String> bufferNames = New.arrayList(); while (cursor.next()) { Row row = cursor.get(); buffer.add(row); database.setProgress(DatabaseEventListener.STATE_CREATE_INDEX, n,
/** * Get the value for the given column. * * @param filterId table filter id * @param column the column * @return column value for current row */ public Value getValue(int filterId, Column column) { if (current == null) { return null; } Object x = current.row(filterId); assert x != null; Row row = current.isRow(filterId) ? (Row) x : ((Cursor) x).get(); int columnId = column.getColumnId(); if (columnId == -1) { return ValueLong.get(row.getKey()); } Value value = row.getValue(column.getColumnId()); if (value == null) { throw DbException.throwInternalError("value is null: " + column + " " + row); } return value; }
private boolean removeIfExists(Session session, Row row) { // maybe it was inserted by the same session just before Cursor c = delta.find(session, row, row); while (c.next()) { Row r = c.get(); if (r.getKey() == row.getKey() && r.getVersion() == row.getVersion()) { if (r != row && table.getScanIndex(session).compareRows(r, row) != 0) { row.setVersion(r.getVersion() + 1); } else { delta.remove(session, r); return true; } } } return false; }
@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(); }
Row found = cursor.get(); meta.removeRow(session, found); if (isMultiVersion()) {
GridH2Row h2Row = (GridH2Row)cursor.get();
current = current.copyBehind(jfId); current.updateRow(jfId, c.get(), JoinRow.S_CURSOR, JoinRow.S_ROW);
database.setProgress(DatabaseEventListener.STATE_CREATE_INDEX, n, MathUtils.convertLongToInt(i++), t); Row row = cursor.get(); buffer.add(row); if (buffer.size() >= bufferSize) {
buff = null; while (cursor.next()) { Row row = cursor.get(); if (buff == null) { buff = new StatementBuilder(ins);