示例#1
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);
 }
示例#2
0
 private void computeHKeyDerivations(Map<Table, Integer> ordinalMap) {
   indexToHKeys = new IndexToHKey[leafMostTable().getDepth() + 1];
   Table table = leafMostTable();
   while (table != null) {
     int tableDepth = table.getDepth();
     assert tableDepth <= leafMostTable().getDepth() : table;
     AssociationBuilder hKeyBuilder = new AssociationBuilder();
     HKey hKey = table.hKey();
     for (HKeySegment hKeySegment : hKey.segments()) {
       hKeyBuilder.toHKeyEntry(ordinalMap.get(hKeySegment.table()), -1);
       for (HKeyColumn hKeyColumn : hKeySegment.columns()) {
         int indexColumnPosition = positionOf(hKeyColumn.column());
         if (indexColumnPosition == -1) {
           indexColumnPosition = substituteHKeyColumnPosition(hKeyColumn);
         }
         hKeyBuilder.toHKeyEntry(-1, indexColumnPosition);
       }
     }
     indexToHKeys[tableDepth] = hKeyBuilder.createIndexToHKey();
     table = table.getParentTable();
   }
 }