Package org.openrdf.sail.memory.model

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


  }

  private void readStatement(boolean hasContext, boolean isExplicit, DataInputStream dataIn)
    throws IOException, ClassCastException
  {
    MemResource memSubj = (MemResource)readValue(dataIn);
    MemURI memPred = (MemURI)readValue(dataIn);
    MemValue memObj = (MemValue)readValue(dataIn);
    MemResource memContext = null;
    if (hasContext) {
      memContext = (MemResource)readValue(dataIn);
    }

    MemStatement st = new MemStatement(memSubj, memPred, memObj, memContext, isExplicit,
View Full Code Here


        URI pred = (URI)getConstantValue(sp.getPredicateVar());
        Value obj = getConstantValue(sp.getObjectVar());
        Resource context = (Resource)getConstantValue(sp.getContextVar());

        // Perform look-ups for value-equivalents of the specified values
        MemResource memSubj = vf.getMemResource(subj);
        MemURI memPred = vf.getMemURI(pred);
        MemValue memObj = vf.getMemValue(obj);
        MemResource memContext = vf.getMemResource(context);

        if (subj != null && memSubj == null || pred != null && memPred == null || obj != null
            && memObj == null || context != null && memContext == null)
        {
          // non-existent subject, predicate, object or context
          return 0.0;
        }

        // Search for the smallest list that can be used by the iterator
        List<Integer> listSizes = new ArrayList<Integer>(4);
        if (memSubj != null) {
          listSizes.add(memSubj.getSubjectStatementCount());
        }
        if (memPred != null) {
          listSizes.add(memPred.getPredicateStatementCount());
        }
        if (memObj != null) {
          listSizes.add(memObj.getObjectStatementCount());
        }
        if (memContext != null) {
          listSizes.add(memContext.getContextStatementCount());
        }

        double cardinality;

        if (listSizes.isEmpty()) {
View Full Code Here

   */
  protected Cursor<MemStatement> createStatementIterator(Resource subj, URI pred, Value obj,
      boolean explicitOnly, int snapshot, ReadMode readMode, MemValueFactory vf, Resource... contexts)
  {
    // Perform look-ups for value-equivalents of the specified values
    MemResource memSubj = vf.getMemResource(subj);
    if (subj != null && memSubj == null) {
      // non-existent subject
      return new EmptyCursor<MemStatement>();
    }

    MemURI memPred = vf.getMemURI(pred);
    if (pred != null && memPred == null) {
      // non-existent predicate
      return new EmptyCursor<MemStatement>();
    }

    MemValue memObj = vf.getMemValue(obj);
    if (obj != null && memObj == null) {
      // 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);
        }
      }

View Full Code Here

  {
    assert txnStatements != null;
    boolean newValueCreated = false;

    // Get or create MemValues for the operands
    MemResource memSubj = vf.getMemResource(subj);
    if (memSubj == null) {
      memSubj = vf.createMemResource(subj);
      newValueCreated = true;
    }
    MemURI memPred = vf.getMemURI(pred);
    if (memPred == null) {
      memPred = vf.createMemURI(pred);
      newValueCreated = true;
    }
    MemValue memObj = vf.getMemValue(obj);
    if (memObj == null) {
      memObj = vf.createMemValue(obj);
      newValueCreated = true;
    }
    MemResource memContext = vf.getMemResource(context);
    if (context != null && memContext == null) {
      memContext = vf.createMemResource(context);
      newValueCreated = true;
    }
View Full Code Here

    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);
        }
View Full Code Here

  protected <X extends Exception> CloseableIteration<MemStatement, X> createStatementIterator(
      Class<X> excClass, Resource subj, URI pred, Value obj, boolean explicitOnly, int snapshot,
      ReadMode readMode, Resource... contexts)
  {
    // Perform look-ups for value-equivalents of the specified values
    MemResource memSubj = valueFactory.getMemResource(subj);
    if (subj != null && memSubj == null) {
      // non-existent subject
      return new EmptyIteration<MemStatement, X>();
    }

    MemURI memPred = valueFactory.getMemURI(pred);
    if (pred != null && memPred == null) {
      // non-existent predicate
      return new EmptyIteration<MemStatement, X>();
    }

    MemValue memObj = valueFactory.getMemValue(obj);
    if (obj != null && memObj == null) {
      // 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);
        }
      }

View Full Code Here

    throws SailException
  {
    boolean newValueCreated = false;

    // Get or create MemValues for the operands
    MemResource memSubj = valueFactory.getMemResource(subj);
    if (memSubj == null) {
      memSubj = valueFactory.createMemResource(subj);
      newValueCreated = true;
    }
    MemURI memPred = valueFactory.getMemURI(pred);
    if (memPred == null) {
      memPred = valueFactory.createMemURI(pred);
      newValueCreated = true;
    }
    MemValue memObj = valueFactory.getMemValue(obj);
    if (memObj == null) {
      memObj = valueFactory.createMemValue(obj);
      newValueCreated = true;
    }
    MemResource memContext = valueFactory.getMemResource(context);
    if (context != null && memContext == null) {
      memContext = valueFactory.createMemResource(context);
      newValueCreated = true;
    }
View Full Code Here

  private static void readStatement(MemoryStore store, boolean hasContext, boolean isExplicit,
      DataInputStream dataIn)
    throws IOException, ClassCastException
  {
    MemResource memSubj = (MemResource)readValue(store, dataIn);
    MemURI memPred = (MemURI)readValue(store, dataIn);
    MemValue memObj = (MemValue)readValue(store, dataIn);
    MemResource memContext = null;
    if (hasContext) {
      memContext = (MemResource)readValue(store, dataIn);
    }

    MemStatement st = new MemStatement(memSubj, memPred, memObj, memContext, isExplicit, store.getCurrentSnapshot());
View Full Code Here

        Resource context = (Resource)getConstantValue(sp.getContextVar());

        MemValueFactory valueFactory = store.getValueFactory();

        // Perform look-ups for value-equivalents of the specified values
        MemResource memSubj = valueFactory.getMemResource(subj);
        MemURI memPred = valueFactory.getMemURI(pred);
        MemValue memObj = valueFactory.getMemValue(obj);
        MemResource memContext = valueFactory.getMemResource(context);

        if (subj != null && memSubj == null || pred != null && memPred == null || obj != null
            && memObj == null || context != null && memContext == null)
        {
          // non-existent subject, predicate, object or context
          cardinality = 0;
          return;
        }

        // Search for the smallest list that can be used by the iterator
        List<Integer> listSizes = new ArrayList<Integer>(4);
        if (memSubj != null) {
          listSizes.add(memSubj.getSubjectStatementCount());
        }
        if (memPred != null) {
          listSizes.add(memPred.getPredicateStatementCount());
        }
        if (memObj != null) {
          listSizes.add(memObj.getObjectStatementCount());
        }
        if (memContext != null) {
          listSizes.add(memContext.getContextStatementCount());
        }

        if (listSizes.isEmpty()) {
          cardinality = store.size();
View Full Code Here

TOP

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

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.