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

📄 syscolumnsrowfactory.java

📁 derby database source code.good for you.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
	 * Builds an empty index row.	 *	 *	@param	indexNumber	Index to build empty row for.	 *  @param  rowLocation	Row location for last column of index row	 *	 * @return corresponding empty index row	 * @exception   StandardException thrown on failure	 */	public ExecIndexRow	buildEmptyIndexRow( int indexNumber,											RowLocation rowLocation) 			throws StandardException	{		int ncols = getIndexColumnCount(indexNumber);		ExecIndexRow row = getExecutionFactory().getIndexableRow(ncols + 1);		row.setColumn(ncols + 1, rowLocation);		switch(indexNumber)		{			case SYSCOLUMNS_INDEX1_ID:				/* 1st column is REFERENCEID (UUID - char(36)) */				row.setColumn					(1, getDataValueFactory().getCharDataValue((String) null));				/* 2nd column is COLUMNNAME (varchar(128)) */				row.setColumn				    (2, 					 getDataValueFactory().getVarcharDataValue((String) null));				break;		    case SYSCOLUMNS_INDEX2_ID:								/* 1st column is DEFAULTID (UUID - char(36)) */				row.setColumn					(1, getDataValueFactory().getCharDataValue((String) null));				break;		}	// end switch		return	row;	}	/**	 * Make a ColumnDescriptor out of a SYSCOLUMNS row	 *	 * @param row 					a SYSCOLUMNS row	 * @param parentTupleDescriptor	The UniqueTupleDescriptor for the object that is tied	 *								to this column	 * @param dd 					dataDictionary	 *	 * @return	a column descriptor equivalent to a SYSCOLUMNS row	 *	 * @exception   StandardException thrown on failure	 */	public TupleDescriptor buildDescriptor(		ExecRow					row,		TupleDescriptor			parentTupleDescriptor,		DataDictionary 			dd )					throws StandardException	{		if (SanityManager.DEBUG)		{			SanityManager.ASSERT(row.nColumns() == SYSCOLUMNS_COLUMN_COUNT, 								 "Wrong number of columns for a SYSCOLUMNS row");		}		int columnNumber;		String columnName;		String defaultID;		DefaultInfoImpl		defaultInfo = null;		ColumnDescriptor colDesc;		BaseTypeIdImpl		typeId;		TypeId	wrapperTypeId;		DataValueDescriptor	defaultValue = null;		UUID				defaultUUID = null;		UUID				uuid = null;		UUIDFactory			uuidFactory = getUUIDFactory();		long autoincStart, autoincInc;		DataDescriptorGenerator	ddg = dd.getDataDescriptorGenerator();		/*		** We're going to be getting the UUID for this sucka		** so make sure it is a UniqueTupleDescriptor.		*/		if (parentTupleDescriptor != null)		{			if (SanityManager.DEBUG)			{				if (!(parentTupleDescriptor instanceof UniqueTupleDescriptor))				{					SanityManager.THROWASSERT(parentTupleDescriptor.getClass().getName() 							+ " not instanceof UniqueTupleDescriptor");					}			}			uuid = ((UniqueTupleDescriptor)parentTupleDescriptor).getUUID();		}		else		{			/* 1st column is REFERENCEID (char(36)) */			uuid = uuidFactory.recreateUUID(row.getColumn(SYSCOLUMNS_REFERENCEID).													getString());		}		/* NOTE: We get columns 5 and 6 next in order to work around 		 * a 1.3.0 HotSpot bug.  (#4361550)		 */		// 5th column is COLUMNDEFAULT (serialiazable)		Object object = row.getColumn(SYSCOLUMNS_COLUMNDEFAULT).getObject();		if (object instanceof DataValueDescriptor)		{			defaultValue = (DataValueDescriptor) object;		}		else if (object instanceof DefaultInfoImpl)		{			defaultInfo = (DefaultInfoImpl) object;			defaultValue = defaultInfo.getDefaultValue();		}		/* 6th column is DEFAULTID (char(36)) */		defaultID = row.getColumn(SYSCOLUMNS_COLUMNDEFAULTID).getString();		if (defaultID != null)		{			defaultUUID = uuidFactory.recreateUUID(defaultID);		}		/* 2nd column is COLUMNNAME (varchar(128)) */		columnName = row.getColumn(SYSCOLUMNS_COLUMNNAME).getString();		/* 3rd column is COLUMNNUMBER (int) */		columnNumber = row.getColumn(SYSCOLUMNS_COLUMNNUMBER).getInt();		/* 4th column is COLUMNDATATYPE */		/*		** What is stored in the column is a TypeDescriptorImpl, which		** points to a BaseTypeIdImpl.  These are simple types that are		** intended to be movable to the client, so they don't have		** the entire implementation.  We need to wrap them in DataTypeServices		** and TypeId objects that contain the full implementations for		** language processing.		*/		TypeDescriptorImpl typeDescriptor = (TypeDescriptorImpl) row.getColumn(SYSCOLUMNS_COLUMNDATATYPE).													getObject();		typeId = typeDescriptor.getTypeId();		/*		** The BaseTypeIdImpl tells what type of TypeId it is supposed to		** be wrapped in.		*/		wrapperTypeId =			(TypeId) Monitor.newInstanceFromIdentifier(typeId.wrapperTypeFormatId());		/* Wrap the BaseTypeIdImpl in a full type id */		wrapperTypeId.setNestedTypeId(typeId);		/* Wrap the TypeDescriptorImpl in a full DataTypeDescriptor */		DataTypeDescriptor dataTypeServices = new DataTypeDescriptor(typeDescriptor,													wrapperTypeId);		/* 7th column is AUTOINCREMENTVALUE, not cached in descriptor (long) */		/* 8th column is AUTOINCREMENTSTART (long) */		autoincStart = row.getColumn(SYSCOLUMNS_AUTOINCREMENTSTART).getLong();		/* 9th column is AUTOINCREMENTINC (long) */		autoincInc = row.getColumn(SYSCOLUMNS_AUTOINCREMENTINC).getLong();		DataValueDescriptor col = row.getColumn(SYSCOLUMNS_AUTOINCREMENTSTART);		autoincStart = col.getLong();		col = row.getColumn(SYSCOLUMNS_AUTOINCREMENTINC);		autoincInc = col.getLong();		colDesc = new ColumnDescriptor(columnName, columnNumber,							dataTypeServices, defaultValue, defaultInfo, uuid, 							defaultUUID, autoincStart, autoincInc);		return colDesc;	}	/**	  *	Get the index number for the primary key index on this catalog.	  *	  *	@return	a 0-based number	  *	  */	public	int	getPrimaryKeyIndexNumber()	{		return SYSCOLUMNS_INDEX1_ID;	}	/**	 * Builds a list of columns suitable for creating this Catalog.	 *	 *	 * @return array of SystemColumn suitable for making this catalog.	 */	public SystemColumn[]	buildColumnList()	{		if ( columnList != null ) { return columnList; }		columnList = new SystemColumn[SYSCOLUMNS_COLUMN_COUNT];		// describe columns		columnList[0] = 					new SystemColumnImpl(								convertIdCase( REFERENCEDID_STRING),			// column name								SYSCOLUMNS_REFERENCEID,// column number								0,					// precision								0,					// scale								false,				// nullability								"CHAR",				// dataType								true,				// built-in type								36					// maxLength			                   );		columnList[1] = 					new SystemColumnImpl(			// SQL IDENTIFIER								convertIdCase( COLUMNNAME_STRING),		// column name								SYSCOLUMNS_COLUMNNAME,	// column number								false				// nullability			                   );		columnList[2] = 					new SystemColumnImpl(								convertIdCase( "COLUMNNUMBER"),	// column name								SYSCOLUMNS_COLUMNNUMBER,	// column number								0,					// precision								0,					// scale								false,				// nullability								"INTEGER",				// dataType								true,				// built-in type								4					// maxLength							   );		columnList[3] = 					new SystemColumnImpl(								convertIdCase( "COLUMNDATATYPE"),			// column name							SYSCOLUMNS_COLUMNDATATYPE,	// column number							0,					// precision							0,					// scale							false,				// nullability							"org.apache.derby.catalog.TypeDescriptor",	    // dataType							false,				// built-in type							TypeDescriptor.MAXIMUM_WIDTH_UNKNOWN // maxLength			               );		columnList[4] = 					new SystemColumnImpl(								convertIdCase( "COLUMNDEFAULT"),			// column name							SYSCOLUMNS_COLUMNDEFAULT,	// column number							0,					// precision							0,					// scale							true,				// nullability							"java.io.Serializable",	    // dataType							false,				// built-in type							TypeDescriptor.MAXIMUM_WIDTH_UNKNOWN // maxLength			               );		columnList[5] = 					new SystemColumnImpl(								convertIdCase( COLUMNDEFAULTID_STRING),			// column name								SYSCOLUMNS_COLUMNDEFAULTID,// column number								0,					// precision								0,					// scale								true,				// nullability								"CHAR",				// dataType								true,				// built-in type								36					// maxLength			                   );		// new columns for autoincrement.		columnList[6] = 			        new SystemColumnImpl(							    convertIdCase( "AUTOINCREMENTVALUE"), // column name								SYSCOLUMNS_AUTOINCREMENTVALUE,								0,								0, 								true,								"BIGINT",								true,								TypeId.LONGINT_MAXWIDTH							   );				columnList[7] = 			        new SystemColumnImpl(							    convertIdCase( "AUTOINCREMENTSTART"), // column name								SYSCOLUMNS_AUTOINCREMENTSTART,								0,								0, 								true,								"BIGINT",								true,								TypeId.LONGINT_MAXWIDTH							   );		columnList[8] = 			        new SystemColumnImpl(							    convertIdCase( "AUTOINCREMENTINC"), // column name								SYSCOLUMNS_AUTOINCREMENTINC,								0,								0, 								true,								"BIGINT",								true,								TypeId.LONGINT_MAXWIDTH							   );		return	columnList;	}}

⌨️ 快捷键说明

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