Search in sources :

Example 1 with TupleMap

use of org.apache.jena.atlas.lib.tuple.TupleMap in project jena by apache.

the class TestTupleMap method map_transforms.

@Test
public void map_transforms() {
    TupleMap x = TupleMap.create("SPO", "POS");
    List<Integer> listGet = x.transformPut();
    List<Integer> listGetExpected = Arrays.asList(2, 0, 1);
    assertEquals(listGetExpected, listGet);
    List<Integer> listPut = x.transformGet();
    List<Integer> listPutExpected = Arrays.asList(1, 2, 0);
    assertEquals(listPutExpected, listPut);
}
Also used : TupleMap(org.apache.jena.atlas.lib.tuple.TupleMap) Test(org.junit.Test)

Example 2 with TupleMap

use of org.apache.jena.atlas.lib.tuple.TupleMap in project jena by apache.

the class TestTupleMap method map_slot_1.

@Test
public void map_slot_1() {
    TupleMap tmap = TupleMap.create("SPO", "POS");
    Tuple<String> tuple = TupleFactory.tuple("S", "P", "O");
    assertEquals("P", tmap.mapSlot(0, tuple));
    assertEquals("O", tmap.mapSlot(1, tuple));
    assertEquals("S", tmap.mapSlot(2, tuple));
    Tuple<String> tuple1 = tmap.map(tuple);
    assertEquals("S", tmap.unmapSlot(0, tuple1));
    assertEquals("P", tmap.unmapSlot(1, tuple1));
    assertEquals("O", tmap.unmapSlot(2, tuple1));
}
Also used : TupleMap(org.apache.jena.atlas.lib.tuple.TupleMap) Test(org.junit.Test)

Example 3 with TupleMap

use of org.apache.jena.atlas.lib.tuple.TupleMap in project jena by apache.

the class TestTupleMap method map_tuple_4.

@Test
public void map_tuple_4() {
    String[] x = { "G", "S", "P", "O" };
    String[] y = { "O", "S", "P", "G" };
    TupleMap tmap = TupleMap.create("Test", x, y);
    Tuple<String> tuple = TupleFactory.tuple(x);
    Tuple<String> mapped = tmap.map(tuple);
    Tuple<String> expected = TupleFactory.tuple(y);
    assertEquals(expected, mapped);
    Tuple<String> unmapped = tmap.unmap(mapped);
    assertEquals(TupleFactory.tuple(x), unmapped);
}
Also used : TupleMap(org.apache.jena.atlas.lib.tuple.TupleMap) Test(org.junit.Test)

Example 4 with TupleMap

use of org.apache.jena.atlas.lib.tuple.TupleMap in project jena by apache.

the class TestTupleMap method map_array_2.

@Test
public void map_array_2() {
    // (0,1,2) -> (2,0,1) S->2 etc
    // so (0,1,2) <- (1,2,0)
    TupleMap x = TupleMap.create("SPO", "POS");
    String[] array = { "Y", "Z", "X" };
    // The index 0 comes from position 3.
    assertEquals("X", x.unmapSlot(0, array));
    assertEquals("Y", x.unmapSlot(1, array));
    assertEquals("Z", x.unmapSlot(2, array));
}
Also used : TupleMap(org.apache.jena.atlas.lib.tuple.TupleMap) Test(org.junit.Test)

Example 5 with TupleMap

use of org.apache.jena.atlas.lib.tuple.TupleMap in project jena by apache.

the class TestTupleMap method map_tuple_2.

@Test
public void map_tuple_2() {
    TupleMap x = TupleMap.create("SPO", "POS");
    Tuple<String> tuple = TupleFactory.tuple("S", "P", "O");
    Tuple<String> mapped = x.map(tuple);
    Tuple<String> expected = TupleFactory.tuple("P", "O", "S");
    assertEquals(expected, mapped);
}
Also used : TupleMap(org.apache.jena.atlas.lib.tuple.TupleMap) Test(org.junit.Test)

Aggregations

TupleMap (org.apache.jena.atlas.lib.tuple.TupleMap)20 Test (org.junit.Test)16 RangeIndex (org.apache.jena.dboe.index.RangeIndex)3 RecordFactory (org.apache.jena.dboe.base.record.RecordFactory)2 IndexParams (org.apache.jena.dboe.index.IndexParams)2 TupleIndex (org.apache.jena.tdb2.store.tupletable.TupleIndex)2 BlockMgr (org.apache.jena.dboe.base.block.BlockMgr)1 BufferChannel (org.apache.jena.dboe.base.file.BufferChannel)1 FileSet (org.apache.jena.dboe.base.file.FileSet)1 Location (org.apache.jena.dboe.base.file.Location)1 Record (org.apache.jena.dboe.base.record.Record)1 BPlusTree (org.apache.jena.dboe.trans.bplustree.BPlusTree)1 BPlusTreeParams (org.apache.jena.dboe.trans.bplustree.BPlusTreeParams)1 ProgressIterator (org.apache.jena.system.progress.ProgressIterator)1 ProgressMonitor (org.apache.jena.system.progress.ProgressMonitor)1 TDBException (org.apache.jena.tdb2.TDBException)1 DatasetGraphTDB (org.apache.jena.tdb2.store.DatasetGraphTDB)1 TupleIndexRecord (org.apache.jena.tdb2.store.tupletable.TupleIndexRecord)1