Search in sources :

Example 1 with ColumnMap

use of org.apache.jena.tdb.lib.ColumnMap in project jena by apache.

the class TestColumnMap method map2.

@Test
public void map2() {
    String[] x = { "G", "S", "P", "O" };
    String[] y = { "O", "S", "P", "G" };
    ColumnMap cmap = new ColumnMap("Test", x, y);
    Tuple<String> tuple = tuple(x);
    Tuple<String> mapped = cmap.map(tuple);
    Tuple<String> expected = tuple(y);
    assertEquals(expected, mapped);
    Tuple<String> unmapped = cmap.unmap(mapped);
    assertEquals(tuple(x), unmapped);
}
Also used : ColumnMap(org.apache.jena.tdb.lib.ColumnMap) BaseTest(org.apache.jena.atlas.junit.BaseTest) Test(org.junit.Test)

Example 2 with ColumnMap

use of org.apache.jena.tdb.lib.ColumnMap in project jena by apache.

the class TestColumnMap method remap4.

@Test
public void remap4() {
    ColumnMap x = new ColumnMap("POS", 2, 0, 1);
    Tuple<String> tuple = tuple("S", "P", "O");
    Tuple<String> tuple2 = x.map(tuple);
    tuple2 = x.unmap(tuple2);
    assertEquals(tuple, tuple2);
}
Also used : ColumnMap(org.apache.jena.tdb.lib.ColumnMap) BaseTest(org.apache.jena.atlas.junit.BaseTest) Test(org.junit.Test)

Example 3 with ColumnMap

use of org.apache.jena.tdb.lib.ColumnMap in project jena by apache.

the class TestColumnMap method remap2.

@Test
public void remap2() {
    ColumnMap x = new ColumnMap("SPO->POS", 2, 0, 1);
    Integer[] array = { 0, 1, 2 };
    // The index 1 comes from position 0.
    assertEquals(Integer.valueOf(1), x.fetchSlot(0, array));
    assertEquals(Integer.valueOf(2), x.fetchSlot(1, array));
    assertEquals(Integer.valueOf(0), x.fetchSlot(2, array));
}
Also used : ColumnMap(org.apache.jena.tdb.lib.ColumnMap) BaseTest(org.apache.jena.atlas.junit.BaseTest) Test(org.junit.Test)

Example 4 with ColumnMap

use of org.apache.jena.tdb.lib.ColumnMap in project jena by apache.

the class TestColumnMap method remap1.

@Test
public void remap1() {
    // S->2 etc
    ColumnMap x = new ColumnMap("SPO->POS", 2, 0, 1);
    Integer[] array = { 0, 1, 2 };
    assertEquals(Integer.valueOf(2), x.mapSlot(0, array));
    assertEquals(Integer.valueOf(0), x.mapSlot(1, array));
    assertEquals(Integer.valueOf(1), x.mapSlot(2, array));
}
Also used : ColumnMap(org.apache.jena.tdb.lib.ColumnMap) BaseTest(org.apache.jena.atlas.junit.BaseTest) Test(org.junit.Test)

Example 5 with ColumnMap

use of org.apache.jena.tdb.lib.ColumnMap in project jena by apache.

the class TestColumnMap method remap3.

@Test
public void remap3() {
    ColumnMap x = new ColumnMap("POS", 2, 0, 1);
    Tuple<String> tuple = tuple("S", "P", "O");
    Tuple<String> mapped = x.map(tuple);
    Tuple<String> expected = tuple("P", "O", "S");
    assertEquals(expected, mapped);
}
Also used : ColumnMap(org.apache.jena.tdb.lib.ColumnMap) BaseTest(org.apache.jena.atlas.junit.BaseTest) Test(org.junit.Test)

Aggregations

ColumnMap (org.apache.jena.tdb.lib.ColumnMap)14 BaseTest (org.apache.jena.atlas.junit.BaseTest)6 Test (org.junit.Test)6 FileSet (org.apache.jena.tdb.base.file.FileSet)5 RangeIndex (org.apache.jena.tdb.index.RangeIndex)5 RecordFactory (org.apache.jena.tdb.base.record.RecordFactory)4 Location (org.apache.jena.tdb.base.file.Location)3 Record (org.apache.jena.tdb.base.record.Record)3 IndexParams (org.apache.jena.tdb.index.IndexParams)3 BPlusTree (org.apache.jena.tdb.index.bplustree.BPlusTree)3 TupleIndexRecord (org.apache.jena.tdb.store.tupletable.TupleIndexRecord)3 InputStream (java.io.InputStream)2 AtlasException (org.apache.jena.atlas.AtlasException)2 BlockMgr (org.apache.jena.tdb.base.block.BlockMgr)2 BPlusTreeParams (org.apache.jena.tdb.index.bplustree.BPlusTreeParams)2 TupleIndex (org.apache.jena.tdb.store.tupletable.TupleIndex)2 Tuple (org.apache.jena.atlas.lib.tuple.Tuple)1 TDBException (org.apache.jena.tdb.TDBException)1 NodeId (org.apache.jena.tdb.store.NodeId)1 ModLocation (tdb.cmdline.ModLocation)1