use of org.apache.jena.tdb.store.tupletable.TupleIndexRecord 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.store.tupletable.TupleIndexRecord 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.store.tupletable.TupleIndexRecord in project jena by apache.
the class SetupTDB method makeTupleIndex.
public static TupleIndex makeTupleIndex(Location location, String primary, String indexOrder, String indexName, int keyLength) {
FileSet fs = new FileSet(location, indexName);
int readCacheSize = params.getBlockReadCacheSize();
int writeCacheSize = params.getBlockWriteCacheSize();
// Value part is null (zero length)
RangeIndex rIndex = SetupIndex.makeRangeIndex(location, indexName, params.getBlockSize(), keyLength, 0, readCacheSize, writeCacheSize);
TupleIndex tupleIndex = new TupleIndexRecord(primary.length(), new ColumnMap(primary, indexOrder), indexOrder, rIndex.getRecordFactory(), rIndex);
return tupleIndex;
}
use of org.apache.jena.tdb.store.tupletable.TupleIndexRecord in project jena by apache.
the class DebugTDB method dumpIndex.
public static void dumpIndex(TupleIndex idx) {
Iterator<Tuple<NodeId>> iter = idx.all();
while (iter.hasNext()) {
Tuple<NodeId> tuple = iter.next();
System.out.println(tuple);
}
if (false) {
// Dump raw
TupleIndexRecord tir = (TupleIndexRecord) idx;
RangeIndex rIdx = tir.getRangeIndex();
for (Record aRIdx : rIdx) {
System.out.println(aRIdx);
}
}
}
use of org.apache.jena.tdb.store.tupletable.TupleIndexRecord in project jena by apache.
the class dumpbpt method exec.
@Override
protected void exec() {
List<String> tripleIndexes = Arrays.asList(Names.tripleIndexes);
List<String> quadIndexes = Arrays.asList(Names.quadIndexes);
Location loc = modLocation.getLocation();
// The name is the order.
for (String indexName : super.getPositional()) {
String primary;
if (indexName.length() == 3) {
primary = Names.primaryIndexTriples;
} else if (indexName.length() == 4) {
primary = Names.primaryIndexQuads;
} else if (Objects.equals(indexName, Names.indexNode2Id)) {
primary = Names.indexNode2Id;
} else {
cmdError("Wrong length: " + indexName);
primary = null;
}
// prefix2id
// prefixIdx : GPU
int keySubLen = SystemTDB.SizeOfNodeId;
int keyUnitLen = indexName.length();
int keyLength = keySubLen * keyUnitLen;
int valueLength = 0;
// Node table indexes.
if (Objects.equals(indexName, Names.indexNode2Id) || Objects.equals(indexName, Names.prefixNode2Id)) {
keySubLen = SystemTDB.LenNodeHash;
keyUnitLen = 1;
keyLength = SystemTDB.LenNodeHash;
valueLength = SystemTDB.SizeOfNodeId;
}
// Prefixes
if (Objects.equals(indexName, Names.indexPrefix)) {
primary = Names.primaryIndexPrefix;
}
RecordFactory rf = new RecordFactory(keyLength, valueLength);
RangeIndex rIndex = IndexFactory.buildRangeIndex(loc, indexName, rf);
BPlusTree bpt = (BPlusTree) rIndex;
if (false) {
System.out.println("---- Index structure");
bpt.dump();
}
if (true) {
System.out.println("---- Index contents");
Iterator<Record> iter = bpt.iterator();
if (!iter.hasNext())
System.out.println("<<Empty>>");
for (; iter.hasNext(); ) {
Record r = iter.next();
printRecord("", System.out, r, keyUnitLen);
}
}
// Check.
Iterator<Record> iterCheck = bpt.iterator();
Record r1 = null;
int i = 0;
for (; iterCheck.hasNext(); ) {
Record r2 = iterCheck.next();
i++;
if (r1 != null) {
if (!Record.keyLT(r1, r2)) {
System.err.println("key error@ " + i);
printRecord(" ", System.err, r1, keyUnitLen);
printRecord(" ", System.err, r2, keyUnitLen);
}
}
r1 = r2;
}
if (false) {
// Dump in tuple order.
TupleIndex tupleIndex = new TupleIndexRecord(primary.length(), new ColumnMap(primary, indexName), indexName, rIndex.getRecordFactory(), rIndex);
if (true) {
System.out.println("---- Tuple contents");
Iterator<Tuple<NodeId>> iter2 = tupleIndex.all();
if (!iter2.hasNext())
System.out.println("<<Empty>>");
for (; iter2.hasNext(); ) {
Tuple<NodeId> row = iter2.next();
System.out.println(row);
}
}
}
}
}
Aggregations