📄 t_accessfactory.java
字号:
} REPORT(("return from full row scan heap.getScanInfo() = " + prop)); if (Integer.parseInt(prop.getProperty( MessageService.getTextMessage(SQLState.STORE_RTS_NUM_PAGES_VISITED))) != 1) { throw T_Fail.testFailMsg( "(scanInfo) wrong numPagesVisited. Expected 1, got " + Integer.parseInt(prop.getProperty( MessageService.getTextMessage( SQLState.STORE_RTS_NUM_PAGES_VISITED)))); } if (Integer.parseInt(prop.getProperty( MessageService.getTextMessage(SQLState.STORE_RTS_NUM_ROWS_VISITED))) != 2) { throw T_Fail.testFailMsg( "(scanInfo) wrong numRowsVisited. Expected 2, got " + Integer.parseInt(prop.getProperty( MessageService.getTextMessage( SQLState.STORE_RTS_NUM_ROWS_VISITED)))); } if (Integer.parseInt(prop.getProperty( MessageService.getTextMessage(SQLState.STORE_RTS_NUM_ROWS_QUALIFIED))) != 1) { throw T_Fail.testFailMsg( "(scanInfo) wrong numRowsQualified. Expected 1, got " + Integer.parseInt(prop.getProperty( MessageService.getTextMessage( SQLState.STORE_RTS_NUM_ROWS_QUALIFIED)))); } // Try a partial Row scan // only get the 2nd column. FormatableBitSet validColumns = new FormatableBitSet(3); validColumns.set(1); scan = tc.openScan( conglomid, false, // don't hold TransactionController.OPENMODE_FORUPDATE, // for update TransactionController.MODE_RECORD, TransactionController.ISOLATION_SERIALIZABLE, validColumns, // only get the second column null, // start position - first row in conglomerate 0, // unused if start position is null. null, // qualifier - accept all rows null, // stop position - last row in conglomerate 0); // unused if stop position is null. if (scan.isTableLocked()) { throw T_Fail.testFailMsg( "(scanInfo) table should be row locked."); } scan_info = scan.getScanInfo(); prop = scan_info.getAllScanInfo(null); REPORT(("return from partial scan heap.getScanInfo() = " + prop)); // RESOLVE - should test the btree one also. REPORT("(scanInfo) finishing"); return true; } /** * Test partial scans. * <p> * * @return true if the test succeeded. * * @param tc The transaction controller to use in the test. * * @exception StandardException Standard exception policy. * @exception T_Fail Unexpected behaviour from the API **/ protected boolean partialScan( TransactionController tc) throws StandardException, T_Fail { int key_value; REPORT("(partialScan) starting"); // Create a heap conglomerate. T_AccessRow template_row = new T_AccessRow(2); long conglomid = tc.createConglomerate( "heap", // create a heap conglomerate template_row.getRowArray(), // 1 column template. null, // column sort order not required for heap null, // default properties TransactionController.IS_DEFAULT); // not temporary // Open the conglomerate. ConglomerateController cc = tc.openConglomerate( conglomid, false, TransactionController.OPENMODE_FORUPDATE, TransactionController.MODE_RECORD, TransactionController.ISOLATION_SERIALIZABLE); // Create a 1 column row. int column = 1. T_AccessRow r1 = new T_AccessRow(2); SQLInteger c1 = new SQLInteger(1); SQLInteger c2 = new SQLInteger(100); r1.setCol(0, c1); r1.setCol(1, c2); // Get a location template RowLocation rowloc1 = cc.newRowLocationTemplate(); // Insert the row and remember its location. cc.insertAndFetchLocation(r1.getRowArray(), rowloc1); // create another 2 column row. int column = 2. // Get a location template r1.setCol(0, new SQLInteger(2)); r1.setCol(1, new SQLInteger(200)); RowLocation rowloc2 = cc.newRowLocationTemplate(); // Insert the row and remember its location. cc.insertAndFetchLocation(r1.getRowArray(), rowloc2); cc.delete(rowloc2); tc.commit(); // Try a partial Row scan with no columns. // only get the 2nd column. FormatableBitSet validColumns = new FormatableBitSet(); ScanController scan = tc.openScan( conglomid, false, // don't hold TransactionController.OPENMODE_FORUPDATE, // for update TransactionController.MODE_RECORD, TransactionController.ISOLATION_SERIALIZABLE, validColumns, // only get the second column null, // start position - first row in conglomerate 0, // unused if start position is null. null, // qualifier - accept all rows null, // stop position - last row in conglomerate 0); // unused if stop position is null. // should see one row. if (!scan.next()) { throw T_Fail.testFailMsg("(partialScan) did not see first row."); } if (scan.next()) { throw T_Fail.testFailMsg("(partialScan) saw more than one row."); } // RESOLVE - should test the btree one also. REPORT("(partialScan) finishing"); return true; } // Simple insert into heap performance test protected boolean insert_bench(TransactionController tc) throws StandardException, T_Fail { ConglomerateController cc = null; ScanController scan = null; long conglomid = -1; long before, after; // Create a row. T_AccessRow r1 = new T_AccessRow(1); long iter = 100; for (int numcols = 1; numcols < 101; numcols *= 10) { // Create a heap conglomerate. conglomid = tc.createConglomerate( "heap", // create a heap conglomerate new T_AccessRow(numcols).getRowArray(), // 1 SQLInteger() column template. null, // column sort order not required for heap null, // default properties TransactionController.IS_DEFAULT); // not temporary tc.commit(); // Open the conglomerate. cc = tc.openConglomerate( conglomid, false, TransactionController.OPENMODE_FORUPDATE, TransactionController.MODE_RECORD, TransactionController.ISOLATION_SERIALIZABLE); for (int i = 0; i < numcols; i++) { r1.setCol(i, new SQLInteger(numcols)); } // time before before = System.currentTimeMillis(); for (int i = 0; i < iter; i++) { if (cc.insert(r1.getRowArray()) != 0) throw T_Fail.testFailMsg("(insert_bench) insert failed "); } // time after after = System.currentTimeMillis(); REPORT( "insert " + iter + " rows of " + numcols + " integer cols = " + (after - before) + " milliseconds.\n"); // time before before = System.currentTimeMillis(); for (int i = 0; i < iter; i++) { if (cc.insert(r1.getRowArray()) != 0) throw T_Fail.testFailMsg("(insert_bench) insert failed "); } // time after after = System.currentTimeMillis(); REPORT( "second insert " + iter + " rows of " + numcols + " integer cols = " + (after - before) + " milliseconds.\n"); // Open a scan on the conglomerate. before = System.currentTimeMillis(); scan = tc.openScan( conglomid, false, // don't hold 0, // not for update TransactionController.MODE_RECORD, TransactionController.ISOLATION_SERIALIZABLE, (FormatableBitSet) null, // all columns, all as objects null, // start position - first row in conglomerate 0, // unused if start position is null. null, // qualifier - accept all rows null, // stop position - last row in conglomerate 0); // unused if stop position is null. // time before before = System.currentTimeMillis(); // Iterate through and check that the rows are still there. while (scan.next()) { scan.fetch(r1.getRowArray()); } // time after after = System.currentTimeMillis(); REPORT( "scan " + (2 * iter) + " rows of " + numcols + " integer cols = " + (after - before) + " milliseconds.\n"); // Close the conglomerate. cc.close(); tc.commit(); } return(true); } /** * Test the access level SortCost interface. * <p> * * @return true if the test succeeded. * * @param tc The transaction controller to use in the test. * * @exception StandardException Standard exception policy. * @exception T_Fail Unexpected behaviour from the API **/ protected boolean sortCost( TransactionController tc) throws StandardException, T_Fail { int key_value; REPORT("(sortCost) starting"); // Create a heap conglomerate. T_AccessRow template_row = new T_AccessRow(2); long conglomid = tc.createConglomerate( "heap", // create a heap conglomerate template_row.getRowArray(), // 1 column template. null, // column sort order not required for heap null, // default properties TransactionController.IS_DEFAULT); // not temporary // Open the conglomerate. ConglomerateController cc = tc.openConglomerate( conglomid, false, TransactionController.OPENMODE_FORUPDATE, TransactionController.MODE_RECORD, TransactionController.ISOLATION_SERIALIZABLE); // Create a 2 column row. T_AccessRow r1 = new T_AccessRow(2); SQLInteger c1 = new SQLInteger(1); SQLInteger c2 = new SQLInteger(100); r1.setCol(0, c1); r1.setCol(1, c2); // Get a location template RowLocation rowloc1 = cc.newRowLocationTemplate(); // Insert the row and remember its location. cc.insertAndFetchLocation(r1.getRowArray(), rowloc1); cc.close(); tc.commit(); // flush the cache to get the row count updated. flush_cache(); // Test 1 - Just call for various types of sorts. Not sure how // to test the validity. SortCostController scc = tc.openSortCostController(null); double estimated_cost = scc.getSortCost( template_row.getRowArray(), null, false, 10000, 100, 100); if (estimated_cost <= 0) { throw T_Fail.testFailMsg( "(storeCost) estimated sort cost :" + estimated_cost); } REPORT("(sortCost) finishing"); return true; } /** * Test the access level StoreCost interface. * <p> * * @return true if the test succeeded. * * @param tc The transaction controller to use in the test. * * @exception StandardException Standard exception policy. * @exception T_Fail Unexpected behaviour from the API **/ protected boolean storeCost( TransactionController tc) throws StandardException, T_Fail { int key_value; REPORT("(storeCost) starting"); // Create a heap conglomerate. T_AccessRow template_row = new T_AccessRow(2); long conglomid = tc.createConglomerate( "heap", // create a heap conglomerate template_row.getRowArray(), // 1 column template. null, // column sort order not required for heap null, // default properties TransactionController.IS_DEFAULT); // not temporary // Open the conglomerate. ConglomerateController cc = tc.openConglomerate( conglomid, false, TransactionController.OPENMODE_FORUPDATE,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -