use of org.apache.jena.tdb.index.RangeIndex in project jena by apache.
the class TestTransIterator method transIter_01.
@Test
public void transIter_01() {
int[] vals = {};
RangeIndex rIndex = build(2, vals);
Iterator<Record> iter1 = rIndex.iterator();
Iterator<Record> iter2 = rIndex.iterator();
count(iter1, vals.length);
count(iter2, vals.length);
}
use of org.apache.jena.tdb.index.RangeIndex in project jena by apache.
the class TestTransIterator method transIter_02.
@Test
public void transIter_02() {
int[] vals = { 1, 2, 3, 4, 5, 6, 7 };
RangeIndex rIndex = build(2, vals);
Iterator<Record> iter1 = rIndex.iterator();
Iterator<Record> iter2 = rIndex.iterator();
count(iter1, vals.length);
count(iter2, vals.length);
}
use of org.apache.jena.tdb.index.RangeIndex 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.index.RangeIndex 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.index.RangeIndex 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