Search in sources :

Example 86 with FormatableBitSet

use of org.apache.derby.iapi.services.io.FormatableBitSet in project derby by apache.

the class T_RawStoreFactory method P708.

/**
 *		Insert a single row with single or multiple portions.
 *		Update every other field with a long col
 *		rollback.
 *		The update each column back to a null and rollback
 *
 *		@exception T_Fail Unexpected behaviour from the API
 *		@exception StandardException Unexpected exception from the implementation
 */
protected void P708(long segment, boolean multiPortion) throws StandardException, T_Fail {
    Transaction t = t_util.t_startTransaction();
    long cid = t_util.t_addContainer(t, segment, 4096);
    ContainerHandle c = t_util.t_openContainer(t, segment, cid, true);
    Page page = t_util.t_getPage(c, ContainerHandle.FIRST_PAGE_NUMBER);
    t_util.t_checkEmptyPage(page);
    // row has 15 cols, each with 200 (ish) bytes (100 null chars)
    // thus we would expect at least 3 pages
    T_RawStoreRow row = new T_RawStoreRow(15);
    for (int i = 0; i < 15; i++) {
        row.setColumn(i, multiPortion ? 100 : 10, "XX" + i + "YY");
    }
    RecordHandle rh = t_util.t_insertAtSlot(page, 0, row, (byte) (Page.INSERT_INITIAL | Page.INSERT_OVERFLOW));
    t_util.t_checkFetch(page, rh, row);
    page.unlatch();
    t_util.t_commit(t);
    c = t_util.t_openContainer(t, segment, cid, true);
    page = t_util.t_getPage(c, ContainerHandle.FIRST_PAGE_NUMBER);
    // update  every other column to be a long column
    for (int i = 0; i < 15; i++) {
        if ((i % 2) == 0) {
            continue;
        }
        REPORT("P708 : multiPortion " + multiPortion + " - col " + i);
        FormatableBitSet colList = new FormatableBitSet(i + 1);
        colList.set(i);
        T_RawStoreRow rowU = new T_RawStoreRow(i + 1);
        // longer than 4096 page length
        rowU.setColumn(i, 3000, "WW" + i + "UU");
        int slot = page.getSlotNumber(rh);
        page.updateAtSlot(slot, rowU.getRow(), colList);
    }
    t_util.t_abort(t);
    c = t_util.t_openContainer(t, segment, cid, false);
    page = t_util.t_getPage(c, ContainerHandle.FIRST_PAGE_NUMBER);
    t_util.t_checkFetch(page, rh, row);
    page.unlatch();
    if (segment != ContainerHandle.TEMPORARY_SEGMENT) {
        // cleanup
        t_util.t_dropContainer(t, segment, cid);
    }
    t_util.t_commit(t);
    t.close();
    PASS("P708: multiPortion " + multiPortion + " segment = " + segment);
}
Also used : RawTransaction(org.apache.derby.iapi.store.raw.xact.RawTransaction) FormatableBitSet(org.apache.derby.iapi.services.io.FormatableBitSet) RawContainerHandle(org.apache.derby.iapi.store.raw.data.RawContainerHandle)

Example 87 with FormatableBitSet

use of org.apache.derby.iapi.services.io.FormatableBitSet in project derby by apache.

the class T_RawStoreFactory method P706.

/**
 *		Insert a single row with single or multiple portions.
 *		Update every other field with a long col
 *		The update each column back to a null
 *
 *		@exception T_Fail Unexpected behaviour from the API
 *		@exception StandardException Unexpected exception from the implementation
 */
