static private TupleTable create2() { TupleIndex idxSPO = TestTupleIndexRecordDirect.create("SPO") ; TupleIndex x[] = { idxSPO } ; TupleTable table = new TupleTable(3, x) ; return table ; }
static void add(TupleTable table, NodeId x1, NodeId x2, NodeId x3) { Tuple<NodeId> tuple = tuple(x1, x2, x3) ; table.add(tuple) ; }
/** Find by NodeId. */ @Override public Iterator<Tuple<NodeId>> find(Tuple<NodeId> tuple) { // All find/*, except findAll, comes through this operation so startRead/finishRead/checkIterator only needs to happen here. try { startRead() ; // find worker - need also protect iterators that access the node table. Iterator<Tuple<NodeId>> iter = tupleTable.find(tuple) ; return iteratorControl(iter) ; } finally { finishRead() ; } }
private void dropSecondaryIndexes() { numIndexes = nodeTupleTable.getTupleTable().numIndexes(); primaryIndex = nodeTupleTable.getTupleTable().getIndex(0); secondaryIndexes = ArrayUtils.alloc(TupleIndex.class, numIndexes-1); System.arraycopy(nodeTupleTable.getTupleTable().getIndexes(), 1, secondaryIndexes, 0, numIndexes-1); // Set non-primary indexes to null. for ( int i = 1; i < numIndexes; i++ ) nodeTupleTable.getTupleTable().setTupleIndex(i, null); }
static Map<String, TupleIndex> indexMap(DatasetGraphTDB dsgtdb) { Map<String, TupleIndex> indexMap = new HashMap<>(); // All triple/quad indexes. Arrays.stream(dsgtdb.getTripleTable().getNodeTupleTable().getTupleTable().getIndexes()) .forEach(idx->indexMap.put(idx.getName(), idx)); Arrays.stream(dsgtdb.getQuadTable().getNodeTupleTable().getTupleTable().getIndexes()) .forEach(idx->indexMap.put(idx.getName(), idx)); return indexMap; }
t.getTupleTable().delete(array[i]) ; array[i] = null ;
/** Clear the tuple table - does not clear the node table */ @Override public void clear() { try { startWrite() ; tupleTable.clear() ; } finally { finishWrite() ; } }
@Override public final void close() { try { startWrite() ; tupleTable.close() ; nodeTable.close() ; } finally { finishWrite() ; } }
public TupleTable(int tupleLen, TupleIndex[] indexes) { this.tupleLen = tupleLen ; this.indexes = indexes ; if ( indexes[0] == null ) throw new TDBException("TupleTable: no primary index") ; for ( TupleIndex index : indexes ) { if ( index != null && index.getTupleLength() != tupleLen ) throw new TDBException("Incompatible index: "+index.getMappingStr()) ; } scanAllIndex = chooseScanAllIndex(tupleLen, indexes) ; }
@Override public Iterator<Tuple<NodeId>> findAll() { try { startRead() ; return iteratorControl(tupleTable.getIndex(0).all()) ; } finally { finishRead() ; } }
boolean anyGraph = (graphNode==null ? false : (Node.ANY.equals(graphNode))) ; int tupleLen = nodeTupleTable.getTupleTable().getTupleLen() ; if ( graphNode == null ) { if ( 3 != tupleLen )
public TDBDatasetDetails(DatasetGraphTDB dsg) { ntTop = dsg.getTripleTable().getNodeTupleTable().getNodeTable() ; tripleIndexes = ArrayUtils.copy(dsg.getTripleTable().getNodeTupleTable().getTupleTable().getIndexes()) ; quadIndexes = ArrayUtils.copy(dsg.getQuadTable().getNodeTupleTable().getTupleTable().getIndexes()) ; fillInNodeTableDetails() ; fillInIndexDetails() ; }
@Override public void deleteRow(Node... nodes) { try { startWrite() ; NodeId n[] = new NodeId[nodes.length] ; for (int i = 0; i < nodes.length; i++) { NodeId id = idForNode(nodes[i]) ; if (NodeId.isDoesNotExist(id)) return ; n[i] = id ; } Tuple<NodeId> t = TupleFactory.create(n) ; tupleTable.delete(t) ; } finally { finishWrite() ; } }
@Test public void createFind1() { TupleTable table = create() ; add(table, n1, n2, n3) ; // Cast removes compile lint warning. Tuple<NodeId> pat = tuple((NodeId)null, null, null) ; Iterator<Tuple<NodeId>> iter = table.find(pat) ; List<Tuple<NodeId>> x = Iter.toList(iter) ; int z = x.size() ; assertEquals(1, z) ; Tuple<NodeId> e1 = x.get(0) ; assertEquals(tuple(n1, n2, n3) , e1) ; }
static private TupleTable create2() { TupleIndex idxSPO = TestTupleIndexRecordDirect.create("SPO") ; TupleIndex x[] = { idxSPO } ; TupleTable table = new TupleTable(3, x) ; return table ; }
static void add(TupleTable table, NodeId x1, NodeId x2, NodeId x3) { Tuple<NodeId> tuple = tuple(x1, x2, x3) ; table.add(tuple) ; }
@Override public void startBulk() { TransactionCoordinator coordinator = CoLib.newCoordinator(); NodeTupleTable p = prefixes.getNodeTupleTable(); CoLib.add(coordinator, p.getNodeTable()); CoLib.add(coordinator, p.getTupleTable().getIndexes()); coordinator.start(); transaction = coordinator.begin(TxnType.WRITE); }
@Test public void createFind1() { TupleTable table = create() ; add(table, n1, n2, n3) ; // Cast removes compile lint warning. Tuple<NodeId> pat = tuple((NodeId)null, null, null) ; Iterator<Tuple<NodeId>> iter = table.find(pat) ; List<Tuple<NodeId>> x = Iter.toList(iter) ; int z = x.size() ; assertEquals(1, z) ; Tuple<NodeId> e1 = x.get(0) ; assertEquals(tuple(n1, n2, n3) , e1) ; }
public NodeTupleTableConcrete(int N, TupleIndex[] indexes, NodeTable nodeTable) { if (indexes.length == 0 || indexes[0] == null) throw new TDBException("A primary index is required") ; for (TupleIndex index : indexes) { if (N != index.getTupleLength()) throw new TDBException(format("Inconsistent: TupleTable width is %d but index %s is %d", N, index.getMappingStr(), index.getTupleLength())) ; } this.tupleTable = new TupleTable(N, indexes) ; this.nodeTable = nodeTable ; }
@Override public void addRow(Node... nodes) { try { startWrite() ; NodeId n[] = new NodeId[nodes.length] ; for (int i = 0; i < nodes.length; i++) n[i] = nodeTable.getAllocateNodeId(nodes[i]) ; Tuple<NodeId> t = TupleFactory.create(n) ; tupleTable.add(t) ; } finally { finishWrite() ; } }