コード例 #1
0
ファイル: GroupIndex.java プロジェクト: ianblenke/sql-layer
  @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
ファイル: GroupIndex.java プロジェクト: ianblenke/sql-layer
  @Override
  public void computeFieldAssociations(Map<Table, Integer> ordinalMap) {
    List<Table> branchTables = new ArrayList<>();
    for (Table table = leafMostTable(); table != null; table = table.getParentTable()) {
      branchTables.add(table);
    }
    Collections.reverse(branchTables);

    Map<Table, Integer> offsetsMap = new HashMap<>();
    int offset = 0;
    columnsPerFlattenedField = new ArrayList<>();
    for (Table table : branchTables) {
      offsetsMap.put(table, offset);
      offset += table.getColumnsIncludingInternal().size();
      columnsPerFlattenedField.addAll(table.getColumnsIncludingInternal());
    }
    computeFieldAssociations(ordinalMap, offsetsMap);
    // Complete computation of inIndex bitsets
    for (ParticipatingTable participatingTable : tablesByDepth.values()) {
      participatingTable.close();
    }
  }