📄 btreecontroller.java
字号:
**/ public boolean isKeyed() { return(true); } /* * Request the system properties associated with a table. * <p> * Request the value of properties that are associated with a table. The * following properties can be requested: * derby.storage.pageSize * derby.storage.pageReservedSpace * derby.storage.minimumRecordSize * derby.storage.initialPages * <p> * To get the value of a particular property add it to the property list, * and on return the value of the property will be set to it's current * value. For example: * * get_prop(ConglomerateController cc) * { * Properties prop = new Properties(); * prop.put("derby.storage.pageSize", ""); * cc.getTableProperties(prop); * * System.out.println( * "table's page size = " + * prop.getProperty("derby.storage.pageSize"); * } * * @param prop Property list to fill in. * * @exception StandardException Standard exception policy. **/ public void getTableProperties(Properties prop) throws StandardException { if (this.container == null) { throw StandardException.newException( SQLState.BTREE_IS_CLOSED, new Long(err_containerid)); } container.getContainerProperties(prop); return; } /** * Request set of properties associated with a table. * <p> * Returns a property object containing all properties that the store * knows about, which are stored persistently by the store. This set * of properties may vary from implementation to implementation of the * store. * <p> * This call is meant to be used only for internal query of the properties * by jbms, for instance by language during bulk insert so that it can * create a new conglomerate which exactly matches the properties that * the original container was created with. This call should not be used * by the user interface to present properties to users as it may contain * properties that are meant to be internal to jbms. Some properties are * meant only to be specified by jbms code and not by users on the command * line. * <p> * Note that not all properties passed into createConglomerate() are stored * persistently, and that set may vary by store implementation. * * @param prop Property list to add properties to. If null, routine will * create a new Properties object, fill it in and return it. * * @exception StandardException Standard exception policy. **/ public Properties getInternalTablePropertySet(Properties prop) throws StandardException { Properties ret_properties = ConglomerateUtil.createRawStorePropertySet(prop); getTableProperties(ret_properties); return(ret_properties); } /** * Load rows from rowSource into the opened btree. * <p> * Efficiently load rows into the already opened btree. The btree must * be table locked, as no row locks will be requested by this routine. * On exit from this routine the conglomerate will be closed (on both * error or success). * <p> * This routine does an almost bottom up build of a btree. It assumes * all rows arrive in sorted order, and inserts them directly into the * next (to the right) spot in the current leaf until there is no space. * Then it calls the generic split code to add the next leaf (RESOLVE - * in the future we could optimize this to split bottom up rather than * top down for create index). * * @exception StandardException Standard exception policy. If conglomerate * supports uniqueness checks and has been * created to disallow duplicates, and one of * the rows being loaded had key columns which * were duplicate of a row already in the * conglomerate, then raise * SQLState.STORE_CONGLOMERATE_DUPLICATE_KEY_EXCEPTION. * * @see Conglomerate#load **/ public long load( TransactionManager xact_manager, boolean createConglom, RowLocationRetRowSource rowSource) throws StandardException { long num_rows_loaded = 0; if (SanityManager.DEBUG) { SanityManager.ASSERT(createConglom, "Cannot load a btree incrementally - it must either be entirely logged, or entirely not logged. Doesn't make sense to log only the allocation when one cannot guarantee to not touch any pre-existing pages"); } if (scratch_template == null) scratch_template = runtime_mem.get_template(); LeafControlRow current_leaf = null; try { // Btree must just have been created and empty, so there must // be one root leaf page which is empty except for the control row. current_leaf = (LeafControlRow) ControlRow.Get(this, BTree.ROOTPAGEID); int current_insert_slot = 1; if (SanityManager.DEBUG) { // root must be empty except for the control row. SanityManager.ASSERT(current_leaf.page.recordCount() == 1); } // now loop thru the row source and insert into the btree FormatableBitSet validColumns = rowSource.getValidColumns(); // get the next row and its valid columns from the rowSource DataValueDescriptor[] row; while ((row = rowSource.getNextRowFromRowSource()) != null) { num_rows_loaded++; if (SanityManager.DEBUG) { SanityManager.ASSERT( validColumns == null, "Does not support partial row"); } while (true) { if (do_load_insert(row, current_leaf, current_insert_slot)) { // row inserted successfully. break; } else { // if insert fails, do a split pass. There is an edge // case where multiple split passes are necessary if // branch splits are necessary, thus the loop. It is // most likely that only a single split pass will be // necessary. current_leaf = do_load_split(row, current_leaf); current_insert_slot = current_leaf.page.recordCount(); } } current_insert_slot++; } current_leaf.release(); current_leaf = null; // Loading done, must flush all pages to disk since it is unlogged. if (!this.getConglomerate().isTemporary()) container.flushContainer(); } finally { this.close(); } return(num_rows_loaded); } /* ** Methods of ConglomerateController which are not supported. */ /** Delete a row from the conglomerate. @see ConglomerateController#delete @exception StandardException Standard exception policy. **/ public boolean delete(RowLocation loc) throws StandardException { throw(StandardException.newException( SQLState.BTREE_UNIMPLEMENTED_FEATURE)); } /** Fetch the row at the given location. @see ConglomerateController#fetch @exception StandardException Standard exception policy. **/ public boolean fetch( RowLocation loc, DataValueDescriptor[] row, FormatableBitSet validColumns) throws StandardException { throw(StandardException.newException( SQLState.BTREE_UNIMPLEMENTED_FEATURE)); } /** Fetch the row at the given location. @see ConglomerateController#fetch @exception StandardException Standard exception policy. **/ public boolean fetch( RowLocation loc, DataValueDescriptor[] row, FormatableBitSet validColumns, boolean waitForLock) throws StandardException { throw(StandardException.newException( SQLState.BTREE_UNIMPLEMENTED_FEATURE)); } /** Insert a row into the conglomerate, and store its location in the provided template row location. Unimplemented by btree. @see ConglomerateController#insertAndFetchLocation @exception StandardException Standard exception policy. **/ public void insertAndFetchLocation( DataValueDescriptor[] row, RowLocation templateRowLocation) throws StandardException { throw StandardException.newException( SQLState.BTREE_UNIMPLEMENTED_FEATURE); } /** Return a row location object of the correct type to be used in calls to insertAndFetchLocation. @see ConglomerateController#newRowLocationTemplate @exception StandardException Standard exception policy. **/ public RowLocation newRowLocationTemplate() throws StandardException { throw StandardException.newException( SQLState.BTREE_UNIMPLEMENTED_FEATURE); } /** * Lock the given row location. * <p> * Should only be called by access. * <p> * This call can be made on a ConglomerateController that was opened * for locking only. * <p> * RESOLVE (mikem) - move this call to ConglomerateManager so it is * obvious that non-access clients should not call this. * * @return true if lock was granted, only can be false if wait was false. * * @param loc The "RowLocation" which describes the exact row to lock. * @param wait Should the lock call wait to be granted? * * @exception StandardException Standard exception policy. **/ public boolean lockRow( RowLocation loc, int lock_operation, boolean wait, int lock_duration) throws StandardException { throw StandardException.newException( SQLState.BTREE_UNIMPLEMENTED_FEATURE); } public boolean lockRow( long page_num, int record_id, int lock_operation, boolean wait, int lock_duration) throws StandardException { throw StandardException.newException( SQLState.BTREE_UNIMPLEMENTED_FEATURE); } public void unlockRowAfterRead( RowLocation loc, boolean forUpdate, boolean row_qualifies) throws StandardException { throw StandardException.newException( SQLState.BTREE_UNIMPLEMENTED_FEATURE); } /** Replace the entire row at the given location. @see ConglomerateController#replace @exception StandardException Standard exception policy. **/ public boolean replace( RowLocation loc, DataValueDescriptor[] row, FormatableBitSet validColumns) throws StandardException { throw StandardException.newException( SQLState.BTREE_UNIMPLEMENTED_FEATURE); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -