/** * Creates an indexed cursor for the primary key cursor of the given table. * @param table the table over which this cursor will traverse */ public static IndexCursor createPrimaryKeyCursor(Table table) throws IOException { return createCursor(table.getPrimaryKeyIndex()); }
throws IOException return index.getTable().newCursor().setIndex(index) .setStartRow(startRow) .setStartRowInclusive(startInclusive) .setEndRow(endRow) .setEndRowInclusive(endInclusive) .toIndexCursor();
/** * Sets the starting and ending row for a range based index cursor. * <p> * A valid index must be specified before calling this method. */ public CursorBuilder setSpecificRow(Object... specificRow) { setStartRow(specificRow); setEndRow(specificRow); return this; }
@Override protected Cursor getTableNamesCursor() throws IOException { return _systemCatalogCursor.getIndex().newCursor() .setStartEntry(_tableParentId, IndexData.MIN_VALUE) .setEndEntry(_tableParentId, IndexData.MAX_VALUE) .toIndexCursor(); }
/** * Creates an indexed cursor for the given table, narrowed to the given * range. * <p> * Note, index based table traversal may not include all rows, as certain * types of indexes do not include all entries (namely, some indexes ignore * null entries, see {@link Index#shouldIgnoreNulls}). * * @param index index for the table which will define traversal order as * well as enhance certain lookups * @param startRow the first row of data for the cursor (inclusive), or * {@code null} for the first entry * @param endRow the last row of data for the cursor (inclusive), or * {@code null} for the last entry */ public static IndexCursor createCursor(Index index, Object[] startRow, Object[] endRow) throws IOException { return index.getTable().newCursor().setIndex(index) .setStartRow(startRow) .setEndRow(endRow) .toIndexCursor(); }
_tableFinder = new DefaultTableFinder( _systemCatalog.newCursor() .setIndexByColumnNames(CAT_COL_PARENT_ID, CAT_COL_NAME) .setColumnMatcher(CaseInsensitiveColumnMatcher.INSTANCE) .toIndexCursor()); } catch(IllegalArgumentException e) { if(LOG.isDebugEnabled()) { .setColumnMatcher(CaseInsensitiveColumnMatcher.INSTANCE) .toCursor());
/** * Creates a Cursor restricted to the given column value if possible (using * an existing index), otherwise a simple table cursor. */ private Cursor createCursorWithOptionalIndex( TableImpl table, String colName, Object colValue) throws IOException { try { return table.newCursor() .setIndexByColumnNames(colName) .setSpecificEntry(colValue) .toCursor(); } catch(IllegalArgumentException e) { if(LOG.isDebugEnabled()) { LOG.debug(withErrorContext( "Could not find expected index on table " + table.getName())); } } // use table scan instead return CursorImpl.createCursor(table); }
/** * Creates an indexed cursor for the given table. * <p> * Note, index based table traversal may not include all rows, as certain * types of indexes do not include all entries (namely, some indexes ignore * null entries, see {@link Index#shouldIgnoreNulls}). * * @param index index for the table which will define traversal order as * well as enhance certain lookups */ public static IndexCursor createCursor(Index index) throws IOException { return index.getTable().newCursor().setIndex(index).toIndexCursor(); }
private List<Relationship> getRelationshipsImpl( TableImpl table1, TableImpl table2, boolean includeSystemTables) throws IOException { initRelationships(); List<Relationship> relationships = new ArrayList<Relationship>(); if(table1 != null) { Cursor cursor = createCursorWithOptionalIndex( _relationships, REL_COL_FROM_TABLE, table1.getName()); collectRelationships(cursor, table1, table2, relationships, includeSystemTables); cursor = createCursorWithOptionalIndex( _relationships, REL_COL_TO_TABLE, table1.getName()); collectRelationships(cursor, table2, table1, relationships, includeSystemTables); } else { collectRelationships(new CursorBuilder(_relationships).toCursor(), null, null, relationships, includeSystemTables); } return relationships; }
IndexCursor primaryCursor = primaryIdx.newCursor().toIndexCursor(); Object[] entryValues = new Object[_secondaryCols.size()]; for(Row row : _secondaryTable.newCursor().toCursor() .newIterable().addColumns(_secondaryCols)) {
/** * Returns a new index cursor for the table, constructed to the given * specifications. */ public IndexCursor toIndexCursor() throws IOException { return (IndexCursorImpl)toCursor(); }
/** * Sets an index to use for the cursor by searching the table for an index * with the given name. * @throws IllegalArgumentException if no index can be found on the table * with the given name */ public CursorBuilder setIndexByName(String indexName) { return setIndex(_table.getIndex(indexName)); }
@Override public CursorBuilder newCursor() { return new CursorBuilder(this); }
/** * Convenience method for finding a specific row by the primary key of the * table. See {@link IndexCursor#findRowByEntry(Object...)} for details on * the entryValues. * * @param table the table to search * @param entryValues the column values for the table's primary key columns. * @return the matching row or {@code null} if a match could not be found. */ public static Row findRowByPrimaryKey(Table table, Object... entryValues) throws IOException { return findRowByEntry(table.getPrimaryKeyIndex(), entryValues); }
/** * Sets the ending row for a range based index cursor to the given entry * (where the given values correspond to the index's columns). * <p> * A valid index must be specified before calling this method. */ public CursorBuilder setEndEntry(Object... endEntry) { if(endEntry != null) { setEndRow(_index.constructPartialIndexRowFromEntry( IndexData.MAX_VALUE, endEntry)); } return this; }
public OleBlob getOleBlob(Database db) throws UcanaccessSQLException { try { Table t = db.getTable(tableName); Cursor c = CursorBuilder.createPrimaryKeyCursor(t); return c.findFirstRow(key) ? c.getCurrentRow().getBlob(columnName) : null; } catch (IOException e) { throw new UcanaccessSQLException(e); } }
/** * Creates a normal, un-indexed cursor for the given table. * @param table the table over which this cursor will traverse */ public static Cursor createCursor(Table table) throws IOException { return table.newCursor().toCursor(); }
@Override public CursorBuilder newCursor() { return getTable().newCursor().setIndex(this); }
/** * 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); }