📄 t_b2i.java
字号:
TransactionController.OPENMODE_FORUPDATE, TransactionController.MODE_RECORD, TransactionController.ISOLATION_SERIALIZABLE); if (!(index_cc instanceof B2IController)) { throw T_Fail.testFailMsg("openConglomerate returned wrong type"); } index_cc.checkConsistency(); // Create a row and insert into base table, remembering it's location. DataValueDescriptor[] r1 = TemplateRow.newU8Row(2); T_SecondaryIndexRow index_row1 = new T_SecondaryIndexRow(); RowLocation base_rowloc1 = base_cc.newRowLocationTemplate(); index_row1.init(r1, base_rowloc1, 3); // Commit the create of the tables so that the following aborts don't // undo that work. tc.commit(); // Now try aborts of transactions during splits, using magic // trace flags. This test inserts enough rows to cause a split // and then forces the split to fail at various key points. The // split should be backed out and also the rows before the split. // The test makes sure that there are some inserts before the forced // split abort. String[] debug_strings = { "leaf_split_growRoot1", "leaf_split_growRoot2", "leaf_split_growRoot3", "leaf_split_growRoot4", "leaf_split_growRoot5", "leaf_split_abort1", "leaf_split_abort2", "leaf_split_abort3", "leaf_split_abort4", "branch_split_abort1", "branch_split_abort2", "branch_split_abort3", "branch_split_abort4", "BTreeController_doIns2" }; for (int errs = 0; errs < debug_strings.length; errs++) { REPORT("Doing abort test: " + debug_strings[errs]); // set the debug flag, which will cause an error // RESOLVE (mmm) these tests should be run from the language to // make sure error handling really works. if (SanityManager.DEBUG) SanityManager.DEBUG_SET(debug_strings[errs]); try { // Open the base table base_cc = tc.openConglomerate( create_ret.base_conglomid, false, TransactionController.OPENMODE_FORUPDATE, TransactionController.MODE_RECORD, TransactionController.ISOLATION_SERIALIZABLE); // Open the secondary index index_cc = tc.openConglomerate( create_ret.index_conglomid, false, TransactionController.OPENMODE_FORUPDATE, TransactionController.MODE_RECORD, TransactionController.ISOLATION_SERIALIZABLE); // insert one row that does not cause failure. ((SQLLongint)r1[0]).setValue(2); ((SQLLongint)r1[1]).setValue(10000 + errs); // Insert the row into the base table;remember its location. base_cc.insertAndFetchLocation(r1, base_rowloc1); // Insert the row into the secondary index. if (index_cc.insert(index_row1.getRow()) != 0) throw T_Fail.testFailMsg("insert failed"); // set the debug flag, which will cause an error // RESOLVE (mmm) these tests should be run from the // language to make sure error handling really works. if (SanityManager.DEBUG) SanityManager.DEBUG_SET(debug_strings[errs]); // now insert enough rows to cause failure for (int i = 100; i > 0; i -= 2) { ((SQLLongint)r1[0]).setValue(2); ((SQLLongint)r1[1]).setValue(i); // Insert the row into the base table;remember its location. base_cc.insertAndFetchLocation(r1, base_rowloc1); // Insert the row into the secondary index. if (index_cc.insert(index_row1.getRow()) != 0) { throw T_Fail.testFailMsg("insert failed"); } } throw T_Fail.testFailMsg( "debug flag (" + debug_strings[errs] + ")did not cause exception."); } catch (StandardException e) { ContextService contextFactory = ContextService.getFactory(); // Get the context manager. ContextManager cm = contextFactory.getCurrentContextManager(); if (SanityManager.DEBUG) SanityManager.ASSERT(cm != null); cm.cleanupOnError(e); // RESOLVE (mikem) - when split abort works come up with // a good sanity check here. // // index check - there should be no records: scan = tc.openScan(create_ret.index_conglomid, false, TransactionController.OPENMODE_FORUPDATE, TransactionController.MODE_RECORD, TransactionController.ISOLATION_SERIALIZABLE, (FormatableBitSet) null, null, ScanController.NA, null, null, ScanController.NA); index_cc = tc.openConglomerate( create_ret.index_conglomid, false, TransactionController.OPENMODE_FORUPDATE, TransactionController.MODE_RECORD, TransactionController.ISOLATION_SERIALIZABLE); index_cc.checkConsistency(); index_cc.close(); if (scan.next()) { throw T_Fail.testFailMsg( "t_002: there are still rows in table."); } scan.close(); } // Unset the flag. if (SanityManager.DEBUG) SanityManager.DEBUG_CLEAR(debug_strings[errs]); } // Try a simple abort. The following adds enough rows to cause a // split. The result of the split should be a tree with no rows, but // the splits will not be undone. It is up to the implementation // whether the undo's cause shrinks in the tree. In the initial // implementation it won't. { tc.commit(); // Open the base table base_cc = tc.openConglomerate( create_ret.base_conglomid, false, TransactionController.OPENMODE_FORUPDATE, TransactionController.MODE_RECORD, TransactionController.ISOLATION_SERIALIZABLE); // Open the secondary index index_cc = tc.openConglomerate( create_ret.index_conglomid, false, TransactionController.OPENMODE_FORUPDATE, TransactionController.MODE_RECORD, TransactionController.ISOLATION_SERIALIZABLE); // BTree.PROPERTY_MAX_ROWS_PER_PAGE_PARAMETER has been set to 2 so // inserting 3 rows will cause a split at the leaf level. // Make sure that normal abort leaves the committed split. for (int i = 0; i < 3; i++) { ((SQLLongint)r1[0]).setValue(2); ((SQLLongint)r1[1]).setValue(i); // Insert the row into the base table;remember its location. base_cc.insertAndFetchLocation(r1, base_rowloc1); // Insert the row into the secondary index. if (index_cc.insert(index_row1.getRow()) != 0) throw T_Fail.testFailMsg("insert failed"); } tc.abort(); // index check - there should be no records left. ScanController empty_scan = tc.openScan(create_ret.index_conglomid, false, 0, TransactionController.MODE_RECORD, TransactionController.ISOLATION_SERIALIZABLE, (FormatableBitSet) null, null, ScanController.NA, null, null, ScanController.NA); if (empty_scan.next()) { throw T_Fail.testFailMsg( "t_002: there are still rows in table."); } } tc.commit(); REPORT("Ending t_002"); return true; } private boolean t_003_scan_test_cases( TransactionController tc, long index_conglomid, T_SecondaryIndexRow template ) throws StandardException, T_Fail { boolean ret_val = true; // run through a predicates as described in the openScan() interface // DataValueDescriptor[] start_key = TemplateRow.newU8Row(1); DataValueDescriptor[] stop_key = TemplateRow.newU8Row(1); // test predicate x = 5 // // result set should be: {5,2,16}, {5,4,17}, {5,6,18} // REPORT("scan (x = 5)"); ((SQLLongint)start_key[0]).setValue(5); ((SQLLongint)stop_key[0]).setValue(5); if (!T_QualifierTest.t_scan(tc, index_conglomid, template.getRow(), template.getRow(), start_key, ScanController.GE, null, stop_key, ScanController.GT, 3, 16, T_QualifierTest.ORDER_FORWARD)) { ret_val = false; } // +---------------------------------------------------------+ // |pred |start|key|stop |key|rows returned |rows locked | // | |value|op |value|op | |(serialization)| // +------+-----+---+-----+---+--------------+---------------+ // |x > 5 |{5} |GT |null | |{6,1} .. {9,1}|{5,6} .. {9,1} | // +-----------------------------------------+---------------+ REPORT("scan (x > 5)"); ((SQLLongint)start_key[0]).setValue(5); if (!T_QualifierTest.t_scan(tc, index_conglomid, template.getRow(), template.getRow(), start_key, ScanController.GT, null, null, ScanController.NA, 3, 19, T_QualifierTest.ORDER_FORWARD)) { ret_val = false; } // +---------------------------------------------------------+ // |pred |start|key|stop |key|rows returned |rows locked | // | |value|op |value|op | |(serialization)| // +------+-----+---+-----+---+--------------+---------------+ // |x >= 5|{5} |GE |null | |{5,2} .. {9,1}|{4,6} .. {9,1} | // +-----------------------------------------+---------------+ REPORT("scan (x >= 5)"); ((SQLLongint)start_key[0]).setValue(5); if (!T_QualifierTest.t_scan(tc, index_conglomid, template.getRow(), template.getRow(), start_key, ScanController.GE, null, null, ScanController.NA, 6, 16, T_QualifierTest.ORDER_FORWARD)) { ret_val = false; } // // +---------------------------------------------------------+ // |pred |start|key|stop |key|rows returned |rows locked | // | |value|op |value|op | |(serialization)| // +------+-----+---+-----+---+--------------+---------------+ // |x <= 5|null | |{5} |GT |{1,1} .. {5,6}|first .. {5,6} | // +-----------------------------------------+---------------+ REPORT("scan (x <= 5)"); ((SQLLongint)stop_key[0]).setValue(5); if (!T_QualifierTest.t_scan(tc, index_conglomid, template.getRow(), template.getRow(), null, ScanController.NA, null, stop_key, ScanController.GT, 8, 11, T_QualifierTest.ORDER_FORWARD)) { ret_val = false; } // // +---------------------------------------------------------+ // |pred |start|key|stop |key|rows returned |rows locked | // | |value|op |value|op | |(serialization)| // +------+-----+---+-----+---+--------------+---------------+ // |x < 5 |null | |{5} |GE |{1,1} .. {4,6}|first .. {4,6} | // +-----------------------------------------+---------------+ REPORT("scan (x < 5)"); ((SQLLongint)stop_key[0]).setValue(5); if (!T_QualifierTest.t_scan(tc, index_conglomid, template.getRow(), template.getRow(), null, ScanController.NA, null, stop_key, ScanController.GE, 5, 11, T_QualifierTest.ORDER_FORWARD)) { ret_val = false; } //long col1[] = { 1, 3, 4, 4, 4, 5, 5, 5, 6, 7, 9}; //long col2[] = { 1, 1, 2, 4, 6, 2, 4, 6, 1, 1, 1}; //long col3[] = {11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21}; // +------------------------------------------------------------------+ // |pred |start|key|stop |key|rows returned|rows locked | // | |value|op |value|op | |(serialized) | // +-----------------+------+--+-----+--+--------------+--------------+ // |x >= 5 and x <= 7|{5}, |GE|{7} |GT|{5,2} .. {7,1}|{4,6} .. {7,1}| // +------------------------------------------------------------------+ REPORT("scan (x >= 5 and x <= 7)"); ((SQLLongint)start_key[0]).setValue(5); ((SQLLongint)stop_key[0]).setValue(7); if (!T_QualifierTest.t_scan(tc, index_conglomid, template.getRow(), template.getRow(), start_key, ScanController.GE, null, stop_key, ScanController.GT, 5, 16, T_QualifierTest.ORDER_FORWARD)) { ret_val = false; } // +------------------------------------------------------------------+ // |pred |start|key|stop |key|rows returned|rows locked | // | |value|op |value|op | |(serialized) | // +-----------------+------+--+-----+--+--------------+--------------+
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -