use of org.apache.jena.tdb.index.RangeIndex 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.index.RangeIndex in project jena by apache.
the class TestTransIterator method transIter_03.
@Test
public void transIter_03() {
// Interleaved.
int[] vals = { 1, 2, 3, 4, 5, 6, 7 };
RangeIndex rIndex = build(2, vals);
Iterator<Record> iter1 = rIndex.iterator();
Iterator<Record> iter2 = rIndex.iterator();
for (; iter1.hasNext(); ) {
Record r1 = iter1.next();
Record r2 = iter2.next();
}
assertFalse(iter2.hasNext());
}
use of org.apache.jena.tdb.index.RangeIndex in project jena by apache.
the class IndexAssembler method open.
@Override
public TupleIndex open(Assembler a, Resource root, Mode mode) {
exactlyOneProperty(root, pDescription);
String desc = getAsStringValue(root, pDescription).toUpperCase(Locale.ENGLISH);
exactlyOneProperty(root, pFile);
String filename = getAsStringValue(root, pFile);
// Need to get location from the enclosing PGraphAssembler
if (location != null)
filename = location.absolute(filename);
String primary = null;
RecordFactory rf = null;
switch(desc.length()) {
case 3:
primary = Names.primaryIndexTriples;
rf = SystemTDB.indexRecordTripleFactory;
break;
case 4:
primary = Names.primaryIndexQuads;
rf = SystemTDB.indexRecordQuadFactory;
break;
default:
throw new TDBException("Bad length for index description: " + desc);
}
// Problems with spotting the index technology.
// FileSet.fromFilename(filename) ;
FileSet fileset = null;
IndexParams idxParams = StoreParams.getDftStoreParams();
RangeIndex rIndex = IndexFactory.buildRangeIndex(fileset, rf, idxParams);
return new TupleIndexRecord(desc.length(), new ColumnMap(primary, desc), desc, rf, rIndex);
}
use of org.apache.jena.tdb.index.RangeIndex in project jena by apache.
the class DatasetBuilderStd method buildTupleIndex.
// -------------
private TupleIndex buildTupleIndex(FileSet fileSet, ColumnMap colMap, String name, StoreParams params) {
RecordFactory recordFactory = new RecordFactory(SystemTDB.SizeOfNodeId * colMap.length(), 0);
RangeIndex rIdx = /*rangeIndexBuilder.*/
buildRangeIndex(fileSet, recordFactory, params);
TupleIndex tIdx = new TupleIndexRecord(colMap.length(), colMap, name, recordFactory, rIdx);
return tIdx;
}
use of org.apache.jena.tdb.index.RangeIndex in project jena by apache.
the class DatasetBuilderStd method buildRangeIndex.
private RangeIndex buildRangeIndex(FileSet fileSet, RecordFactory recordFactory, IndexParams indexParams) {
int blkSize = indexParams.getBlockSize();
int order = BPlusTreeParams.calcOrder(blkSize, recordFactory.recordLength());
RangeIndex rIndex = createBPTree(fileSet, order, blockMgrBuilder, blockMgrBuilder, recordFactory, indexParams);
return rIndex;
}
Aggregations