use of org.apache.jena.atlas.lib.tuple.TupleMap in project jena by apache.
the class TestTupleMap method map_tuple_3.
@Test
public void map_tuple_3() {
TupleMap tmap = TupleMap.create("GSPO", "OSPG");
Tuple<String> tuple = TupleFactory.tuple("G", "S", "P", "O");
Tuple<String> mapped = tmap.map(tuple);
Tuple<String> expected = TupleFactory.tuple("O", "S", "P", "G");
assertEquals(expected, mapped);
Tuple<String> unmapped = tmap.unmap(mapped);
assertEquals(TupleFactory.tuple("G", "S", "P", "O"), unmapped);
}
use of org.apache.jena.atlas.lib.tuple.TupleMap in project jena by apache.
the class TestTupleMap method map_array_1.
@Test
public void map_array_1() {
TupleMap x = TupleMap.create("SPO", "POS");
String[] array = { "X", "Y", "Z" };
// The 0th item after mapping is the "1"
assertEquals("Y", x.mapSlot(0, array));
assertEquals("Z", x.mapSlot(1, array));
assertEquals("X", x.mapSlot(2, array));
String[] array2 = new String[array.length];
x.map(array, array2);
assertArrayEquals(new String[] { "Y", "Z", "X" }, array2);
String[] array3 = new String[array.length];
x.unmap(array2, array3);
assertArrayEquals(array, array3);
}
use of org.apache.jena.atlas.lib.tuple.TupleMap in project jena by apache.
the class TestTupleMap method compile_1.
@Test
public void compile_1() {
TupleMap map = TupleMap.create("SPO", "POS");
// SPO -> POS
// col 0 goes to col 2
// col 1 goes to col 0
// col 2 goes to col 1
Integer[] expectedPut = { 2, 0, 1 };
assertEquals(Arrays.asList(expectedPut), map.transformPut());
Integer[] expectedGet = { 1, 2, 0 };
assertEquals(Arrays.asList(expectedGet), map.transformGet());
}
use of org.apache.jena.atlas.lib.tuple.TupleMap in project jena by apache.
the class TestTupleIndexRecordDirect method create.
static TupleIndexRecord create(String description) {
IndexParams indexParams = StoreParams.getDftStoreParams();
RangeIndex rIdx = BuildTestLib.buildRangeIndex(FileSet.mem(), factory, indexParams);
TupleMap tmap = TupleMap.create("SPO", description);
TupleIndexRecord index = new TupleIndexRecord(3, tmap, description, factory, rIdx);
return index;
}
use of org.apache.jena.atlas.lib.tuple.TupleMap in project jena by apache.
the class ProcBuildIndexX method indexBuilder.
private static long indexBuilder(DatasetGraph dsg, InputStream input, String indexName) {
long tickPoint = BulkLoaderX.DataTick;
int superTick = BulkLoaderX.DataSuperTick;
// Location of storage, not the DB.
DatasetGraphTDB dsgtdb = TDBInternal.getDatasetGraphTDB(dsg);
Location location = dsgtdb.getLocation();
int keyLength = SystemTDB.SizeOfNodeId * indexName.length();
int valueLength = 0;
// The name is the order.
String primary = indexName;
String primaryOrder;
int dftKeyLength;
int dftValueLength;
int tupleLength = indexName.length();
TupleIndex index;
if (tupleLength == 3) {
primaryOrder = Names.primaryIndexTriples;
dftKeyLength = SystemTDB.LenIndexTripleRecord;
dftValueLength = 0;
// Find index.
index = findIndex(dsgtdb.getTripleTable().getNodeTupleTable().getTupleTable().getIndexes(), indexName);
} else if (tupleLength == 4) {
primaryOrder = Names.primaryIndexQuads;
dftKeyLength = SystemTDB.LenIndexQuadRecord;
dftValueLength = 0;
index = findIndex(dsgtdb.getQuadTable().getNodeTupleTable().getTupleTable().getIndexes(), indexName);
} else {
throw new TDBException("Index name: " + indexName);
}
TupleMap colMap = TupleMap.create(primaryOrder, indexName);
int readCacheSize = 10;
int writeCacheSize = 100;
int blockSize = SystemTDB.BlockSize;
RecordFactory recordFactory = new RecordFactory(dftKeyLength, dftValueLength);
int order = BPlusTreeParams.calcOrder(blockSize, recordFactory);
BPlusTreeParams bptParams = new BPlusTreeParams(order, recordFactory);
int blockSizeNodes = blockSize;
int blockSizeRecords = blockSize;
FileSet destination = new FileSet(location, indexName);
BufferChannel blkState = FileFactory.createBufferChannel(destination, Names.extBptState);
BlockMgr blkMgrNodes = BlockMgrFactory.create(destination, Names.extBptTree, blockSizeNodes, readCacheSize, writeCacheSize);
BlockMgr blkMgrRecords = BlockMgrFactory.create(destination, Names.extBptRecords, blockSizeRecords, readCacheSize, writeCacheSize);
int rowBlock = 1000;
Iterator<Record> iter = new RecordsFromInput(input, tupleLength, colMap, rowBlock);
// ProgressMonitor.
ProgressMonitor monitor = ProgressMonitorOutput.create(BulkLoaderX.LOG_Index, indexName, tickPoint, superTick);
ProgressIterator<Record> iter2 = new ProgressIterator<>(iter, monitor);
monitor.start();
BPlusTree bpt2 = BPlusTreeRewriter.packIntoBPlusTree(iter2, bptParams, recordFactory, blkState, blkMgrNodes, blkMgrRecords);
bpt2.close();
monitor.finish();
// [BULK] End stage.
long count = monitor.getTicks();
return count;
}
Aggregations