@Override protected int findMaxSyntheticId() throws IOException { initIdCursor(); _systemCatalogIdCursor.reset(); // synthetic ids count up from min integer. so the current, highest, // in-use synthetic id is the max id < 0. _systemCatalogIdCursor.findClosestRowByEntry(0); if(!_systemCatalogIdCursor.moveToPreviousRow()) { return Integer.MIN_VALUE; } ColumnImpl idCol = _systemCatalog.getColumn(CAT_COL_ID); return (Integer)_systemCatalogIdCursor.getCurrentRowValue(idCol); } }
@Override protected Cursor findRow(Integer parentId, String name) throws IOException { return (_systemCatalogCursor.findFirstRowByEntry(parentId, name) ? _systemCatalogCursor : null); }
/** * Convenience method for finding a specific row (as defined by the cursor) * where the index entries match the given values. See {@link * IndexCursor#findRowByEntry(Object...)} for details on the entryValues. * * @param index the index to search * @param entryValues the column values for the index's columns. * @return the matching row or {@code null} if a match could not be found. */ public static Row findRowByEntry(Index index, Object... entryValues) throws IOException { return createCursor(index).findRowByEntry(entryValues); }
IndexCursor cursor = new CursorBuilder(ptabl).setIndexByColumnNames("id").toIndexCursor(); if(cursor.findFirstRowByEntry(1)) { cursor.deleteCurrentRow(); }
Table table = db.getTable("Members"); String dateColumnName = "DateJoined"; Column dateColumn = table.getColumn(dateColumnName); IndexCursor cursor = CursorBuilder.createCursor(table.getIndex(dateColumnName)); String searchDateAsString = "2014/03/01"; SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd"); Date search_date = sdf.parse(searchDateAsString); cursor.findClosestRowByEntry(search_date); if (cursor.isAfterLast()) { System.out.println(String.format("There are no rows with %s >= %s", dateColumnName, searchDateAsString)); } else { // we want strictly greater than, so skip over the rows that are equal while (search_date.equals(cursor.getCurrentRowValue(dateColumn))) { if (!cursor.moveToNextRow()) break; } if (cursor.isAfterLast()) { System.out.println(String.format("There are no rows with %s > %s", dateColumnName, searchDateAsString)); } } // now iterate over the remaining rows while (!cursor.isAfterLast()) { System.out.println(sdf.format(cursor.getCurrentRowValue(dateColumn))); cursor.moveToNextRow(); }
Table tbl = db.getSystemTable("MSysRelationships"); IndexCursor crsr = CursorBuilder.createCursor(tbl.getIndex("szRelationship")); Row r = crsr.findRowByEntry(relationshipName); if (r != null) { while (r != null) { tbl.deleteRow(r); r = crsr.findRowByEntry(relationshipName); rowPattern.put("Name", "Relationships"); rowPattern.put("Type", 3); if (crsr.findFirstRow(rowPattern)) { Integer relationshipsId = crsr.getCurrentRow().getInt("Id"); r = crsr.findRowByEntry(relationshipsId, relationshipName); if (r != null) { Integer relationshipId = r.getInt("Id"); tbl = db.getSystemTable("MSysACEs"); crsr = CursorBuilder.createCursor(tbl.getIndex("ObjectId")); r = crsr.findRowByEntry(relationshipId); while (r != null) { tbl.deleteRow(r); r = crsr.findRowByEntry(relationshipId);
IndexCursor cursor = CursorBuilder.createCursor( complexColumns.getPrimaryKeyIndex()); if(!cursor.findFirstRowByEntry(complexTypeId)) { throw new IOException(column.withErrorContext( "Could not find complex column info for complex column with id " + complexTypeId)); Row cColRow = cursor.getCurrentRow(); int tableId = cColRow.getInt(COL_TABLE_ID); if(tableId != column.getTable().getTableDefPageNumber()) {
/** * Returns selected columns from the first row in the "to" table based on * the given columns in the "from" table if any, {@code null} if there is no * matching row. * * @param fromRow row from the "from" table (which must include the relevant * columns for this join relationship) * @param columnNames desired columns in the from table row */ public Row findFirstRow(Map<String,?> fromRow, Collection<String> columnNames) throws IOException { return (hasRows(fromRow) ? _toCursor.getCurrentRow(columnNames) : null); }
public Index getToIndex() { return getToCursor().getIndex(); }
public Table getToTable() { return getToCursor().getTable(); }
@Override public TableInfo lookupTable(String tableName) throws IOException { if(findRow(_tableParentId, tableName) == null) { return null; } Row row = _systemCatalogCursor.getCurrentRow( SYSTEM_CATALOG_TABLE_DETAIL_COLUMNS); Integer pageNumber = row.getInt(CAT_COL_ID); String realName = row.getString(CAT_COL_NAME); int flags = row.getInt(CAT_COL_FLAGS); Short type = row.getShort(CAT_COL_TYPE); if(!isTableType(type)) { return null; } String linkedDbName = row.getString(CAT_COL_DATABASE); String linkedTableName = row.getString(CAT_COL_FOREIGN_NAME); return createTableInfo(realName, pageNumber, flags, type, linkedDbName, linkedTableName); }
List<? extends Index.Column> toCols = _toCursor.getIndex().getColumns(); sb.append(toCols.get(0).getName()); for(int i = 1; i < toCols.size(); ++i) {
/** * Returns {@code true} if the "to" table has any rows based on the given * columns in the "from" table, {@code false} otherwise. * @usage _intermediate_method_ */ public boolean hasRows(Object[] fromRow) throws IOException { toEntryValues(fromRow); return _toCursor.findFirstRowByEntry(_entryValues); }
@Override protected Cursor getTableNamesCursor() throws IOException { return _systemCatalogCursor.getIndex().newCursor() .setStartEntry(_tableParentId, IndexData.MIN_VALUE) .setEndEntry(_tableParentId, IndexData.MAX_VALUE) .toIndexCursor(); }
@Override protected Cursor findRow(Integer objectId) throws IOException { initIdCursor(); return (_systemCatalogIdCursor.findFirstRowByEntry(objectId) ? _systemCatalogIdCursor : null); }
/** * Returns {@code true} if the "to" table has any rows based on the given * columns in the "from" table, {@code false} otherwise. */ public boolean hasRows(Map<String,?> fromRow) throws IOException { toEntryValues(fromRow); return _toCursor.findFirstRowByEntry(_entryValues); }
if(!primaryCursor.findFirstRowByEntry(entryValues)) { throw new ConstraintViolationException(withErrorContext( "Integrity constraint violation found for relationship"));