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

📄 tabinfoimpl.java

📁 derby database source code.good for you.
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
/*   Derby - Class org.apache.derby.impl.sql.catalog.TabInfoImpl   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.derby.impl.sql.catalog;import org.apache.derby.iapi.services.io.FormatableBitSet;import org.apache.derby.iapi.services.context.ContextService;import org.apache.derby.iapi.services.sanity.SanityManager;import org.apache.derby.iapi.services.io.StreamStorable;import org.apache.derby.iapi.error.StandardException;import org.apache.derby.iapi.sql.conn.LanguageConnectionContext;import org.apache.derby.iapi.sql.dictionary.CatalogRowFactory;import org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor;import org.apache.derby.iapi.sql.dictionary.IndexRowGenerator;import org.apache.derby.iapi.sql.dictionary.TabInfo;import org.apache.derby.iapi.sql.execute.ExecIndexRow;import org.apache.derby.iapi.sql.execute.ExecRow;import org.apache.derby.iapi.sql.execute.ExecutionContext;import org.apache.derby.iapi.sql.execute.ExecutionFactory;import org.apache.derby.iapi.sql.execute.RowChanger;import org.apache.derby.iapi.sql.execute.TupleFilter;import org.apache.derby.iapi.sql.Activation;import org.apache.derby.iapi.store.access.ConglomerateController;import org.apache.derby.iapi.store.access.DynamicCompiledOpenConglomInfo;import org.apache.derby.iapi.store.access.Qualifier;import org.apache.derby.iapi.store.access.ScanController;import org.apache.derby.iapi.store.access.StaticCompiledOpenConglomInfo;import org.apache.derby.iapi.store.access.TransactionController;import org.apache.derby.iapi.types.DataValueDescriptor;import org.apache.derby.iapi.types.DataValueFactory;import org.apache.derby.iapi.types.RowLocation;import org.apache.derby.catalog.UUID;import java.util.Enumeration;import java.util.Properties;/*** A poor mans structure used in DataDictionaryImpl.java.* Used to save heapId, name pairs for non core tables.** @author jamie*/public class TabInfoImpl implements TabInfo{	private IndexInfoImpl[]				indexes;	private String						name;	private long						heapConglomerate;	private int							numIndexesSet;	private boolean						heapSet;	private UUID						uuid;	private CatalogRowFactory			crf;	private	ExecutionFactory			executionFactory;	/**	 * Constructor	 *	 * @param crf				the associated CatalogRowFactory	 * @param executionFactory	execution factory of the database	 */	public TabInfoImpl(CatalogRowFactory crf)	{		this.name = crf.getCatalogName();		this.heapConglomerate = -1;		this.crf = crf;		this.executionFactory = crf.getExecutionFactory();		int numIndexes = crf.getNumIndexes();		if (numIndexes > 0)		{			indexes = new IndexInfoImpl[numIndexes];			/* Init indexes */			for (int indexCtr = 0; indexCtr < numIndexes; indexCtr++)			{				indexes[indexCtr] = new IndexInfoImpl(											-1, 											crf.getIndexName(indexCtr),											crf.getIndexColumnCount(indexCtr),											crf.isIndexUnique(indexCtr),											indexCtr,											crf);			}		}	}	/**	 * @see TabInfo#getHeapConglomerate	 */	public long getHeapConglomerate()	{		return heapConglomerate;	}	/**	 * @see TabInfo#setHeapConglomerate	 */	public void setHeapConglomerate(long heapConglomerate)	{		this.heapConglomerate = heapConglomerate;		heapSet = true;	}	/**	 * @see TabInfo#getIndexConglomerate	 */	public long getIndexConglomerate(int indexID)	{		if (SanityManager.DEBUG)		{			SanityManager.ASSERT(indexes != null,				"indexes is expected to be non-null");            if (indexID >= indexes.length)            {                SanityManager.THROWASSERT(                    "indexID (" + indexID + ") is out of range(0-" +                    indexes.length + ")");            }		}		return indexes[indexID].getConglomerateNumber();	}	/**	 * @see TabInfo#setIndexConglomerate	 */	public void setIndexConglomerate(int index, long indexConglomerate)	{		/* Index names must be set before conglomerates.		 * Also verify that we are not setting the same conglomerate		 * twice.		 */		if (SanityManager.DEBUG)		{			SanityManager.ASSERT(indexes[index] != null,				"indexes[index] expected to be non-null");			SanityManager.ASSERT(indexes[index].getConglomerateNumber() == -1,				"indexes[index] expected to be -1");		}		indexes[index].setConglomerateNumber(indexConglomerate);		/* We are completely initialized when all indexes have 		 * their conglomerates initialized 		 */		numIndexesSet++;	}	public void setIndexConglomerate(ConglomerateDescriptor cd)	{		int		index;		String	indexName = cd.getConglomerateName();		if (SanityManager.DEBUG)		{			SanityManager.ASSERT(indexes != null,				"indexes is expected to be non-null");		}		for (index = 0; index < indexes.length; index++)		{			/* All index names expected to be set before			 * any conglomerate is set.			 */			if (SanityManager.DEBUG)			{				SanityManager.ASSERT(indexes[index] != null,					"indexes[index] expected to be non-null");				SanityManager.ASSERT(indexes[index].getIndexName() != null,					"indexes[index].getIndexName() expected to be non-null");			}			/* Do we have a match? */			if (indexes[index].getIndexName().equals(indexName))			{				indexes[index].setConglomerateNumber(cd.getConglomerateNumber());				break;			}		}		if (SanityManager.DEBUG)		{			if (index == indexes.length)			{				SanityManager.THROWASSERT("match not found for " + indexName);			}		}		/* We are completely initialized when all indexIds are initialized */		numIndexesSet++;	}	/**	 * @see TabInfo#getTableName	 */	public String getTableName()	{		return name;	}	/**	 * @see TabInfo#getIndexName	 */	public String getIndexName(int indexId)	{		return indexes[indexId].getIndexName();	}	/**	 * @see TabInfo#setIndexName	 */	public void setIndexName(int indexID, String indexName)	{		if (SanityManager.DEBUG)		{			SanityManager.ASSERT(indexes != null,				"indexes is expected to be non-null");			if (indexID >= indexes.length)				SanityManager.THROWASSERT(				"indexID (" + indexID + ") is out of range(0-" +				indexes.length + ")");		}		indexes[indexID].setIndexName(indexName);	}	/**	 * @see TabInfo#getCatalogRowFactory	 */	public CatalogRowFactory getCatalogRowFactory()	{		return crf;	}	/**	 * @see TabInfo#isComplete	 */	public boolean isComplete()	{		/* We are complete when heap conglomerate and all		 * index conglomerates are set.		 */		if (! heapSet)		{			return false;		}		return (indexes == null ||	indexes.length == numIndexesSet);	}	/**	 * @see TabInfo#getIndexColumnCount	 */	public int getIndexColumnCount(int indexNumber)	{		if (SanityManager.DEBUG)		{			SanityManager.ASSERT(indexes != null,				"indexes is expected to be non-null");			if (!(indexNumber < indexes.length))			{				SanityManager.THROWASSERT("indexNumber (" + indexNumber + ") is out of range(0-" +				indexes.length + ")");			}		}		return indexes[indexNumber].getColumnCount();	}	/**	 * @see TabInfo#getIndexRowGenerator	 */	public IndexRowGenerator getIndexRowGenerator(int indexNumber)	{		if (SanityManager.DEBUG)		{			SanityManager.ASSERT(indexes != null,				"indexes is expected to be non-null");            if (indexNumber >= indexes.length)            {                SanityManager.THROWASSERT(                    "indexNumber (" + indexNumber + ") is out of range(0-" +                    indexes.length + ")");            }		}		return indexes[indexNumber].getIndexRowGenerator();	}	/**	 * @see TabInfo#setIndexRowGenerator	 */	public void setIndexRowGenerator(int indexNumber, IndexRowGenerator irg)	{		if (SanityManager.DEBUG)		{			SanityManager.ASSERT(indexes != null,				"indexes is expected to be non-null");            if (indexNumber >= indexes.length)            {                SanityManager.THROWASSERT(                    "indexNumber (" + indexNumber + ") is out of range(0-" +                    indexes.length + ")");            }		}		indexes[indexNumber].setIndexRowGenerator(irg);	}	/**	 * @see TabInfo#getNumberOfIndexes	 */	public int getNumberOfIndexes()	{		if (indexes == null)		{			return 0;		}		else		{			return indexes.length;		}	}	/**	 * @see TabInfo#getBaseColumnPosition	 */	public int getBaseColumnPosition(int indexNumber, int colNumber)	{		if (SanityManager.DEBUG)		{			SanityManager.ASSERT(indexes != null,				"indexes is expected to be non-null");			if (indexNumber >= indexes.length)			{				SanityManager.THROWASSERT("indexNumber (" + indexNumber + ") is out of range(0-" +					indexes.length + ")");			}		}		return indexes[indexNumber].getBaseColumnPosition(colNumber);	}	/**	 * @see TabInfo#setBaseColumnPosition	 */	public void setBaseColumnPosition(int indexNumber, int colNumber,									 int baseColumnPosition)	{		if (SanityManager.DEBUG)		{			SanityManager.ASSERT(indexes != null,				"indexes is expected to be non-null");			if (indexNumber >= indexes.length)			{				SanityManager.THROWASSERT("indexNumber (" + indexNumber + ") is out of range(0-" +					indexes.length + ")");			}		}		indexes[indexNumber].setBaseColumnPosition(colNumber, baseColumnPosition);	}	/**	 * @see TabInfo#isIndexUnique	 */	public boolean isIndexUnique(int indexNumber)	{		if (SanityManager.DEBUG)		{			SanityManager.ASSERT(indexes != null,				"indexes is expected to be non-null");			if (indexNumber >= indexes.length)			{				SanityManager.THROWASSERT("indexNumber (" + indexNumber + ") is out of range(0-" +					indexes.length + ")");			}		}		return indexes[indexNumber].isIndexUnique();	}	/**	 * Inserts a base row into a catalog and inserts all the corresponding	 * index rows.	 *	 *	@param	row			row to insert	 *	@param	tc			transaction	 *	@param	wait		to wait on lock or quickly TIMEOUT	 *	@return	row number (>= 0) if duplicate row inserted into an index	 *			ROWNOTDUPLICATE otherwise	 *	 * @exception StandardException		Thrown on failure	 */	public int insertRow( ExecRow row, TransactionController tc, boolean wait)		throws StandardException	{		RowLocation[] 			notUsed = new RowLocation[1]; 		return insertRowListImpl(new ExecRow[] {row},tc,notUsed, wait);	}	/**	 * Inserts a base row into a catalog and inserts all the corresponding

⌨️ 快捷键说明

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