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

📄 t_b2i.java

📁 derby database source code.good for you.
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
/*   Derby - Class org.apache.derbyTesting.unitTests.store.T_b2i   Copyright 1997, 2005 The Apache Software Foundation or its licensors, as applicable.   Licensed under the Apache License, Version 2.0 (the "License");   you may not use this file except in compliance with the License.   You may obtain a copy of the License at      http://www.apache.org/licenses/LICENSE-2.0   Unless required by applicable law or agreed to in writing, software   distributed under the License is distributed on an "AS IS" BASIS,   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   See the License for the specific language governing permissions and   limitations under the License. */package org.apache.derbyTesting.unitTests.store;// impl imports are the preferred way to create unit tests.import org.apache.derbyTesting.unitTests.harness.T_MultiIterations;import org.apache.derbyTesting.unitTests.harness.T_Fail;import org.apache.derby.impl.store.access.btree.index.*;import org.apache.derby.iapi.types.SQLLongint;import org.apache.derby.iapi.reference.Property;import org.apache.derby.iapi.reference.SQLState;import org.apache.derby.iapi.services.io.FormatableBitSet;import org.apache.derby.iapi.services.i18n.MessageService;import org.apache.derby.iapi.services.monitor.Monitor;import org.apache.derby.iapi.services.sanity.SanityManager;import org.apache.derby.iapi.services.stream.HeaderPrintWriter;import org.apache.derby.iapi.services.context.ContextService;import org.apache.derby.iapi.services.context.ContextManager;import org.apache.derby.iapi.services.io.FormatIdUtil;import org.apache.derby.iapi.error.StandardException;import org.apache.derby.iapi.store.access.conglomerate.TransactionManager;import org.apache.derby.iapi.store.access.AccessFactory;import org.apache.derby.iapi.store.access.ConglomerateController;import org.apache.derby.iapi.store.access.Qualifier;import org.apache.derby.iapi.types.RowLocation;import org.apache.derby.iapi.store.access.ScanController;import org.apache.derby.iapi.store.access.ScanInfo;import org.apache.derby.iapi.store.access.TransactionController;import org.apache.derby.iapi.store.access.RowUtil;import org.apache.derby.iapi.store.access.ColumnOrdering;import org.apache.derby.iapi.store.raw.ContainerHandle;import org.apache.derby.iapi.store.raw.LockingPolicy;import org.apache.derby.iapi.store.raw.RawStoreFactory;import org.apache.derby.iapi.types.DataValueDescriptor;import org.apache.derby.impl.store.access.btree.BTree;import org.apache.derby.impl.store.access.conglomerate.TemplateRow;import org.apache.derby.iapi.types.SQLChar;import java.util.Properties;public class T_b2i extends T_MultiIterations{     private static final String testService = "b2iTest";    private Object store_module = null;     private ContextService contextService = null;    /* Methods required by T_MultiIterations */    /**     * Routine one once per invocation of the test by the driver.     * <p>     * Do work that should only be done once, no matter how many times     * runTests() may be executed.     *	 * @exception  T_Fail  Thrown on any error.     **/    protected void setupTest()		throws T_Fail    {		// don't automatic boot this service if it gets left around		if (startParams == null) {			startParams = new Properties();		}		startParams.put(Property.NO_AUTO_BOOT, Boolean.TRUE.toString());		// remove the service directory to ensure a clean run		startParams.put(Property.DELETE_ON_CREATE, Boolean.TRUE.toString());		// see if we are testing encryption		startParams = T_Util.setEncryptionParam(startParams);		try {			store_module = Monitor.createPersistentService(				getModuleToTestProtocolName(), testService, startParams);						contextService = ContextService.getFactory();		} catch (StandardException mse) {			throw T_Fail.exceptionFail(mse);		}    }	/*	** Methods required by T_Generic	*/	public String getModuleToTestProtocolName() {		return AccessFactory.MODULE;	}    /**     * Driver routine for the btree secondary index tests.     * <p>     *	 * @exception  T_Fail  Throws T_Fail on any test failure.     **/	protected void runTestSet() throws T_Fail	{		AccessFactory store = null;		TransactionController tc = null;		boolean pass = false;        out.println("executing b2i test");        store = (AccessFactory) store_module;		if (store == null)        {			throw T_Fail.testFailMsg(                    getModuleToTestProtocolName() + " service not started.");		}		ContextManager cm1 = contextService.newContextManager();		contextService.setCurrentContextManager(cm1);		REPORT("(unitTestMain) Testing " + testService);		try {			tc = store.getTransaction(cm1);				pass = true;            if (                t_005(tc)   &&                t_001(tc)   &&                t_003(tc)   &&                t_004(tc)   &&                t_005(tc)   &&                t_006(tc)   &&                t_009(tc)   &&                t_010(tc)   &&                t_011(tc)   &&                t_012(tc)   &&                t_013(tc)   &&                t_014(tc)   &&				t_017(tc)   &&				t_018(tc)   &&				t_019(tc)   &&				t_020(tc)                   )                			{				pass = true;                if (SanityManager.DEBUG)                {                    pass = false;                    // The following tests depend on SanityManager functionality                    // so can not be run in an insane server.                    if (t_002(tc) &&                        t_007(tc) &&                        t_008(tc) &&                        t_015(tc) &&                        t_016(tc)                        )                        pass = true;                }			}			tc.commit();			tc.destroy();		}		catch (StandardException e)		{			String  msg = e.getMessage();			if (msg == null)				msg = e.getClass().getName();			REPORT(msg);            e.printStackTrace(out.getPrintWriter());            cm1.cleanupOnError(e);            pass = false;		}        catch (Throwable t)        {			String  msg = t.getMessage();			if (msg == null)				msg = t.getClass().getName();			REPORT(msg);            t.printStackTrace(out.getPrintWriter());            cm1.cleanupOnError(t);            pass = false;        }		finally {			contextService.resetCurrentContextManager(cm1);		}		if (!pass)			throw T_Fail.testFailMsg("");	}    /**     * Utility routine to create base table for tests.     * <p>     * A little utility routine to create base tables for tests.  Just     * here to make tests a little more readable.  It currently just      * creates a heap table with "num_cols" SQLLongint columns.     *	 * @return The identifier to be used to open the conglomerate later.     *     * @param num_cols the number of columns in the base table.     *	 * @exception  StandardException  Standard exception policy.     **/    void createCongloms(    TransactionController   tc,    int                     num_cols,    boolean                 unique,    boolean                 varying_first_col,    int                     max_btreerows_per_page,    T_CreateConglomRet        ret_val)		throws StandardException    {        T_SecondaryIndexRow index_row  = new T_SecondaryIndexRow();        DataValueDescriptor[] base_row = TemplateRow.newU8Row(num_cols);        if (varying_first_col)        {            SQLChar    string_col = new SQLChar();            base_row[0] = string_col;        }        long base_conglomid = 0;        // create the base table        base_conglomid =             tc.createConglomerate(                "heap",   // create a heap conglomerate                base_row, // base table template row                null, //column sort order - not required for heap                null,     // default properties                TransactionController.IS_DEFAULT);// not temporary        // Open the base table        ConglomerateController base_cc =             tc.openConglomerate(                base_conglomid,                 false,                TransactionController.OPENMODE_FORUPDATE,                TransactionController.MODE_RECORD,                TransactionController.ISOLATION_SERIALIZABLE);        // initialize the secondary index row - pointing it at base row        RowLocation base_rowloc = base_cc.newRowLocationTemplate();        index_row.init(base_row, base_rowloc, num_cols + 1);                // create the secondary index        Properties properties =             createProperties(                null,           // no current properties list                 false,          // don't allow duplicates                num_cols + 1,   // index on all base row cols + row location                (unique ? num_cols : num_cols + 1),   // non-unique index                true,           // maintain parent links                base_conglomid, // base conglomid                num_cols);      // row loc in last column        if (max_btreerows_per_page > 1)        {            if (BTree.PROPERTY_MAX_ROWS_PER_PAGE_PARAMETER != null)            {                properties.put(                    BTree.PROPERTY_MAX_ROWS_PER_PAGE_PARAMETER,                    String.valueOf(max_btreerows_per_page));            }        }        long index_conglomid =             tc.createConglomerate(                "BTREE",    	    // create a btree secondary                index_row.getRow(), // index row template				null, //column sort order - default                properties,         // properties                TransactionController.IS_DEFAULT); // not temporary        // return values to caller        ret_val.base_conglomid     = base_conglomid;        ret_val.index_conglomid    = index_conglomid;        // RESOLVE (mikem - 04/29/98 - why is following line commented out?        // ret_val.base_template_row  = TemplateRow.newU8Row(num_cols);        ret_val.index_template_row = index_row.getRow();        return;    }    protected static Properties createProperties(    Properties  input_properties,    boolean     input_allowduplicates,    int         input_nkeyfields,    int         input_nuniquecolumns,    boolean     input_maintainparentlinks,    long        input_baseconglomerateid,    int         input_rowlocationcolumn)        throws StandardException    {        Properties properties =             ((input_properties == null) ? new Properties() : input_properties);        properties.put(            "allowDuplicates",     String.valueOf(input_allowduplicates));        properties.put(            "nKeyFields",          String.valueOf(input_nkeyfields));        properties.put(            "nUniqueColumns",      String.valueOf(input_nuniquecolumns));        properties.put(            "maintainParentLinks", String.valueOf(input_maintainparentlinks));        properties.put(            "baseConglomerateId",  String.valueOf(input_baseconglomerateid));        properties.put(            "rowLocationColumn",   String.valueOf(input_rowlocationcolumn));        return(properties);    }    /**     * Test a single scan.     * 	 * @exception  StandardException  Standard exception policy.     */    protected boolean t_scan(    TransactionController   tc,    long                    conglomid,    DataValueDescriptor[]	template,    DataValueDescriptor[]	start_key, 

⌨️ 快捷键说明

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