⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 t_b2i.java

📁 derby database source code.good for you.
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
    {        REPORT("Starting t_004");        T_CreateConglomRet create_ret = new T_CreateConglomRet();        createCongloms(tc, 2, false, false, 0, create_ret);        Properties properties =             createProperties(                null,       // no current properties list                 false,      // don't allow duplicates                4,          // 3 columns in index row                4,          // non-unique index                true,       // maintain parent links                create_ret.base_conglomid,        // fake base conglom for now                3);         // row loc in last column        T_QualifierTest q_test =             new T_QualifierTest(                "BTREE",    				    // create a btree secondary                properties,                     // properties                false,                          // not temporary                out,                T_QualifierTest.ORDER_FORWARD); // ordered         boolean test_result = q_test.t_testqual(tc);        REPORT("Ending t_004");        return(test_result);    }    /**     * Test Branch splits - number of rows necessary to cause splits is raw     * store implementation dependant (currently 5 rows per page in in-memory     * implementation).     *	 * @exception  StandardException  Standard exception policy.	 * @exception  T_Fail  Throws T_Fail on any test failure.     */    protected boolean t_005(TransactionController tc)        throws StandardException, T_Fail    {        boolean     ret_val = true;        REPORT("Starting t_005");        T_CreateConglomRet create_ret = new T_CreateConglomRet();        createCongloms(tc, 2, false, false, 0, create_ret);		// Open the base conglomerate.		ConglomerateController base_cc =	            tc.openConglomerate(                create_ret.base_conglomid,                false,                TransactionController.OPENMODE_FORUPDATE,                TransactionController.MODE_RECORD,                TransactionController.ISOLATION_SERIALIZABLE);		// Open the index conglomerate.		ConglomerateController index_cc =	            tc.openConglomerate(                create_ret.index_conglomid,                false,                TransactionController.OPENMODE_FORUPDATE,                TransactionController.MODE_RECORD,                TransactionController.ISOLATION_SERIALIZABLE);		// Create a row.		T_SecondaryIndexRow index_row = new T_SecondaryIndexRow();        RowLocation             rowloc    = base_cc.newRowLocationTemplate();        DataValueDescriptor[]   base_row  = TemplateRow.newU8Row(2);        index_row.init(base_row, rowloc, 3);         // insert them in reverse order just to make sure btree is sorting them        for (int i = 200; i >= 0; i -= 4)        {            ((SQLLongint)base_row[0]).setValue(1);            ((SQLLongint)base_row[1]).setValue(i);            base_cc.insertAndFetchLocation(base_row, rowloc);            if (index_cc.insert(index_row.getRow()) != 0)                throw T_Fail.testFailMsg("insert failed");        }        for (int i = 199; i >= 0; i -= 4)        {            ((SQLLongint)base_row[0]).setValue(1);            ((SQLLongint)base_row[1]).setValue(i);            base_cc.insertAndFetchLocation(base_row, rowloc);            if (index_cc.insert(index_row.getRow()) != 0)                throw T_Fail.testFailMsg("insert failed");        }        index_cc.checkConsistency();		// Close the conglomerate.		index_cc.close();        tc.commit();        // Search for each of the keys and delete them one at a time.        DataValueDescriptor[] delete_key = TemplateRow.newU8Row(2);        for (int i = 200; i >= 0; i -= 4)        {            ((SQLLongint)delete_key[0]).setValue(1);            ((SQLLongint)delete_key[1]).setValue(i);            if (!t_delete(                tc, create_ret.index_conglomid, delete_key, index_row.getRow()))            {                ret_val = false;            }        }        for (int i = 199; i >= 0; i -= 4)        {            ((SQLLongint)delete_key[0]).setValue(1);            ((SQLLongint)delete_key[1]).setValue(i);            if (!t_delete(                tc, create_ret.index_conglomid, delete_key, index_row.getRow()))            {                ret_val = false;            }        }        tc.commit();		// Open the base conglomerate.		base_cc =             tc.openConglomerate(                create_ret.base_conglomid,                false,                TransactionController.OPENMODE_FORUPDATE,                TransactionController.MODE_RECORD,                TransactionController.ISOLATION_SERIALIZABLE);		// Open the conglomerate.		index_cc =             tc.openConglomerate(                create_ret.index_conglomid,                false,                TransactionController.OPENMODE_FORUPDATE,                TransactionController.MODE_RECORD,                TransactionController.ISOLATION_SERIALIZABLE);        // flush and empty cache to make sure rereading stuff works.        RawStoreFactory rawstore =             (RawStoreFactory) Monitor.findServiceModule(                this.store_module, RawStoreFactory.MODULE);        rawstore.idle();        // now make sure that additional splits don't cause delete bits to         // be enabled (one early bug did so).                for (int i = 200; i >= 0; i -= 3)        {            ((SQLLongint)base_row[0]).setValue(1);            ((SQLLongint)base_row[1]).setValue(i);            base_cc.insertAndFetchLocation(base_row, rowloc);            if (index_cc.insert(index_row.getRow()) != 0)                throw T_Fail.testFailMsg("insert failed");        }        for (int i = 200; i >= 0; i -= 3)        {            ((SQLLongint)delete_key[0]).setValue(1);            ((SQLLongint)delete_key[1]).setValue(i);            if (!t_delete(                tc, create_ret.index_conglomid, delete_key, index_row.getRow()))            {                ret_val = false;            }        }        // 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_005: there are still rows in table.");        index_cc.checkConsistency();        for (int i = 600; i >= 400; i -= 3)        {            ((SQLLongint)base_row[0]).setValue(1);            ((SQLLongint)base_row[1]).setValue(i);            base_cc.insertAndFetchLocation(base_row, rowloc);            if (index_cc.insert(index_row.getRow()) != 0)                throw T_Fail.testFailMsg("insert failed");        }        index_cc.checkConsistency();        tc.abort();        // index check - there should be no records left.        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_005: there are still rows in table.");        REPORT("Ending t_005");        return(ret_val);    }    /**     * Test unimplemented interfaces.       *     * The following ScanController interfaces are not supported by the     * btree implementation, because row locations are not returned outside     * the interface.  At some point we may package a key as a row location     * but that does not really give any more functionality than using scan     * to find your key:     *     ScanController.fetchLocation()     *     ScanController.newRowLocationTemplate()     *     ScanController.replace()     *     ConglomerateController.delete()     *     ConglomerateController.fetch()	 *     ConglomerateController.insertAndFetchLocation()	 *     ConglomerateController.newRowLocationTemplate()     *     ConglomerateController.replace()     *	 * @exception  StandardException  Standard exception policy.	 * @exception  T_Fail  Throws T_Fail on any test failure.     */    protected boolean t_006(TransactionController tc)        throws StandardException, T_Fail    {        REPORT("Starting t_006");        T_CreateConglomRet create_ret = new T_CreateConglomRet();        createCongloms(tc, 2, false, false, 0, create_ret);		// Open the base conglomerate.		ConglomerateController base_cc =	            tc.openConglomerate(                create_ret.base_conglomid,                false,                TransactionController.OPENMODE_FORUPDATE,                TransactionController.MODE_RECORD,                TransactionController.ISOLATION_SERIALIZABLE);		// Open the index conglomerate.		ConglomerateController index_cc =	            tc.openConglomerate(                create_ret.index_conglomid,                false,                TransactionController.OPENMODE_FORUPDATE,                TransactionController.MODE_RECORD,                TransactionController.ISOLATION_SERIALIZABLE);		// Create a base row template.        DataValueDescriptor[]   base_row    = TemplateRow.newU8Row(2);        RowLocation             base_rowloc = base_cc.newRowLocationTemplate();        T_SecondaryIndexRow index_row_from_base_row = new T_SecondaryIndexRow();        index_row_from_base_row.init(base_row, base_rowloc, 3);        ((SQLLongint)base_row[0]).setValue(1);		// Create a row.		T_SecondaryIndexRow index_row = new T_SecondaryIndexRow();        index_row.init(TemplateRow.newU8Row(2),                         base_cc.newRowLocationTemplate(), 3);        // test: make sure scan position is right after inserts before scan        //       no split case.  In this case the slot position of the current        //       position should change, but the code will keep a record handle        //       and not need to reposition by key.        // before keys: 1000, 3000        // last key gotten froms scan : 0        // insert keys:1-900        // next key from scan should be: 5        // insert 1000        ((SQLLongint)base_row[1]).setValue(1000);        base_cc.insertAndFetchLocation(base_row, base_rowloc);        if (index_cc.insert(index_row_from_base_row.getRow()) != 0)        {			throw T_Fail.testFailMsg("insert failed");        }        // try each of the unsupported interfaces:        try        {            index_cc.delete(null);            return(FAIL("t_006: ConglomerateController.delete() succeeded."));        }        catch (StandardException e)        {        }        try        {            if (!index_cc.fetch(                    null, RowUtil.EMPTY_ROW, (FormatableBitSet) null))            {                return(FAIL("t_006: ConglomerateController.fetch() bad ret."));            }            return(FAIL("t_006: ConglomerateController.fetch() succeeded."));        }        catch (StandardException e)        {        }        try        {            index_cc.insertAndFetchLocation((DataValueDescriptor[]) null, null);            return(FAIL(                "t_006: ConglomerateController.insertAndFetchLocation() succeeded."));        }        catch (StandardException e)        {        }        try        {            RowLocation rowloc = index_cc.newRowLocationTemplate();            return(FAIL(                "t_006: ConglomerateController.newRowLocationTemplate() succeeded."));        }        catch (StandardException e)        {        }        try        {            index_cc.replace(null, null, null);            return(FAIL("t_006: ConglomerateController.replace() succeeded."));        }        catch (StandardException e)        {        }        index_cc.close();        // open a new scan        ScanController scan =             tc.openScan(create_ret.index_conglomid, false,                         0,                        TransactionController.MODE_RECORD,                        TransactionController.ISOLATION_SERIALIZABLE,						(For

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -