/** * Return the best fit for the blocksize and the record length. Knows about * block header space. */ public static int calcOrder(int blockSize, RecordFactory factory) { return calcOrder(blockSize, factory.recordLength()) ; }
/** * Return the best fit for the blocksize and the record length. Knows about * block header space. */ public static int calcOrder(int blockSize, RecordFactory factory) { return calcOrder(blockSize, factory.recordLength()) ; }
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 ; }
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 ; }
/** 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) ; }
/** 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) ; }