protected void P706(long segment, boolean multiPortion) throws StandardException, T_Fail {
    Transaction t = t_util.t_startTransaction();
    long cid = t_util.t_addContainer(t, segment, 4096);
    ContainerHandle c = t_util.t_openContainer(t, segment, cid, true);
    Page page = t_util.t_getPage(c, ContainerHandle.FIRST_PAGE_NUMBER);
    t_util.t_checkEmptyPage(page);
    // row has 15 cols, each with 200 (ish) bytes (100 null chars)
    // thus we would expect at least 3 pages
    T_RawStoreRow row = new T_RawStoreRow(15);
    for (int i = 0; i < 15; i++) {
        row.setColumn(i, multiPortion ? 100 : 10, "XX" + i + "YY");
    }
    RecordHandle rh = t_util.t_insertAtSlot(page, 0, row, (byte) (Page.INSERT_INITIAL | Page.INSERT_OVERFLOW));
    t_util.t_checkFetch(page, rh, row);
    page.unlatch();
    page = t_util.t_getPage(c, ContainerHandle.FIRST_PAGE_NUMBER);
    // update  every other column to be a long column
    for (int i = 0; i < 15; i++) {
        if ((i % 2) == 0) {
            continue;
        }
        REPORT("P706 : multiPortion " + multiPortion + " - col " + i);
        FormatableBitSet colList = new FormatableBitSet(i + 1);
        colList.set(i);
        T_RawStoreRow rowU = new T_RawStoreRow(i + 1);
        // longer than 4096 page length
        rowU.setColumn(i, 3000, "WW" + i + "UU");
        int slot = page.getSlotNumber(rh);
        page.updateAtSlot(slot, rowU.getRow(), colList);
        page.unlatch();
        row.setColumn(i, 3000, "WW" + i + "UU");
        page = t_util.t_getPage(c, ContainerHandle.FIRST_PAGE_NUMBER);
        t_util.t_checkFetch(page, rh, row);
    }
    t_util.t_commit(t);
    // update  every column to a null
    c = t_util.t_openContainer(t, segment, cid, true);
    page = t_util.t_getPage(c, ContainerHandle.FIRST_PAGE_NUMBER);
    for (int i = 0; i < 15; i++) {
        REPORT("P706 : update to null " + multiPortion + " - col " + i);
        FormatableBitSet colList = new FormatableBitSet(i + 1);
        colList.set(i);
        T_RawStoreRow rowU = new T_RawStoreRow(i + 1);
        rowU.setColumn(i, (String) null);
        int slot = page.getSlotNumber(rh);
        page.updateAtSlot(slot, rowU.getRow(), colList);
        page.unlatch();
        row.setColumn(i, (String) null);
        page = t_util.t_getPage(c, ContainerHandle.FIRST_PAGE_NUMBER);
        t_util.t_checkFetch(page, rh, row);
    }
    page.unlatch();
    if (segment != ContainerHandle.TEMPORARY_SEGMENT) {
        // cleanup
        t_util.t_dropContainer(t, segment, cid);
    }
    t_util.t_commit(t);
    t.close();
    PASS("P706: multiPortion " + multiPortion + " segment = " + segment);
}
Also used : RawTransaction(org.apache.derby.iapi.store.raw.xact.RawTransaction) FormatableBitSet(org.apache.derby.iapi.services.io.FormatableBitSet) RawContainerHandle(org.apache.derby.iapi.store.raw.data.RawContainerHandle)

Example 88 with FormatableBitSet

use of org.apache.derby.iapi.services.io.FormatableBitSet in project derby by apache.

the class T_RawStoreFactory method P703.

/**
 *		Simple set of partial row updates on a singel page with
 *		shrinking and expanding columns.
 *
 *		@exception T_Fail Unexpected behaviour from the API
 *		@exception StandardException Unexpected exception from the implementation
 */
protected void P703(long segment) throws StandardException, T_Fail {
    Transaction t = t_util.t_startTransaction();
    long cid = t_util.t_addContainer(t, segment, 4096);
    ContainerHandle c = t_util.t_openContainer(t, segment, cid, true);
    Page page = t_util.t_getPage(c, ContainerHandle.FIRST_PAGE_NUMBER);
    t_util.t_checkEmptyPage(page);
    REPORT("P703 - start ");
    T_RawStoreRow row = new T_RawStoreRow(2);
    row.setColumn(0, REC_001);
    row.setColumn(1, REC_002);
    RecordHandle rh = t_util.t_insertAtSlot(page, 0, row, (byte) (Page.INSERT_INITIAL | Page.INSERT_OVERFLOW));
    t_util.t_checkFetch(page, rh, row);
    REPORT("P703 - insert Ok ");
    page.unlatch();
    page = t_util.t_getPage(c, ContainerHandle.FIRST_PAGE_NUMBER);
    // Perform 10 tests
    // 1  update col0 to grow
    // 2  update col1 to grow
    // 3  update col0 to shrink
    // 4  update col1 to shrink
    // 5  update col0 to null
    // 6  update col1 to null
    // 7  update col0 to non-null
    // 8  update col1 to non-null
    // 9  update no columns
    // 10 update both cols
    P703Helper(page, rh, 0, REC_006, REC_002);
    REPORT("P703 - case 1 passed");
    P703Helper(page, rh, 1, REC_007, REC_006);
    REPORT("P703 - case 2 passed");
    P703Helper(page, rh, 0, REC_003, REC_007);
    REPORT("P703 - case 3 passed");
    P703Helper(page, rh, 1, REC_004, REC_003);
    REPORT("P703 - case 4 passed");
    P703Helper(page, rh, 0, null, REC_004);
    REPORT("P703 - case 5 passed");
    P703Helper(page, rh, 1, null, null);
    REPORT("P703 - case 6 passed");
    P703Helper(page, rh, 0, REC_002, null);
    REPORT("P703 - case 7 passed");
    P703Helper(page, rh, 1, REC_001, REC_002);
    REPORT("P703 - case 8 passed");
    P703Helper(page, rh, -1, REC_002, REC_001);
    REPORT("P703 - case 9 passed");
    FormatableBitSet colList = new FormatableBitSet(2);
    colList.set(0);
    colList.set(1);
    row.setColumn(0, REC_004);
    row.setColumn(1, REC_003);
    int slot = page.getSlotNumber(rh);
    page.updateAtSlot(slot, row.getRow(), colList);
    t_util.t_checkFetch(page, rh, row);
    REPORT("P703 - case 10 passed");
    page.unlatch();
    if (segment != ContainerHandle.TEMPORARY_SEGMENT) {
        // cleanup
        t_util.t_dropContainer(t, segment, cid);
    }
    t.commit();
    t.close();
    PASS("P703: segment = " + segment);
}
Also used : RawTransaction(org.apache.derby.iapi.store.raw.xact.RawTransaction) FormatableBitSet(org.apache.derby.iapi.services.io.FormatableBitSet) RawContainerHandle(org.apache.derby.iapi.store.raw.data.RawContainerHandle)

Example 89 with FormatableBitSet

use of org.apache.derby.iapi.services.io.FormatableBitSet in project derby by apache.

the class T_AccessFactory method partialScan.

/**
 * 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(// create a heap conglomerate
    "heap", // 1 column template.
    template_row.getRowArray(), // column sort order not required for heap
    null, // default collation
    null, // default properties
    null, // not temporary
    TransactionController.IS_DEFAULT);
    // 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, // don't hold
    false, // for update
    TransactionController.OPENMODE_FORUPDATE, TransactionController.MODE_RECORD, TransactionController.ISOLATION_SERIALIZABLE, // only get the second column
    validColumns, // start position - first row in conglomerate
    null, // unused if start position is null.
    0, // qualifier - accept all rows
    null, // stop position - last row in conglomerate
    null, // unused if stop position is null.
    0);
    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;
}
Also used : FormatableBitSet(org.apache.derby.iapi.services.io.FormatableBitSet) RowLocation(org.apache.derby.iapi.types.RowLocation) SQLLongint(org.apache.derby.iapi.types.SQLLongint) SQLInteger(org.apache.derby.iapi.types.SQLInteger)

Example 90 with FormatableBitSet

use of org.apache.derby.iapi.services.io.FormatableBitSet in project derby by apache.

the class T_AccessFactory method scanInfo.

/**
 * Test the access level ScanInfo 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 scanInfo(TransactionController tc) throws StandardException, T_Fail {
    int key_value;
    REPORT("(scanInfo) starting");
    // Create a heap conglomerate.
    T_AccessRow template_row = new T_AccessRow(2);
    long conglomid = tc.createConglomerate(// create a heap conglomerate
    "heap", // 1 column template.
    template_row.getRowArray(), // column sort order not required for heap
    null, // default collation
    null, // default properties
    null, // not temporary
    TransactionController.IS_DEFAULT);
    // 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);
    if (tc.isPristine() || tc.isIdle()) {
        throw T_Fail.testFailMsg("(scanInfo) bad xact state after update xact.");
    }
    tc.commit();
    ScanController scan = tc.openScan(conglomid, // don't hold
    false, // for read
    0, TransactionController.MODE_TABLE, TransactionController.ISOLATION_SERIALIZABLE, // all columns, all as objects
    (FormatableBitSet) null, // start position - first row in conglomerate
    null, // unused if start position is null.
    0, // qualifier - accept all rows
    null, // stop position - last row in conglomerate
    null, // unused if stop position is null.
    0);
    if (!scan.isTableLocked()) {
        throw T_Fail.testFailMsg("(scanInfo) table should be table locked.");
    }
    while (scan.next()) {
        scan.fetch(r1.getRowArray());
    }
    ScanInfo scan_info = scan.getScanInfo();
    Properties prop = scan_info.getAllScanInfo(null);
    if (!tc.isPristine() || tc.isIdle()) {
        throw T_Fail.testFailMsg("(scanInfo) bad xact state after update xact.");
    }
    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, // don't hold
    false, // for update
    TransactionController.OPENMODE_FORUPDATE, TransactionController.MODE_RECORD, TransactionController.ISOLATION_SERIALIZABLE, // only get the second column
    validColumns, // start position - first row in conglomerate
    null, // unused if start position is null.
    0, // qualifier - accept all rows
    null, // stop position - last row in conglomerate
    null, // unused if stop position is null.
    0);
    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;
}
Also used : FormatableBitSet(org.apache.derby.iapi.services.io.FormatableBitSet) Properties(java.util.Properties) RowLocation(org.apache.derby.iapi.types.RowLocation) SQLLongint(org.apache.derby.iapi.types.SQLLongint) SQLInteger(org.apache.derby.iapi.types.SQLInteger)

Aggregations

FormatableBitSet (org.apache.derby.iapi.services.io.FormatableBitSet)146 DataValueDescriptor (org.apache.derby.iapi.types.DataValueDescriptor)36 RowLocation (org.apache.derby.iapi.types.RowLocation)32 SQLLongint (org.apache.derby.iapi.types.SQLLongint)25 ScanController (org.apache.derby.iapi.store.access.ScanController)24 ExecRow (org.apache.derby.iapi.sql.execute.ExecRow)23 ConglomerateController (org.apache.derby.iapi.store.access.ConglomerateController)18 StandardException (org.apache.derby.shared.common.error.StandardException)17 RawTransaction (org.apache.derby.iapi.store.raw.xact.RawTransaction)15 RawContainerHandle (org.apache.derby.iapi.store.raw.data.RawContainerHandle)13 TransactionController (org.apache.derby.iapi.store.access.TransactionController)12 ConglomerateDescriptor (org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor)11 SQLInteger (org.apache.derby.iapi.types.SQLInteger)11 UUID (org.apache.derby.catalog.UUID)10 ExecIndexRow (org.apache.derby.iapi.sql.execute.ExecIndexRow)10 ConstraintDescriptor (org.apache.derby.iapi.sql.dictionary.ConstraintDescriptor)9 DataDictionary (org.apache.derby.iapi.sql.dictionary.DataDictionary)7 SQLChar (org.apache.derby.iapi.types.SQLChar)7 Properties (java.util.Properties)6 ContextManager (org.apache.derby.iapi.services.context.ContextManager)6