예제 #1
0
  @Override
  public void addColumn(IndexColumn indexColumn) {
    Table indexTable = indexColumn.getColumn().getTable();
    Integer indexTableDepth = indexTable.getDepth();
    assert indexTableDepth != null;

    super.addColumn(indexColumn);
    GroupIndexHelper.actOnGroupIndexTables(this, indexColumn, GroupIndexHelper.ADD);

    // Add the table into our navigable map if needed. Confirm it's within the branch
    ParticipatingTable participatingTable = tablesByDepth.get(indexTableDepth);
    if (participatingTable == null) {
      Map.Entry<Integer, ParticipatingTable> rootwardEntry =
          tablesByDepth.floorEntry(indexTableDepth);
      Map.Entry<Integer, ParticipatingTable> leafwardEntry =
          tablesByDepth.ceilingEntry(indexTableDepth);
      checkIndexTableInBranchNew(indexColumn, indexTable, indexTableDepth, rootwardEntry, true);
      checkIndexTableInBranchNew(indexColumn, indexTable, indexTableDepth, leafwardEntry, false);
      participatingTable = new ParticipatingTable(indexTable);
      tablesByDepth.put(indexTableDepth, participatingTable);
    } else if (participatingTable.table != indexTable) {
      throw new BranchingGroupIndexException(
          indexColumn.getIndex().getIndexName().getName(),
          indexTable.getName(),
          participatingTable.table.getName());
    }
    participatingTable.markInvolvedInIndex(indexColumn.getColumn());
  }
예제 #2
0
 private void computeFieldAssociations(
     Map<Table, Integer> ordinalMap, Map<? extends Table, Integer> flattenedRowOffsets) {
   freezeColumns();
   allColumns = new ArrayList<>();
   allColumns.addAll(keyColumns);
   AssociationBuilder toIndexRowBuilder = new AssociationBuilder();
   List<Column> indexColumns = new ArrayList<>();
   // Add index key fields
   for (IndexColumn iColumn : getKeyColumns()) {
     Column column = iColumn.getColumn();
     indexColumns.add(column);
     toIndexRowBuilder.rowCompEntry(columnPosition(flattenedRowOffsets, column), -1);
   }
   // Add hkey fields not already included
   int indexColumnPosition = indexColumns.size();
   HKey hKey = hKey();
   for (HKeySegment hKeySegment : hKey.segments()) {
     Integer ordinal = ordinalMap.get(hKeySegment.table());
     assert ordinal != null : hKeySegment.table();
     for (HKeyColumn hKeyColumn : hKeySegment.columns()) {
       Column undeclaredHKeyColumn = undeclaredHKeyColumn(hKeyColumn);
       if (!indexColumns.contains(undeclaredHKeyColumn)) {
         toIndexRowBuilder.rowCompEntry(
             columnPosition(flattenedRowOffsets, undeclaredHKeyColumn), -1);
         indexColumns.add(undeclaredHKeyColumn);
         allColumns.add(
             new IndexColumn(this, undeclaredHKeyColumn, indexColumnPosition++, true, 0));
       }
     }
   }
   indexRowComposition = toIndexRowBuilder.createIndexRowComposition();
   computeHKeyDerivations(ordinalMap);
 }
예제 #3
0
 private int positionOf(Column column) {
   for (IndexColumn indexColumn : allColumns) {
     if (indexColumn.getColumn() == column) {
       return indexColumn.getPosition();
     }
   }
   return -1;
 }
예제 #4
0
  public List<String> getColumns() {
    if (columns == null) return Collections.emptyList();

    if (columns.size() > 1) {
      Collections.sort(this.columns, IndexColumn.getSequenceSorter());
    }
    List<String> result = new ArrayList<>(columns.size());
    for (IndexColumn col : columns) {
      result.add(col.getColumn());
    }
    return result;
  }