/** * Create an array of index columns from a list of columns. The default sort * type is used. * * @param columns the column list * @return the index column array */ public static IndexColumn[] wrap(Column[] columns) { IndexColumn[] list = new IndexColumn[columns.length]; for (int i = 0; i < list.length; i++) { list[i] = new IndexColumn(); list[i].column = columns[i]; } return list; }
/** * Creates index column for table. * * @param col Column index. * @param sorting Sorting order {@link SortOrder} * @return Created index column. */ public IndexColumn indexColumn(int col, int sorting) { IndexColumn res = new IndexColumn(); res.column = getColumn(col); res.columnName = res.column.getName(); res.sortType = sorting; return res; }
/** * @param tbl Table. * @param sortCols Sort columns. * @return Index columns. */ public static IndexColumn[] toIndexColumns(Table tbl, List<GridSqlSortColumn> sortCols) { assert !F.isEmpty(sortCols); IndexColumn[] res = new IndexColumn[sortCols.size()]; for (int i = 0; i < res.length; i++) { GridSqlSortColumn sc = sortCols.get(i); Column col = tbl.getColumn(sc.column()); IndexColumn c = new IndexColumn(); c.column = col; c.columnName = col.getName(); c.sortType = sc.asc ? SortOrder.ASCENDING : SortOrder.DESCENDING; if (sc.nullsFirst) c.sortType |= SortOrder.NULLS_FIRST; if (sc.nullsLast) c.sortType |= SortOrder.NULLS_LAST; res[i] = c; } return res; }
private IndexColumn[] parseIndexColumnList() { ArrayList<IndexColumn> columns = New.arrayList(); do { IndexColumn column = new IndexColumn(); column.columnName = readColumnIdentifier(); columns.add(column); if (readIf("ASC")) { // ignore } else if (readIf("DESC")) { column.sortType = SortOrder.DESCENDING; } if (readIf("NULLS")) { if (readIf("FIRST")) { column.sortType |= SortOrder.NULLS_FIRST; } else { read("LAST"); column.sortType |= SortOrder.NULLS_LAST; } } } while (readIfMore(true)); return columns.toArray(new IndexColumn[0]); }
private void createIndex() { IndexColumn[] indexCols = null; // If we need to do distinct, the distinct columns may not match the // sort columns. So we need to disregard the sort. Not ideal. if (sort != null && !distinct) { int[] colIndex = sort.getQueryColumnIndexes(); indexCols = new IndexColumn[colIndex.length]; for (int i = 0; i < colIndex.length; i++) { IndexColumn indexColumn = new IndexColumn(); indexColumn.column = table.getColumn(colIndex[i]); indexColumn.sortType = sort.getSortTypes()[i]; indexColumn.columnName = COLUMN_NAME + i; indexCols[i] = indexColumn; } } else { indexCols = new IndexColumn[columnCount]; for (int i = 0; i < columnCount; i++) { IndexColumn indexColumn = new IndexColumn(); indexColumn.column = table.getColumn(i); indexColumn.columnName = COLUMN_NAME + i; indexCols[i] = indexColumn; } } String indexName = table.getSchema().getUniqueIndexName(session, table, Constants.PREFIX_INDEX); int indexId = session.getDatabase().allocateObjectId(); IndexType indexType = IndexType.createNonUnique(true); index = table.addIndex(session, indexName, indexId, indexCols, indexType, true, null); }
IndexColumn proxyCol = new IndexColumn();
for (int i = 0; i < len; i++) { String c = columns[i]; IndexColumn ic = new IndexColumn(); int idx = c.indexOf('/'); if (idx >= 0) {
IndexColumn c = new IndexColumn(); c.column = table.getColumn(i); indexColumns[indexColumnId] = c;
if (column.isAutoIncrement() && column.isPrimaryKey()) { column.setPrimaryKey(false); IndexColumn[] cols = { new IndexColumn() }; cols[0].columnName = column.getName(); AlterTableAddConstraint pk = new AlterTableAddConstraint( read("KEY"); boolean hash = readIf("HASH"); IndexColumn[] cols = { new IndexColumn() }; cols[0].columnName = column.getName(); AlterTableAddConstraint pk = new AlterTableAddConstraint( IndexColumn[] cols = { new IndexColumn() }; cols[0].columnName = column.getName(); CreateIndex idx = createAffinityIndex(schema, tableName, cols); unique.setConstraintName(constraintName); unique.setType(CommandInterface.ALTER_TABLE_ADD_CONSTRAINT_UNIQUE); IndexColumn[] cols = { new IndexColumn() }; cols[0].columnName = columnName; unique.setIndexColumns(cols); ref.setConstraintName(constraintName); ref.setType(CommandInterface.ALTER_TABLE_ADD_CONSTRAINT_REFERENTIAL); IndexColumn[] cols = { new IndexColumn() }; cols[0].columnName = columnName; ref.setIndexColumns(cols);
public static IndexColumn[] wrap(Column[] columns) { IndexColumn[] list = new IndexColumn[columns.length]; for (int i = 0; i < list.length; i++) { list[i] = new IndexColumn(); list[i].column = columns[i]; } return list; }
/** * Creates index column for table. * * @param col Column index. * @param sorting Sorting order {@link SortOrder} * @return Created index column. */ public IndexColumn indexColumn(int col, int sorting) { IndexColumn res = new IndexColumn(); res.column = getColumn(col); res.columnName = res.column.getName(); res.sortType = sorting; return res; }
/** * Creates index column for table. * * @param col Column index. * @param sorting Sorting order {@link SortOrder} * @return Created index column. */ public IndexColumn indexColumn(int col, int sorting) { IndexColumn res = new IndexColumn(); res.column = getColumn(col); res.columnName = res.column.getName(); res.sortType = sorting; return res; }
public DummyIndex(Table table,int id) { IndexColumn indexColumn = new IndexColumn(); indexColumn.columnName = "key"; indexColumn.column = new Column("key", Value.LONG); initBaseIndex(table,id,table.getName()+"_DATA",new IndexColumn[] {indexColumn}, IndexType.createScan(true)); }
public DummyIndex(Table table,int id) { IndexColumn indexColumn = new IndexColumn(); indexColumn.columnName = "key"; indexColumn.column = new Column("key", Value.LONG); initBaseIndex(table,id,table.getName()+"_DATA",new IndexColumn[] {indexColumn}, IndexType.createScan(true)); }
public DummyIndex(Table table,int id) { IndexColumn indexColumn = new IndexColumn(); indexColumn.columnName = "key"; indexColumn.column = new Column("key", Value.LONG); initBaseIndex(table,id,table.getName()+"_DATA",new IndexColumn[] {indexColumn}, IndexType.createScan(true)); }
public DummyIndex(Table table,int id) { IndexColumn indexColumn = new IndexColumn(); indexColumn.columnName = "key"; indexColumn.column = new Column("key", Value.LONG); initBaseIndex(table,id,table.getName()+"_DATA",new IndexColumn[] {indexColumn}, IndexType.createScan(true)); }
/** * Constructor for scan index. Hidden column _ROWID_. * @param driver Linked file driver * @param table Linked table * @param id Index identifier */ public H2TableIndex(FileDriver driver, Table table, int id) { this.isScanIndex = true; this.driver = driver; IndexColumn indexColumn = new IndexColumn(); indexColumn.columnName = "key"; indexColumn.column = new Column("key", Value.LONG); initBaseIndex(table, id, table.getName() + "_ROWID_", new IndexColumn[]{indexColumn}, IndexType.createScan(true)); }
/** * Constructor for scan index. Hidden column _ROWID_. * @param driver Linked file driver * @param table Linked table * @param id Index identifier */ public H2TableIndex(FileDriver driver, Table table, int id) { this.isScanIndex = true; this.driver = driver; IndexColumn indexColumn = new IndexColumn(); indexColumn.columnName = "key"; indexColumn.column = new Column("key", Value.LONG); initBaseIndex(table, id, table.getName() + "_ROWID_", new IndexColumn[]{indexColumn}, IndexType.createScan(true)); }
/** * Constructor for scan index. Hidden column _ROWID_. * @param driver Linked file driver * @param table Linked table * @param id Index identifier */ public H2TableIndex(FileDriver driver, Table table, int id) { this.isScanIndex = true; this.driver = driver; IndexColumn indexColumn = new IndexColumn(); indexColumn.columnName = "key"; indexColumn.column = new Column("key", Value.LONG); initBaseIndex(table, id, table.getName() + "_ROWID_", new IndexColumn[]{indexColumn}, IndexType.createScan(true)); }
/** * Constructor for scan index. Hidden column _ROWID_. * @param driver Linked file driver * @param table Linked table * @param id Index identifier */ public H2TableIndex(FileDriver driver, Table table, int id) { this.isScanIndex = true; this.driver = driver; IndexColumn indexColumn = new IndexColumn(); indexColumn.columnName = "key"; indexColumn.column = new Column("key", Value.LONG); initBaseIndex(table, id, table.getName() + "_ROWID_", new IndexColumn[]{indexColumn}, IndexType.createScan(true)); }