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);
}
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);
}
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));
}
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));
}
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);
}
Aggregations