/** (Testing mainly) Make an in-memory B+Tree, with copy-in, copy-out block managers */ public static BPlusTree makeMem(String name, int order, int keyLength, int valueLength) { return makeMem(name, order, -1, keyLength, valueLength) ; }
@Override public RangeIndex makeRangeIndex() { BPlusTree bpTree = BPlusTreeFactory.makeMem(order, recordOrder, RecordLib.TestRecordLength, 0) ; if ( trackers ) bpTree = BPlusTreeFactory.addTracking(bpTree) ; return bpTree ; }
/** Create a B+Tree by BlockSize */ public static BPlusTree createBPTreeByBlockSize(ComponentId cid, FileSet fileset, int blockSize, int readCacheSize, int writeCacheSize, RecordFactory factory) { return createBPTree(cid, fileset, -1, blockSize, readCacheSize, writeCacheSize, factory) ; }
public static RangeIndex makeBPlusTree(ComponentId cid, FileSet fs, int blkSize, int readCacheSize, int writeCacheSize, int dftKeyLength, int dftValueLength) { RecordFactory recordFactory = makeRecordFactory(dftKeyLength, dftValueLength) ; int order = BPlusTreeParams.calcOrder(blkSize, recordFactory.recordLength()) ; RangeIndex rIndex = createBPTree(cid, fs, order, blkSize, readCacheSize, writeCacheSize, recordFactory) ; return rIndex ; }
@Override protected BPlusTree makeRangeIndex(int order, int minRecords) { BPlusTree bpt = BPlusTreeFactory.makeMem(order, minRecords, RecordLib.TestRecordLength, 0) ; if ( addLogger ) { // Put it in but disable it so that it can be enabled // in the middle of a complex operation. LogCtl.disable(BlockMgr.class) ; bpt = BPlusTreeFactory.addLogging(bpt) ; } if ( addTracker ) bpt = BPlusTreeFactory.addTracking(bpt) ; bpt.nonTransactional() ; return bpt ; } }
/** Create the java structures to correspond to * the supplied block managers for the persistent storage. * Initialize the persistent storage to the empty B+Tree if it does not exist. */ public static BPlusTree createNonTxn(BPlusTreeParams params, BufferChannel chan, BlockMgr blkMgrNodes, BlockMgr blkMgrLeaves) { // Allocate a random ComponentId BPlusTree bpt = create(null, params, chan, blkMgrNodes, blkMgrLeaves) ; bpt.nonTransactional() ; return bpt ; }
/** Create the java structures to correspond to * the supplied block managers for the persistent storage. * Initialize the persistent storage to the empty B+Tree if it does not exist. * This is primitive operation that underpins creation of a sB+Tree. */ public static BPlusTree create(ComponentId id, BPlusTreeParams params, BufferChannel chan, BlockMgr blkMgrNodes, BlockMgr blkMgrLeaves) { if ( id == null ) id = ComponentId.allocLocal() ; BPlusTree bpt = attach(id, params, false, chan, blkMgrNodes, blkMgrLeaves) ; return bpt ; }
/** Create a B+Tree using defaults */ public static BPlusTree createBPTree(ComponentId cid, FileSet fileset, RecordFactory factory) { int readCacheSize = SystemIndex.BlockReadCacheSize ; int writeCacheSize = SystemIndex.BlockWriteCacheSize ; int blockSize = SystemIndex.BlockSize ; if ( fileset.isMem() ) { readCacheSize = 0 ; writeCacheSize = 0 ; blockSize = SystemIndex.BlockSizeTest ; } return createBPTreeByBlockSize(cid, fileset, blockSize, readCacheSize, writeCacheSize, factory) ; }
@Override protected BPlusTree makeIndex(int order, int minRecords) { BPlusTree bpt = BPlusTreeFactory.makeMem(order, minRecords, RecordLib.TestRecordLength, 0) ; if ( addLogger ) { // Put it in but disable it so that it can be enabled // in the middle of a complex operation. LogCtl.disable(BlockMgr.class) ; bpt = BPlusTreeFactory.addLogging(bpt) ; } if ( addTracker ) bpt = BPlusTreeFactory.addTracking(bpt) ; bpt.nonTransactional() ; return bpt ; } }
public static RangeIndex makeBPlusTree(ComponentId cid, FileSet fs, int blkSize, int readCacheSize, int writeCacheSize, int dftKeyLength, int dftValueLength) { RecordFactory recordFactory = makeRecordFactory(dftKeyLength, dftValueLength) ; int order = BPlusTreeParams.calcOrder(blkSize, recordFactory.recordLength()) ; RangeIndex rIndex = createBPTree(cid, fs, order, blkSize, readCacheSize, writeCacheSize, recordFactory) ; return rIndex ; }
/** Create the java structures to correspond to * the supplied block managers for the persistent storage. * Initialize the persistent storage to the empty B+Tree if it does not exist. */ public static BPlusTree createNonTxn(BPlusTreeParams params, BufferChannel chan, BlockMgr blkMgrNodes, BlockMgr blkMgrLeaves) { // Allocate a random ComponentId BPlusTree bpt = create(null, params, chan, blkMgrNodes, blkMgrLeaves) ; bpt.nonTransactional() ; return bpt ; }
/** Create the java structures to correspond to * the supplied block managers for the persistent storage. * Initialize the persistent storage to the empty B+Tree if it does not exist. * This is primitive operation that underpins creation of a sB+Tree. */ public static BPlusTree create(ComponentId id, BPlusTreeParams params, BufferChannel chan, BlockMgr blkMgrNodes, BlockMgr blkMgrLeaves) { if ( id == null ) id = ComponentId.allocLocal() ; BPlusTree bpt = attach(id, params, false, chan, blkMgrNodes, blkMgrLeaves) ; return bpt ; }
/** Create a B+Tree using defaults */ public static BPlusTree createBPTree(ComponentId cid, FileSet fileset, RecordFactory factory) { int readCacheSize = SystemIndex.BlockReadCacheSize ; int writeCacheSize = SystemIndex.BlockWriteCacheSize ; int blockSize = SystemIndex.BlockSize ; if ( fileset.isMem() ) { readCacheSize = 0 ; writeCacheSize = 0 ; blockSize = SystemIndex.BlockSizeTest ; } return createBPTreeByBlockSize(cid, fileset, blockSize, readCacheSize, writeCacheSize, factory) ; }
@Override protected BPlusTree makeRangeIndex(int order, int minRecords) { BPlusTree bpt = BPlusTreeFactory.makeMem(order, minRecords, RecordLib.TestRecordLength, 0) ; if ( addLogger ) { // Put it in but disable it so that it can be enabled // in the middle of a complex operation. LogCtl.disable(BlockMgr.class) ; bpt = BPlusTreeFactory.addLogging(bpt) ; } if ( addTracker ) bpt = BPlusTreeFactory.addTracking(bpt) ; bpt.nonTransactional() ; return bpt ; } }
/** (Testing mainly) Make an in-memory B+Tree, with copy-in, copy-out block managers */ public static BPlusTree makeMem(int order, int keyLength, int valueLength) { return makeMem(null, order, keyLength, valueLength) ; }
@Override public RangeIndex makeRangeIndex() { BPlusTree bpTree = BPlusTreeFactory.makeMem(order, recordOrder, RecordLib.TestRecordLength, 0) ; if ( trackers ) bpTree = BPlusTreeFactory.addTracking(bpTree) ; return bpTree ; }
/** Create a B+Tree by Order */ public static BPlusTree createBPTreeByOrder(ComponentId cid, FileSet fileset, int order, RecordFactory factory) { return createBPTree(cid, fileset, order, -1, SystemIndex.BlockReadCacheSize, SystemIndex.BlockWriteCacheSize, factory) ; }
/** Knowing all the parameters, create a B+Tree */ public static BPlusTree createBPTree(ComponentId cid, FileSet fileset, int order, int blockSize, int readCacheSize, int writeCacheSize, RecordFactory factory) { // ---- Checking if (blockSize < 0 && order < 0) throw new IllegalArgumentException("Neither blocksize nor order specified") ; if (blockSize >= 0 && order < 0) order = BPlusTreeParams.calcOrder(blockSize, factory.recordLength()) ; if (blockSize >= 0 && order >= 0) { int order2 = BPlusTreeParams.calcOrder(blockSize, factory.recordLength()) ; if (order != order2) throw new IllegalArgumentException("Wrong order (" + order + "), calculated = " + order2) ; } // Iffy - does not allow for slop. if (blockSize < 0 && order >= 0) { // Only in-memory. blockSize = BPlusTreeParams.calcBlockSize(order, factory) ; } BPlusTreeParams params = new BPlusTreeParams(order, factory) ; BufferChannel bptState = FileFactory.createBufferChannel(fileset, Names.extBptState) ; BlockMgr blkMgrNodes = BlockMgrFactory.create(fileset, Names.extBptTree, blockSize, readCacheSize, writeCacheSize) ; BlockMgr blkMgrRecords = BlockMgrFactory.create(fileset, Names.extBptRecords, blockSize, readCacheSize, writeCacheSize) ; return BPlusTreeFactory.create(cid, params, bptState, blkMgrNodes, blkMgrRecords) ; }
/** Reset an existing B+Tree with different storage units. * For each, null means "use same as original" */ public static BPlusTree rebuild(BPlusTree bpt, BufferChannel chan, BlockMgr blkMgrNodes, BlockMgr blkMgrLeaves) { if ( chan == null ) chan = bpt.getStateManager().getBufferChannel() ; if ( blkMgrNodes == null ) blkMgrNodes = bpt.getNodeManager().getBlockMgr() ; if ( blkMgrLeaves == null ) blkMgrLeaves = bpt.getNodeManager().getBlockMgr() ; BPlusTree bpt2 = attach(bpt.getComponentId(), bpt.getParams(), true, chan, blkMgrNodes, blkMgrLeaves) ; return bpt2 ; }
@Override protected BPlusTree makeIndex(int order, int minRecords) { BPlusTree bpt = BPlusTreeFactory.makeMem(order, minRecords, RecordLib.TestRecordLength, 0) ; if ( addLogger ) { // Put it in but disable it so that it can be enabled // in the middle of a complex operation. LogCtl.disable(BlockMgr.class) ; bpt = BPlusTreeFactory.addLogging(bpt) ; } if ( addTracker ) bpt = BPlusTreeFactory.addTracking(bpt) ; bpt.nonTransactional() ; return bpt ; } }