use of org.apache.jena.dboe.base.record.Record in project jena by apache.
the class RecordBuffer method toString.
@Override
public String toString() {
StringBuilder str = new StringBuilder(40000);
str.append(format("Len=%d Max=%d: ", numSlot, bb.limit() / slotLen));
// Print active slots as records.
for (int i = 0; i < numSlot; i++) {
if (i != 0)
str.append(" ");
Record r = _get(i);
str.append(r.toString());
}
// // Print empty slots
// for ( int i = numSlot*slotLen; i < maxSlot*slotLen ; i++ )
// {
// if ( i != 0 && i%slotLen == 0 )
// str.append(" ");
// byte b = bb.get(i);
// str.append(format("%02x", b));
// }
String s = str.toString();
return s;
}
use of org.apache.jena.dboe.base.record.Record in project jena by apache.
the class RecordBufferIterator method next.
@Override
public Record next() {
if (!hasNext())
throw new NoSuchElementException("RecordBufferIterator");
Record r = slot;
slot = null;
return r;
}
use of org.apache.jena.dboe.base.record.Record 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;
}
use of org.apache.jena.dboe.base.record.Record in project jena by apache.
the class TupleIndexRecord method findWorker.
private Iterator<Tuple<NodeId>> findWorker(Tuple<NodeId> patternNaturalOrder, boolean partialScanAllowed, boolean fullScanAllowed) {
if (Check) {
if (tupleLength != patternNaturalOrder.len())
throw new TDBException(String.format("Mismatch: tuple length %d / index for length %d", patternNaturalOrder.len(), tupleLength));
}
// Convert to index order.
Tuple<NodeId> pattern = tupleMap.map(patternNaturalOrder);
// Canonical form.
int numSlots = 0;
// Index of last leading pattern NodeId. Start less than numSlots-1
int leadingIdx = -2;
boolean leading = true;
// Records.
Record minRec = factory.createKeyOnly();
Record maxRec = factory.createKeyOnly();
// Set the prefixes.
for (int i = 0; i < pattern.len(); i++) {
NodeId X = pattern.get(i);
if (NodeId.isAny(X)) {
X = null;
// No longer seting leading key slots.
leading = false;
continue;
}
// if ( NodeId.isDoesNotExist(X) )
// return Iter.nullIterator();
numSlots++;
if (leading) {
leadingIdx = i;
NodeIdFactory.set(X, minRec.getKey(), i * SizeOfNodeId);
NodeIdFactory.set(X, maxRec.getKey(), i * SizeOfNodeId);
}
}
// Is it a simple existence test?
if (numSlots == pattern.len()) {
if (index.contains(minRec))
return new SingletonIterator<>(pattern);
else
return new NullIterator<>();
}
if (true) {
Iterator<Tuple<NodeId>> tuples;
if (leadingIdx < 0) {
if (!fullScanAllowed)
return null;
// Full scan necessary
tuples = index.iterator(null, null, recordMapper);
} else {
// Adjust the maxRec.
NodeId X = pattern.get(leadingIdx);
// Set the max Record to the leading NodeIds, +1.
// Example, SP? inclusive to S(P+1)? exclusive where ? is zero.
NodeIdFactory.setNext(X, maxRec.getKey(), leadingIdx * SizeOfNodeId);
tuples = index.iterator(minRec, maxRec, recordMapper);
}
if (leadingIdx < numSlots - 1) {
if (!partialScanAllowed)
return null;
// Didn't match all defined slots in request.
// Partial or full scan needed.
// pattern.unmap(colMap);
tuples = scan(tuples, patternNaturalOrder);
}
return tuples;
}
Iterator<Record> iter = null;
if (leadingIdx < 0) {
if (!fullScanAllowed)
return null;
// Full scan necessary
iter = index.iterator();
} else {
// Adjust the maxRec.
NodeId X = pattern.get(leadingIdx);
// Set the max Record to the leading NodeIds, +1.
// Example, SP? inclusive to S(P+1)? exclusive where ? is zero.
NodeIdFactory.setNext(X, maxRec.getKey(), leadingIdx * SizeOfNodeId);
iter = index.iterator(minRec, maxRec);
}
Iterator<Tuple<NodeId>> tuples = Iter.map(iter, item -> TupleLib.tuple(item, tupleMap));
if (leadingIdx < numSlots - 1) {
if (!partialScanAllowed)
return null;
// Didn't match all defined slots in request.
// Partial or full scan needed.
// pattern.unmap(colMap);
tuples = scan(tuples, patternNaturalOrder);
}
return tuples;
}
use of org.apache.jena.dboe.base.record.Record in project jena by apache.
the class BPTreeNodeBuilder method next.
@Override
public Pair<Integer, Record> next() {
if (!hasNext())
throw new NoSuchElementException();
Pair<Integer, Record> x = slot;
slot = null;
return x;
}
Aggregations