Examples of RecordIterator


Examples of uk.ac.open.kmi.smartproducts.sesame.sail.btree.RecordIterator

    ArrayList<NativeStatementIterator> perContextIterList = new ArrayList<NativeStatementIterator>(
        contextIDList.size());

    for (int contextID : contextIDList) {
      RecordIterator btreeIter;

      if (includeInferred) {
        // Get both explicit and inferred statements
        btreeIter = tripleStore.getTriples(subjID, predID, objID, contextID, readTransaction);
      }
View Full Code Here

Examples of uk.ac.open.kmi.smartproducts.sesame.sail.btree.RecordIterator

   */
  public final void storeRecords(RecordCache otherCache)
    throws IOException
  {
    if (recordCount.get() <= maxRecords.get()) {
      RecordIterator recIter = otherCache.getRecords();
      try {
        byte[] record;
        while ((record = recIter.next()) != null && recordCount.incrementAndGet() <= maxRecords.get()) {
          storeRecordInternal(record);
        }
      }
      finally {
        recIter.close();
      }
    }
  }
View Full Code Here

Examples of uk.ac.open.kmi.smartproducts.sesame.sail.btree.RecordIterator

        logger.debug("Initializing new index '{}'...", fieldSeq);

        TripleIndex addedIndex = new TripleIndex(fieldSeq);
        BTree addedBTree = addedIndex.getBTree();

        RecordIterator sourceIter = sourceIndex.getBTree().iterateAll();
        try {
          byte[] value = null;
          while ((value = sourceIter.next()) != null) {
            addedBTree.insert(value);
          }
        }
        finally {
          sourceIter.close();
        }

        currentIndexes.put(fieldSeq, addedIndex);
      }
View Full Code Here

Examples of uk.ac.open.kmi.smartproducts.sesame.sail.btree.RecordIterator

        flags |= TripleStore.EXPLICIT_FLAG;
        flagsMask |= TripleStore.EXPLICIT_FLAG;
      }
    }

    RecordIterator btreeIter = getTriples(subj, pred, obj, context, flags, flagsMask);

    if (readTransaction && explicit) {
      // Filter implicit statements from the result
      btreeIter = new ExplicitStatementFilter(btreeIter);
    }
View Full Code Here

Examples of uk.ac.open.kmi.smartproducts.sesame.sail.btree.RecordIterator

  }

  public int removeTriples(int subj, int pred, int obj, int context)
    throws IOException
  {
    RecordIterator iter = getTriples(subj, pred, obj, context, 0, 0);
    return removeTriples(iter);
  }
View Full Code Here

Examples of uk.ac.open.kmi.smartproducts.sesame.sail.btree.RecordIterator

   */
  public int removeTriples(int subj, int pred, int obj, int context, boolean explicit)
    throws IOException
  {
    byte flags = explicit ? EXPLICIT_FLAG : 0;
    RecordIterator iter = getTriples(subj, pred, obj, context, flags, EXPLICIT_FLAG);
    return removeTriples(iter);
  }
View Full Code Here

Examples of uk.ac.open.kmi.smartproducts.sesame.sail.btree.RecordIterator

      // Set the REMOVED flag by overwriting the affected records
      for (TripleIndex index : indexes) {
        BTree btree = index.getBTree();

        RecordIterator recIter = removedTriplesCache.getRecords();
        try {
          while ((data = recIter.next()) != null) {
            btree.insert(data);
          }
        }
        finally {
          recIter.close();
        }
      }
    }
    finally {
      removedTriplesCache.discard();
View Full Code Here

Examples of uk.ac.open.kmi.smartproducts.sesame.sail.btree.RecordIterator

    boolean validCache = updatedTriplesCache != null && updatedTriplesCache.isValid();

    for (TripleIndex index : indexes) {
      BTree btree = index.getBTree();

      RecordIterator iter;
      if (validCache) {
        // Use the cached set of updated triples
        iter = updatedTriplesCache.getRecords();
      }
      else {
        // Cache is invalid; too much updates(?). Iterate over all triples
        iter = btree.iterateAll();
      }

      try {
        byte[] data;
        while ((data = iter.next()) != null) {
          byte flags = data[FLAG_IDX];
          boolean wasAdded = (flags & ADDED_FLAG) != 0;
          boolean wasRemoved = (flags & REMOVED_FLAG) != 0;
          boolean wasToggled = (flags & TOGGLE_EXPLICIT_FLAG) != 0;

          if (wasRemoved) {
            btree.remove(data);
          }
          else if (wasAdded || wasToggled) {
            if (wasToggled) {
              data[FLAG_IDX] ^= EXPLICIT_FLAG;
            }
            if (wasAdded) {
              data[FLAG_IDX] ^= ADDED_FLAG;
            }

            if (validCache) {
              // We're iterating the cache
              btree.insert(data);
            }
            else {
              // We're iterating the BTree itself
              iter.set(data);
            }
          }
        }
      }
      finally {
        iter.close();
      }
    }

    if (updatedTriplesCache != null) {
      updatedTriplesCache.clear();
View Full Code Here

Examples of uk.ac.open.kmi.smartproducts.sesame.sail.btree.RecordIterator

    throws IOException
  {
    for (TripleIndex index : indexes) {
      System.out.println("Checking " + index + " index");
      BTree btree = index.getBTree();
      RecordIterator iter = btree.iterateAll();
      try {
        for (byte[] data = iter.next(); data != null; data = iter.next()) {
          byte flags = data[FLAG_IDX];
          boolean wasAdded = (flags & ADDED_FLAG) != 0;
          boolean wasRemoved = (flags & REMOVED_FLAG) != 0;
          boolean wasToggled = (flags & TOGGLE_EXPLICIT_FLAG) != 0;
          if (wasAdded || wasRemoved || wasToggled) {
            System.out.println("unexpected triple: " + ByteArrayUtil.toHexString(data));
          }
        }
      }
      finally {
        iter.close();
      }
    }
  }
View Full Code Here

Examples of uk.ac.open.kmi.smartproducts.sesame.sail.btree.RecordIterator

    byte txnFlagsMask = ~(ADDED_FLAG | REMOVED_FLAG | TOGGLE_EXPLICIT_FLAG);

    for (TripleIndex index : indexes) {
      BTree btree = index.getBTree();

      RecordIterator iter;
      if (validCache) {
        // Use the cached set of updated triples
        iter = updatedTriplesCache.getRecords();
      }
      else {
        // Cache is invalid; too much updates(?). Iterate over all triples
        iter = btree.iterateAll();
      }

      try {
        byte[] data = null;
        while ((data = iter.next()) != null) {
          byte flags = data[FLAG_IDX];
          boolean wasAdded = (flags & ADDED_FLAG) != 0;
          boolean wasRemoved = (flags & REMOVED_FLAG) != 0;
          boolean wasToggled = (flags & TOGGLE_EXPLICIT_FLAG) != 0;

          if (wasAdded) {
            btree.remove(data);
          }
          else {
            if (wasRemoved || wasToggled) {
              data[FLAG_IDX] &= txnFlagsMask;

              if (validCache) {
                // We're iterating the cache
                btree.insert(data);
              }
              else {
                // We're iterating the BTree itself
                iter.set(data);
              }
            }
          }
        }
      }
      finally {
        iter.close();
      }
    }

    if (updatedTriplesCache != null) {
      updatedTriplesCache.clear();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.