HKeySegment { public Table table() { return table; } HKeySegment(HKey hKey, Table table); @Override String toString(); HKey hKey(); Table table(); int positionInHKey(); List<HKeyColumn> columns(); HKeyColumn addColumn(Column column);  }
@Test public void nonCascading() { AkibanInformationSchema ais = AISBBasedBuilder.create(SCHEMA, MTypesTranslator.INSTANCE) .table("c") .colInt("cid") .colString("name", 64) .pk("cid") .table("o") .colInt("oid") .colInt("c_id") .colString("date", 32) .pk("oid") .joinTo("c").on("c_id", "cid") .table("i") .colInt("iid") .colInt("o_id") .colInt("sku") .pk("iid") .joinTo("o").on("o_id", "oid") .ais(); checkHKeyColumn( ais, "c", expectedSegments(1).checkSegment(0).expectedCols(1).checkCol(0).expectAtIndex(0), c("c", "cid"), c("o", "c_id")); checkHKeyColumn( ais, "o", expectedSegments(2).checkSegment(0).expectedCols(1).checkCol(0).expectAtIndex(1), c("c", "cid"), c("o", "c_id")); checkHKeyColumn( ais, "o", expectedSegments(2).checkSegment(1).expectedCols(1).checkCol(0).expectAtIndex(0), c("o", "oid"), c("i", "o_id")); checkHKeyColumn( ais, "i", expectedSegments(3).checkSegment(0).expectedCols(1).checkCol(0).expectAtIndex(1), c("c", "cid"), c("o", "c_id")); checkHKeyColumn( ais, "i", expectedSegments(3).checkSegment(1).expectedCols(1).checkCol(0).expectAtIndex(1), c("o", "oid"), c("i", "o_id")); checkHKeyColumn( ais, "i", expectedSegments(3).checkSegment(2).expectedCols(1).checkCol(0).expectAtIndex(0), c("i", "iid")); }
@Test public void cascading() { AkibanInformationSchema ais = AISBBasedBuilder.create(SCHEMA, MTypesTranslator.INSTANCE) .table("c") .colInt("cid") .colString("name", 64) .pk("cid") .table("o") .colInt("c_id") .colInt("oid") .colString("date", 32) .pk("c_id", "oid") .joinTo("c").on("c_id", "cid") .table("i") .colInt("c__id") .colInt("o_id") .colInt("iid") .colInt("sku") .pk("c__id", "o_id", "iid") .joinTo("o").on("c__id","c_id").and("o_id", "oid") .ais(); checkHKeyColumn( ais, "c", expectedSegments(1).checkSegment(0).expectedCols(1).checkCol(0).expectAtIndex(0), c("c", "cid"), c("o", "c_id"), c("i", "c__id")); checkHKeyColumn( ais, "o", expectedSegments(2).checkSegment(0).expectedCols(1).checkCol(0).expectAtIndex(1), c("c", "cid"), c("o", "c_id"), c("i", "c__id")); checkHKeyColumn( ais, "o", expectedSegments(2).checkSegment(1).expectedCols(1).checkCol(0).expectAtIndex(0), c("o", "oid"), c("i", "o_id")); checkHKeyColumn( ais, "i", expectedSegments(3).checkSegment(0).expectedCols(1).checkCol(0).expectAtIndex(2), c("c", "cid"), c("o", "c_id"), c("i", "c__id")); checkHKeyColumn( ais, "i", expectedSegments(3).checkSegment(1).expectedCols(1).checkCol(0).expectAtIndex(1), c("o", "oid"), c("i", "o_id")); checkHKeyColumn( ais, "i", expectedSegments(3).checkSegment(2).expectedCols(1).checkCol(0).expectAtIndex(0), c("i", "iid")); }
@Test public void multiColumnPkNoCascade() { AkibanInformationSchema ais = AISBBasedBuilder.create(SCHEMA, MTypesTranslator.INSTANCE) .table("c") .colInt("cid1") .colInt("cid2") .colString("name", 64) .pk("cid1", "cid2") .table("o") .colInt("oid") .colInt("c_id1") .colInt("c_id2") .colString("date", 32) .pk("oid") .joinTo("c").on("c_id1", "cid1").and("c_id2", "cid2") .table("i") .colInt("iid") .colInt("o_id") .colInt("sku") .pk("iid") .joinTo("o").on("o_id", "oid") .ais(); checkHKeyColumn( ais, "c", expectedSegments(1).checkSegment(0).expectedCols(2).checkCol(0).expectAtIndex(0), c("c", "cid1"), c("o", "c_id1")); checkHKeyColumn( ais, "c", expectedSegments(1).checkSegment(0).expectedCols(2).checkCol(1).expectAtIndex(0), c("c", "cid2"), c("o", "c_id2")); checkHKeyColumn( ais, "o", expectedSegments(2).checkSegment(0).expectedCols(2).checkCol(0).expectAtIndex(1), c("c", "cid1"), c("o", "c_id1")); checkHKeyColumn( ais, "o", expectedSegments(2).checkSegment(0).expectedCols(2).checkCol(1).expectAtIndex(1), c("c", "cid2"), c("o", "c_id2")); checkHKeyColumn( ais, "o", expectedSegments(2).checkSegment(1).expectedCols(1).checkCol(0).expectAtIndex(0), c("o", "oid"), c("i", "o_id")); checkHKeyColumn( ais, "i", expectedSegments(3).checkSegment(0).expectedCols(2).checkCol(0).expectAtIndex(1), c("c", "cid1"), c("o", "c_id1")); checkHKeyColumn( ais, "i", expectedSegments(3).checkSegment(0).expectedCols(2).checkCol(1).expectAtIndex(1), c("c", "cid2"), c("o", "c_id2")); checkHKeyColumn( ais, "i", expectedSegments(3).checkSegment(1).expectedCols(1).checkCol(0).expectAtIndex(1), c("o", "oid"), c("i", "o_id")); checkHKeyColumn( ais, "i", expectedSegments(3).checkSegment(2).expectedCols(1).checkCol(0).expectAtIndex(0), c("i", "iid")); }