Search in sources :

Example 26 with TupleIndex

use of org.apache.jena.tdb.store.tupletable.TupleIndex in project jena by apache.

the class AbstractTestTupleIndex method TupleIndexRecordSPO_1.

@Test
public void TupleIndexRecordSPO_1() {
    TupleIndex index = createIndex("SPO");
    add(index, n1, n2, n3);
    Tuple<NodeId> tuple2 = TupleFactory.tuple(n1, n2, n3);
    Iterator<Tuple<NodeId>> iter = index.find(tuple2);
    assertTrue(iter.hasNext());
    iter.next();
    assertFalse(iter.hasNext());
}
Also used : NodeId(org.apache.jena.tdb.store.NodeId) TupleIndex(org.apache.jena.tdb.store.tupletable.TupleIndex) Tuple(org.apache.jena.atlas.lib.tuple.Tuple) BaseTest(org.apache.jena.atlas.junit.BaseTest) Test(org.junit.Test)

Example 27 with TupleIndex

use of org.apache.jena.tdb.store.tupletable.TupleIndex in project jena by apache.

the class AbstractTestTupleIndex method TupleIndexRecordSPO_5.

@Test
public void TupleIndexRecordSPO_5() {
    TupleIndex index = createIndex("SPO");
    add(index, n1, n2, n3);
    add(index, n1, n2, n4);
    Tuple<NodeId> tuple2 = TupleFactory.tuple(n1, n2, n3);
    Iterator<Tuple<NodeId>> iter = index.find(tuple2);
    Set<Tuple<NodeId>> x = Iter.toSet(iter);
    assertEquals(1, x.size());
    assertTrue(x.contains(TupleFactory.tuple(n1, n2, n3)));
    assertFalse(x.contains(TupleFactory.tuple(n1, n2, n4)));
}
Also used : NodeId(org.apache.jena.tdb.store.NodeId) TupleIndex(org.apache.jena.tdb.store.tupletable.TupleIndex) Tuple(org.apache.jena.atlas.lib.tuple.Tuple) BaseTest(org.apache.jena.atlas.junit.BaseTest) Test(org.junit.Test)

Example 28 with TupleIndex

use of org.apache.jena.tdb.store.tupletable.TupleIndex 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;
}
Also used : ColumnMap(org.apache.jena.tdb.lib.ColumnMap) TupleIndexRecord(org.apache.jena.tdb.store.tupletable.TupleIndexRecord) FileSet(org.apache.jena.tdb.base.file.FileSet) RangeIndex(org.apache.jena.tdb.index.RangeIndex) TupleIndex(org.apache.jena.tdb.store.tupletable.TupleIndex)

Aggregations

TupleIndex (org.apache.jena.tdb.store.tupletable.TupleIndex)28 NodeId (org.apache.jena.tdb.store.NodeId)20 Tuple (org.apache.jena.atlas.lib.tuple.Tuple)19 BaseTest (org.apache.jena.atlas.junit.BaseTest)18 Test (org.junit.Test)18 Location (org.apache.jena.tdb.base.file.Location)3 Timer (org.apache.jena.atlas.lib.Timer)2 RangeIndex (org.apache.jena.tdb.index.RangeIndex)2 ColumnMap (org.apache.jena.tdb.lib.ColumnMap)2 TupleIndexRecord (org.apache.jena.tdb.store.tupletable.TupleIndexRecord)2 Iterator (java.util.Iterator)1 Set (java.util.Set)1 Semaphore (java.util.concurrent.Semaphore)1 FileSet (org.apache.jena.tdb.base.file.FileSet)1 Record (org.apache.jena.tdb.base.record.Record)1 RecordFactory (org.apache.jena.tdb.base.record.RecordFactory)1 BPlusTree (org.apache.jena.tdb.index.bplustree.BPlusTree)1 NodeTable (org.apache.jena.tdb.store.nodetable.NodeTable)1 NodeTupleTable (org.apache.jena.tdb.store.nodetupletable.NodeTupleTable)1 NodeTupleTableConcrete (org.apache.jena.tdb.store.nodetupletable.NodeTupleTableConcrete)1