示例#1
0
 private void createSchema() throws InvalidOperationException {
   String schemaName = schemaName();
   String pTableName = newTableName();
   p = createTable(schemaName, pTableName, "pid int not null", "primary key(pid)");
   String cTableName = newTableName();
   c =
       createTable(
           schemaName,
           cTableName,
           "cid int not null",
           "pid int",
           "primary key(cid)",
           String.format("grouping foreign key(pid) references %s(pid)", pTableName));
   String dTableName = newTableName();
   d =
       createTable(
           schemaName,
           dTableName,
           "did int not null",
           "pid int",
           "primary key(did)",
           String.format("grouping foreign key(pid) references %s(pid)", pTableName));
   schema = SchemaCache.globalSchema(ais());
   pRowType = schema.tableRowType(table(p));
   cRowType = schema.tableRowType(table(c));
   dRowType = schema.tableRowType(table(d));
   group = group(p);
   adapter = newStoreAdapter();
   queryContext = queryContext(adapter);
   queryBindings = queryContext.createBindings();
 }
 @Before
 public void createAndLoad() {
   cID = createTable(SCHEMA, C_TABLE, "cid INT NOT NULL PRIMARY KEY, w INT");
   aID =
       createTable(
           SCHEMA,
           A_TABLE,
           "aid INT NOT NULL PRIMARY KEY, cid INT, x INT, GROUPING FOREIGN KEY(cid) REFERENCES c(cid)");
   oID =
       createTable(
           SCHEMA,
           O_TABLE,
           "oid INT NOT NULL PRIMARY KEY, cid INT, y INT, GROUPING FOREIGN KEY(cid) REFERENCES c(cid)");
   iID =
       createTable(
           SCHEMA,
           I_TABLE,
           "iid INT NOT NULL PRIMARY KEY, oid INT, z INT, GROUPING FOREIGN KEY(oid) REFERENCES o(oid)");
   Schema schema = SchemaCache.globalSchema(ais());
   cRowType = schema.tableRowType(cID);
   aRowType = schema.tableRowType(aID);
   oRowType = schema.tableRowType(oID);
   iRowType = schema.tableRowType(iID);
   writeRows( // unknown
       // no O(65, 6)
       createNewRow(iID, 650, 65, 650000), // 0
       createNewRow(cID, 2, 2000), // 1
       createNewRow(aID, 20, 2, 20000), // 2
       createNewRow(oID, 25, 2, 25000), // 3
       createNewRow(iID, 250, 25, 250000), // 4
       createNewRow(cID, 4, 4000), // 5
       // no A(40, 4, 40000)
       createNewRow(oID, 45, 4, 45000), // 6
       createNewRow(iID, 450, 45, 450000), // 7
       createNewRow(cID, 6, 6000), // 8
       createNewRow(aID, 60, 6, 60000)); // 9
   groupRows = runPlanTxn(groupScanCreator(cID));
 }