private DatasetGraphTDB determineBaseDataset() { // if ( DEBUG ) { // if ( !commitedAwaitingFlush.isEmpty() ) // System.out.print(commitedAwaitingFlush.size()) ; // } else { // System.out.print('_') ; // } DatasetGraphTDB dsg = baseDataset ; // But, if there are pending, committed transactions, use latest. if ( !commitedAwaitingFlush.isEmpty() ) dsg = commitedAwaitingFlush.get(commitedAwaitingFlush.size() - 1).getActiveDataset().getView() ; return dsg ; } private Transaction createTransaction(DatasetGraphTDB dsg, TxnType txnType, TxnType originalTxnType, String label) {
private DatasetGraphTxn createDSGTxn(DatasetGraphTDB dsg, Transaction txn, ReadWrite mode) { // A read transaction (if it has no lifecycle components) can be shared over all // read transactions at the same commit level. // lastreader if ( mode == ReadWrite.READ ) { // If a READ transaction, and a previously built one is cached, use it. DatasetGraphTDB dsgCached = currentReaderView.get() ; if ( dsgCached != null ) { // No components so we don't need to notify them. // We can just reuse the storage dataset. return new DatasetGraphTxn(dsgCached, txn) ; } } DatasetGraphTxn dsgTxn = new DatasetBuilderTxn(this, dsg).build(txn, mode); if ( mode == ReadWrite.READ ) { // If a READ transaction, cache the storage view. // This is cleared when a WRITE commits currentReaderView.set(dsgTxn.getView()) ; } return dsgTxn ; }
/** Get the current DatasetGraphTDB */ @Override public DatasetGraphTDB get() { if ( isInTransaction() ) { DatasetGraphTxn dsgTxn = dsgtxn.get() ; if ( dsgTxn == null ) throw new TDBTransactionException("In a transaction but no transactional DatasetGraph") ; return dsgTxn.getView() ; } if ( sConn.haveUsedInTransaction() ) throw new TDBTransactionException("Not in a transaction") ; // Never been used in a transaction - return underlying database for old // style (non-transactional) usage. return sConn.getBaseDataset() ; }