use of org.apache.jena.dboe.base.block.BlockMgr in project jena by apache.
the class BPlusTreeFactory method addLogging.
/**
* Debugging
*/
public static BPlusTree addLogging(BPlusTree bpTree) {
BufferChannel mgrRoot = null;
BlockMgr mgr1 = bpTree.getNodeManager().getBlockMgr();
BlockMgr mgr2 = bpTree.getRecordsMgr().getBlockMgr();
mgr1 = new BlockMgrLogger(mgr1, false);
mgr2 = new BlockMgrLogger(mgr2, false);
return BPlusTreeFactory.rebuild(bpTree, mgrRoot, mgr1, mgr2);
}
use of org.apache.jena.dboe.base.block.BlockMgr in project jena by apache.
the class TestBPlusTreeRewriterNonTxn method runOneTest.
public static void runOneTest(int order, int N, RecordFactory recordFactory, boolean debug) {
BPlusTreeParams bptParams = new BPlusTreeParams(order, recordFactory);
BPlusTreeRewriter.debug = debug;
// ---- Test data
List<Record> originaldata = TestBPlusTreeRewriterNonTxn.createData(N, recordFactory);
if (debug)
System.out.println("Test data: " + originaldata);
FileSet destination = FileSet.mem();
// ---- Rewrite
BufferChannel rootState = FileFactory.createBufferChannel(destination, Names.extBptState);
// Write leaves to ...
BlockMgr blkMgr1 = BlockMgrFactory.create(destination, Names.extBptTree, bptParams.getCalcBlockSize(), 10, 10);
// Write nodes to ...
BlockMgr blkMgr2 = BlockMgrFactory.create(destination, Names.extBptTree, bptParams.getCalcBlockSize(), 10, 10);
BPlusTree bpt2 = BPlusTreeRewriter.packIntoBPlusTree(originaldata.iterator(), bptParams, recordFactory, rootState, blkMgr1, blkMgr2);
if (debug) {
BPlusTreeRewriterUtils.divider();
bpt2.dump();
}
// ---- Checking
bpt2.check();
scanComparision(originaldata, bpt2);
findComparison(originaldata, bpt2);
sizeComparison(originaldata, bpt2);
}
use of org.apache.jena.dboe.base.block.BlockMgr in project jena by apache.
the class TestRecordBufferPage method recBufferPage02.
@Test
public void recBufferPage02() {
BlockMgr blkMgr = makeBlockMgr();
blkMgr.beginUpdate();
RecordBufferPageMgr rpm = new RecordBufferPageMgr(factory, blkMgr);
int x = -99;
{
RecordBufferPage page1 = rpm.create();
fill(page1.getRecordBuffer(), 10, 20, 30);
x = page1.getId();
rpm.put(page1);
page1 = null;
}
blkMgr.endUpdate();
blkMgr.beginRead();
{
RecordBufferPage page2 = rpm.getRead(x);
assertEquals(10, get(page2, 0));
assertEquals(20, get(page2, 1));
assertEquals(30, get(page2, 2));
rpm.release(page2);
}
blkMgr.endRead();
}
use of org.apache.jena.dboe.base.block.BlockMgr in project jena by apache.
the class TestRecordBufferPage method recBufferPage01.
@Test
public void recBufferPage01() {
BlockMgr blkMgr = makeBlockMgr();
blkMgr.beginUpdate();
RecordBufferPageMgr rpm = new RecordBufferPageMgr(factory, blkMgr);
RecordBufferPage page = rpm.create();
fill(page.getRecordBuffer(), 10, 20, 30);
assertEquals(10, get(page, 0));
assertEquals(20, get(page, 1));
assertEquals(30, get(page, 2));
rpm.release(page);
blkMgr.endUpdate();
}
use of org.apache.jena.dboe.base.block.BlockMgr in project jena by apache.
the class ProcBuildIndexX method indexBuilder.
private static long indexBuilder(DatasetGraph dsg, InputStream input, String indexName) {
long tickPoint = BulkLoaderX.DataTick;
int superTick = BulkLoaderX.DataSuperTick;
// Location of storage, not the DB.
DatasetGraphTDB dsgtdb = TDBInternal.getDatasetGraphTDB(dsg);
Location location = dsgtdb.getLocation();
int keyLength = SystemTDB.SizeOfNodeId * indexName.length();
int valueLength = 0;
// The name is the order.
String primary = indexName;
String primaryOrder;
int dftKeyLength;
int dftValueLength;
int tupleLength = indexName.length();
TupleIndex index;
if (tupleLength == 3) {
primaryOrder = Names.primaryIndexTriples;
dftKeyLength = SystemTDB.LenIndexTripleRecord;
dftValueLength = 0;
// Find index.
index = findIndex(dsgtdb.getTripleTable().getNodeTupleTable().getTupleTable().getIndexes(), indexName);
} else if (tupleLength == 4) {
primaryOrder = Names.primaryIndexQuads;
dftKeyLength = SystemTDB.LenIndexQuadRecord;
dftValueLength = 0;
index = findIndex(dsgtdb.getQuadTable().getNodeTupleTable().getTupleTable().getIndexes(), indexName);
} else {
throw new TDBException("Index name: " + indexName);
}
TupleMap colMap = TupleMap.create(primaryOrder, indexName);
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);
BufferChannel blkState = FileFactory.createBufferChannel(destination, Names.extBptState);
BlockMgr blkMgrNodes = BlockMgrFactory.create(destination, Names.extBptTree, blockSizeNodes, readCacheSize, writeCacheSize);
BlockMgr blkMgrRecords = BlockMgrFactory.create(destination, Names.extBptRecords, blockSizeRecords, readCacheSize, writeCacheSize);
int rowBlock = 1000;
Iterator<Record> iter = new RecordsFromInput(input, tupleLength, colMap, rowBlock);
// ProgressMonitor.
ProgressMonitor monitor = ProgressMonitorOutput.create(BulkLoaderX.LOG_Index, indexName, tickPoint, superTick);
ProgressIterator<Record> iter2 = new ProgressIterator<>(iter, monitor);
monitor.start();
BPlusTree bpt2 = BPlusTreeRewriter.packIntoBPlusTree(iter2, bptParams, recordFactory, blkState, blkMgrNodes, blkMgrRecords);
bpt2.close();
monitor.finish();
// [BULK] End stage.
long count = monitor.getTicks();
return count;
}
Aggregations