Package org.openrdf.sail.memory.model

Examples of org.openrdf.sail.memory.model.MemStatementList


  }

  private boolean isContextResource(MemResource memResource, int snapshot, ReadMode readMode)
    throws StoreException
  {
    MemStatementList contextStatements = memResource.getContextStatementList();

    // Filter resources that are not used as context identifier
    if (contextStatements.size() == 0) {
      return false;
    }

    // Filter more thoroughly by considering snapshot and read-mode parameters
    MemStatementCursor iter = new MemStatementCursor(contextStatements, null, null, null, false, snapshot,
View Full Code Here


      // non-existent object
      return new EmptyCursor<MemStatement>();
    }

    MemResource[] memContexts;
    MemStatementList smallestList;

    contexts = OpenRDFUtil.notNull(contexts);
    if (contexts.length == 0) {
      memContexts = new MemResource[0];
      smallestList = statements;
    }
    else if (contexts.length == 1 && contexts[0] != null) {
      MemResource memContext = vf.getMemResource(contexts[0]);
      if (memContext == null) {
        // non-existent context
        return new EmptyCursor<MemStatement>();
      }

      memContexts = new MemResource[] { memContext };
      smallestList = memContext.getContextStatementList();
    }
    else {
      Set<MemResource> contextSet = new LinkedHashSet<MemResource>(2 * contexts.length);

      for (Resource context : contexts) {
        MemResource memContext = vf.getMemResource(context);
        if (context == null || memContext != null) {
          contextSet.add(memContext);
        }
      }

      if (contextSet.isEmpty()) {
        // no known contexts specified
        return new EmptyCursor<MemStatement>();
      }

      memContexts = contextSet.toArray(new MemResource[contextSet.size()]);
      smallestList = statements;
    }

    if (memSubj != null) {
      MemStatementList l = memSubj.getSubjectStatementList();
      if (l.size() < smallestList.size()) {
        smallestList = l;
      }
    }

    if (memPred != null) {
      MemStatementList l = memPred.getPredicateStatementList();
      if (l.size() < smallestList.size()) {
        smallestList = l;
      }
    }

    if (memObj != null) {
      MemStatementList l = memObj.getObjectStatementList();
      if (l.size() < smallestList.size()) {
        smallestList = l;
      }
    }

    return new MemStatementCursor(smallestList, memSubj, memPred, memObj, explicitOnly, snapshot, readMode,
View Full Code Here

  protected void cleanSnapshots()
    throws InterruptedException
  {
    // System.out.println("cleanSnapshots() starting...");
    // long startTime = System.currentTimeMillis();
    MemStatementList statements = this.statements;

    if (statements == null) {
      // Store has been shut down
      return;
    }

    // Sets used to keep track of which lists have already been processed
    HashSet<MemValue> processedSubjects = new HashSet<MemValue>();
    HashSet<MemValue> processedPredicates = new HashSet<MemValue>();
    HashSet<MemValue> processedObjects = new HashSet<MemValue>();
    HashSet<MemValue> processedContexts = new HashSet<MemValue>();

    Lock stLock = statementListLockManager.getWriteLock();
    try {
      for (int i = statements.size() - 1; i >= 0; i--) {
        MemStatement st = statements.get(i);

        if (st.getTillSnapshot() <= currentSnapshot) {
          MemResource subj = st.getSubject();
          if (processedSubjects.add(subj)) {
            subj.cleanSnapshotsFromSubjectStatements(currentSnapshot);
          }

          MemURI pred = st.getPredicate();
          if (processedPredicates.add(pred)) {
            pred.cleanSnapshotsFromPredicateStatements(currentSnapshot);
          }

          MemValue obj = st.getObject();
          if (processedObjects.add(obj)) {
            obj.cleanSnapshotsFromObjectStatements(currentSnapshot);
          }

          MemResource context = st.getContext();
          if (context != null && processedContexts.add(context)) {
            context.cleanSnapshotsFromContextStatements(currentSnapshot);
          }

          // stale statement
          statements.remove(i);
        }
        else {
          // Reset snapshot
          st.setSinceSnapshot(1);
        }
View Full Code Here

    statementListLockManager = new ReadPrefReadWriteLockManager(trackLocks);
    txnLockManager = new ExclusiveLockManager(trackLocks);
    namespaceStore = new MemNamespaceStore();

    valueFactory = new MemValueFactory();
    statements = new MemStatementList(256);
    currentSnapshot = 1;

    if (persist) {
      dataFile = new File(getDataDir(), DATA_FILE_NAME);
View Full Code Here

      // non-existent object
      return new EmptyIteration<MemStatement, X>();
    }

    MemResource[] memContexts;
    MemStatementList smallestList;

    if (contexts.length == 0) {
      memContexts = new MemResource[0];
      smallestList = statements;
    }
    else if (contexts.length == 1 && contexts[0] != null) {
      MemResource memContext = valueFactory.getMemResource(contexts[0]);
      if (memContext == null) {
        // non-existent context
        return new EmptyIteration<MemStatement, X>();
      }

      memContexts = new MemResource[] { memContext };
      smallestList = memContext.getContextStatementList();
    }
    else {
      Set<MemResource> contextSet = new LinkedHashSet<MemResource>(2 * contexts.length);

      for (Resource context : contexts) {
        MemResource memContext = valueFactory.getMemResource(context);
        if (context == null || memContext != null) {
          contextSet.add(memContext);
        }
      }

      if (contextSet.isEmpty()) {
        // no known contexts specified
        return new EmptyIteration<MemStatement, X>();
      }

      memContexts = contextSet.toArray(new MemResource[contextSet.size()]);
      smallestList = statements;
    }

    if (memSubj != null) {
      MemStatementList l = memSubj.getSubjectStatementList();
      if (l.size() < smallestList.size()) {
        smallestList = l;
      }
    }

    if (memPred != null) {
      MemStatementList l = memPred.getPredicateStatementList();
      if (l.size() < smallestList.size()) {
        smallestList = l;
      }
    }

    if (memObj != null) {
      MemStatementList l = memObj.getObjectStatementList();
      if (l.size() < smallestList.size()) {
        smallestList = l;
      }
    }

    return new MemStatementIterator<X>(smallestList, memSubj, memPred, memObj, explicitOnly, snapshot,
View Full Code Here

   * @throws InterruptedException
   */
  protected void cleanSnapshots()
    throws InterruptedException
  {
    MemStatementList statements = this.statements;

    if (statements == null) {
      // Store has been shut down
      return;
    }

    Lock stLock = statementListLockManager.getWriteLock();
    try {
      for (int i = statements.size() - 1; i >= 0; i--) {
        MemStatement st = statements.get(i);

        if (st.getTillSnapshot() <= currentSnapshot) {
          // stale statement
          st.removeFromComponentLists();
          statements.remove(i);
        }
        else {
          // Reset snapshot
          st.setSinceSnapshot(1);
        }
View Full Code Here

        @Override
        protected boolean accept(MemResource memResource)
          throws SailException
        {
          MemStatementList contextStatements = memResource.getContextStatementList();

          // Filter resources that are not used as context identifier
          if (contextStatements.size() == 0) {
            return false;
          }

          // Filter more thoroughly by considering snapshot and read-mode
          // parameters
View Full Code Here

      v.add(node);
      if (stepIndex + 1 == path.steps.length){
    pathInstances.add(v);
      }
      else {
    MemStatementList properties = getPropertyArcs((MemResource)node, path.steps[stepIndex+1].axis);
    for (int i=0;i<properties.size();i++){
        selectProperty(path, stepIndex+1, properties.get(i), v, pathInstances);
    }
      }
  }
    }
View Full Code Here

      v.add(node);
      if (stepIndex + 1 == path.steps.length){
    pathInstances.add(v);
      }
      else {
    MemStatementList properties = getLPropertyArcs((MemValue)node, path.steps[stepIndex+1].axis);
    for (int i=0;i<properties.size();i++){
        selectProperty(path, stepIndex+1, properties.get(i), v, pathInstances);
    }
      }
  }
    }
View Full Code Here

      }
  }
  if (nodeOrArc instanceof Resource){// the path should start with an arc location step
      // path expr should be evaluated either on incoming or outgoing statements
      // whether we evaluate it on incoming or outgoing arcs depends on the 1st location step's axis
      MemStatementList properties = getPropertyArcs((MemResource)nodeOrArc, expr.steps[0].axis);
      for (int i=0;i<properties.size();i++){
    selectProperty(expr, startStepIndex, properties.get(i), selectedElements, pathInstances);
      }
  }
  else if (nodeOrArc instanceof Statement){// the path should start with a node location step
      // path expr should be evaluated either on subject or object of statement
      // depending on the 1st location step's axis
View Full Code Here

TOP

Related Classes of org.openrdf.sail.memory.model.MemStatementList

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.