use of org.apache.jena.tdb.base.block.BlockMgr in project jena by apache.
the class BPlusTree method makeMem.
/** (Testing mainly) Make an in-memory B+Tree, with copy-in, copy-out block managers */
public static BPlusTree makeMem(String name, int order, int minRecords, int keyLength, int valueLength) {
BPlusTreeParams params = new BPlusTreeParams(order, keyLength, valueLength);
int blkSize;
if (minRecords > 0) {
int maxRecords = 2 * minRecords;
//int rSize = RecordBufferPage.HEADER+(maxRecords*params.getRecordLength()) ;
blkSize = RecordBufferPage.calcBlockSize(params.getRecordFactory(), maxRecords);
} else
blkSize = params.getCalcBlockSize();
BlockMgr mgr1 = BlockMgrFactory.createMem(name + "(nodes)", params.getCalcBlockSize());
BlockMgr mgr2 = BlockMgrFactory.createMem(name + "(records)", blkSize);
BPlusTree bpTree = BPlusTree.create(params, mgr1, mgr2);
return bpTree;
}
use of org.apache.jena.tdb.base.block.BlockMgr in project jena by apache.
the class ExtHash method createMem.
/** Testing version - in-memory but inefficient as it uses a copy-in/copy-out block manager as a RAM disk*/
public static ExtHash createMem(RecordFactory factory, int bucketSizeBytes) {
BlockMgr mgr = BlockMgrFactory.createMem("ExtHash", bucketSizeBytes);
ExtHash eHash = new ExtHash(new PlainFileMem(), factory, mgr);
return eHash;
}
use of org.apache.jena.tdb.base.block.BlockMgr in project jena by apache.
the class BPlusTreeTools method bpt_scan_record_buffer.
/** Scan/dump a file of RecordBuffers */
/*public*/
private static void bpt_scan_record_buffer(String filename, boolean verbose) {
BlockMgr blkMgr = BlockMgrFactory.createStdFileNoCache(filename, SystemTDB.BlockSize);
bpt_scan_record_buffer(blkMgr, verbose);
blkMgr.close();
}
use of org.apache.jena.tdb.base.block.BlockMgr in project jena by apache.
the class ProcRewriteIndex method exec.
public static void exec(Location srcLoc, Location dstLoc, String indexName) {
FileSet destination = new FileSet(dstLoc, indexName);
int readCacheSize = 0;
int writeCacheSize = -1;
int dftKeyLength;
int dftValueLength;
if (indexName.length() == 3) {
dftKeyLength = SystemTDB.LenIndexTripleRecord;
dftValueLength = 0;
} else if (indexName.length() == 4) {
dftKeyLength = SystemTDB.LenIndexQuadRecord;
dftValueLength = 0;
} else {
System.err.printf("Can't determine record size for %s\n", indexName);
return;
}
RecordFactory recordFactory = null;
BPlusTreeParams bptParams = null;
BlockMgr blkMgrNodes;
BlockMgr blkMgrRecords;
int blockSize = SystemTDB.BlockSize;
RangeIndex rangeIndex = SetupIndex.makeRangeIndex(srcLoc, indexName, blockSize, dftKeyLength, dftValueLength, readCacheSize, writeCacheSize);
BPlusTree bpt = (BPlusTree) rangeIndex;
bptParams = bpt.getParams();
recordFactory = bpt.getRecordFactory();
int blockSizeNodes = blockSize;
int blockSizeRecords = blockSize;
blkMgrNodes = BlockMgrFactory.create(destination, Names.bptExtTree, blockSizeNodes, readCacheSize, writeCacheSize);
blkMgrRecords = BlockMgrFactory.create(destination, Names.bptExtRecords, blockSizeRecords, readCacheSize, writeCacheSize);
Iterator<Record> iterator = bpt.iterator();
// // Fakery.
// blkMgrNodes = BlockMgrFactory.create(destination, Names.bptExt1, blockSize, readCacheSize, writeCacheSize) ;
// blkMgrRecords = BlockMgrFactory.create(destination, Names.bptExt2, blockSize, readCacheSize, writeCacheSize) ;
// recordFactory = new RecordFactory(dftKeyLength, dftValueLength) ;
// bptParams = new BPlusTreeParams(3, recordFactory) ;
// List<Record> data = TestBPlusTreeRewriter.createData(10, recordFactory) ;
// iterator = data.iterator() ;
//System.out.println("Rewrite: "+srcLoc+" "+indexName+" --> "+destination) ;
BPlusTree bpt2 = BPlusTreeRewriter.packIntoBPlusTree(iterator, bptParams, recordFactory, blkMgrNodes, blkMgrRecords);
if (bpt2 == null)
return;
//
// Iterator<Record> iter = bpt2.iterator() ;
// for ( ; iter.hasNext() ; )
// {
// Record r = iter.next() ;
// System.out.println(r) ;
// }
bpt2.close();
}
use of org.apache.jena.tdb.base.block.BlockMgr in project jena by apache.
the class ProcIndexBuild method exec.
public static void exec(String locationStr, String indexName, String dataFile) {
// Argument processing
Location location = Location.create(locationStr);
//InputStream input = System.in ;
InputStream input = IO.openFile(dataFile);
int keyLength = SystemTDB.SizeOfNodeId * indexName.length();
int valueLength = 0;
// The name is the order.
String primary = indexName;
// Scope for optimization:
// Null column map => no churn.
// Do record -> record copy, not Tuple, Tuple copy.
String primaryOrder;
int dftKeyLength;
int dftValueLength;
int tupleLength = indexName.length();
if (tupleLength == 3) {
primaryOrder = Names.primaryIndexTriples;
dftKeyLength = SystemTDB.LenIndexTripleRecord;
dftValueLength = 0;
} else if (tupleLength == 4) {
primaryOrder = Names.primaryIndexQuads;
dftKeyLength = SystemTDB.LenIndexQuadRecord;
dftValueLength = 0;
} else {
throw new AtlasException("Index name: " + indexName);
}
ColumnMap colMap = new ColumnMap(primaryOrder, indexName);
// -1? Write only.
// Also flush cache every so often => block writes (but not sequential so boring).
int readCacheSize = 10;
int writeCacheSize = 100;
int blockSize = SystemTDB.BlockSize;
RecordFactory recordFactory = new RecordFactory(dftKeyLength, dftValueLength);
int order = BPlusTreeParams.calcOrder(blockSize, recordFactory);
BPlusTreeParams bptParams = new BPlusTreeParams(order, recordFactory);
int blockSizeNodes = blockSize;
int blockSizeRecords = blockSize;
FileSet destination = new FileSet(location, indexName);
BlockMgr blkMgrNodes = BlockMgrFactory.create(destination, Names.bptExtTree, blockSizeNodes, readCacheSize, writeCacheSize);
BlockMgr blkMgrRecords = BlockMgrFactory.create(destination, Names.bptExtRecords, blockSizeRecords, readCacheSize, writeCacheSize);
int rowBlock = 1000;
Iterator<Record> iter = new RecordsFromInput(input, tupleLength, colMap, rowBlock);
BPlusTree bpt2 = BPlusTreeRewriter.packIntoBPlusTree(iter, bptParams, recordFactory, blkMgrNodes, blkMgrRecords);
bpt2.close();
}
Aggregations