Package dovetaildb.bytes

Examples of dovetaildb.bytes.Bytes


    QueryNode query = index.getRange(Range.OPEN_RANGE, index.getCurrentRevNum());
    ByteTable root = new ByteTable();
    if (query == null) return EMPTY_BYTE_ARRAY;
    SlicedBytes slice = new SlicedBytes(ArrayBytes.EMPTY_BYTES, 0);
    do {
      Bytes term = query.term();
      slice.reInitialize(query.term(), 0, term.getLength());
      root.count(slice, forkThreshold);
    } while(query.anyNext());
    long counted = root.hits;
    int numSlots = 1 << integerLogBase2RoundDown((long)(Math.sqrt(counted)/lengthToRowRatio));
    long minHits = (counted / numSlots) >> 8;
View Full Code Here


    }

    private PrefixUncompressedBytes anyMatchingTerm = new PrefixUncompressedBytes();
    @Override
    public Bytes findAnyMatching(long docId, Bytes prefix) {
      Bytes term;
      if (prefix.getLength() == 0) {
        term = subQueryNode.findAnyMatching(docId, prefix);
      } else {
        Bytes min = compress(prefix);
        byte[] prefixBytes = prefix.getBytes();
        Util.incrementBinary(prefixBytes);
        Bytes max = compress(new ArrayBytes(prefixBytes));
        Range r = new Range(ArrayBytes.EMPTY_BYTES, ArrayBytes.EMPTY_BYTES, ArrayBytes.EMPTY_BYTES, true, true);
        r.setBoundsAndExtractPrefix(min, max);
        term = subQueryNode.findAnyMatching(docId, r.getPrefix());
      }
      if (term == null) return null;
View Full Code Here

    @Override
    public boolean positionSet(long docId, Bytes prefix) {
      this.positionDoc = docId;
      this.positionPrefix = prefix;
      Bytes compressedPrefix = prefixCache.get(prefix);
      if (compressedPrefix == null) {
        compressedPrefix = findCompressedPrefixContaining(prefix);
        prefixCache.put(prefix, compressedPrefix);
      }
      boolean found = subQueryNode.positionSet(docId, compressedPrefix);
View Full Code Here

          return NOT_COLLAPSABLE;
        } else if (t2 == SlotTransition.SPECIALIZE) {
          // can work if it is an increment
          int len = prev.bytes.getLength();
          if (slot.hits == 0 && next.bytes.getLength() == len) {
            Bytes prevPrefix = SlicedBytes.make(prev.bytes, 0, len-1);
            Bytes nextPrefix = SlicedBytes.make(next.bytes, 0, len-1);
            if (prevPrefix.compareTo(nextPrefix) == 0 &&
                prev.bytes.get(len-1) + 1 == next.bytes.get(len-1)) {
              shiftHitsDown = true; // doesn't matter cause hits==0
            } else {
              return NOT_COLLAPSABLE;
View Full Code Here

      do {
        if (!query.positionSet(docId, ArrayBytes.EMPTY_BYTES)) {
          throw new RuntimeException();
        }
        do {
          Bytes nameTxn = query.term();
          int nameTxnLen = nameTxn.getLength();
          long txn = Util.beBytesToLong(nameTxn.getBytes(nameTxnLen - 8, 8), 0);
          if (txn > headTxn) headTxn = txn;
        } while (query.positionNext());
        docId = query.nextValidDocId(docId + 1);
      } while (docId < Long.MAX_VALUE);
//      do {
View Full Code Here

  }
 
  public synchronized void addRevsForTxn(long txn, Map<String, Long> revNums) {
    ArrayList<EditRec> edits = new ArrayList<EditRec>(revNums.size());
    for(Map.Entry<String,Long> bagRev : revNums.entrySet()) {
      Bytes bytes = termForTxnBag(bagRev.getKey(), txn);
      edits.add(new EditRec(bagRev.getValue(), bytes, false));
    }
    map.commitNewRev(edits);
    if (txn > headTxn) headTxn = txn;
    nextReserved = false;
View Full Code Here

  }
 
  public static void applyDocEdits(List<Edit> edits, BoundedDocRec head, RecBuffer<MemDocRec> result) {
    // prereq: edits are in doc id, then term order
    int editLength = edits.size();
    Bytes prefix = (head == null) ? ArrayBytes.EMPTY_BYTES : head.getPrefix();
    int prefixLen = prefix.getLength();
    BoundedDocRec cur = head;
    int editIdx = 0;
    Edit edit = null;
    if (!edits.isEmpty()) edit = edits.get(0);
    while(edit != null && cur != null) {
View Full Code Here

 
 
  public static void TERM_VER_applyDocEdits(List<Edit> edits, BoundedDocRec head, RecBuffer<MemDocRec> result) {
    // prereq: edits are in doc id, then term order
    int editLength = edits.size();
    Bytes prefix = (head == null) ? ArrayBytes.EMPTY_BYTES : head.getPrefix();
    int prefixLen = prefix.getLength();
    BoundedDocRec cur = head;
    int editIdx = 0;
    Edit edit = null;
    if (!edits.isEmpty()) edit = edits.get(0);
    while(edit != null && cur != null) {
View Full Code Here

  }
 
  public static ArrayList<EditRec> popTermBytes(ArrayList<EditRec> editBuffer) {
    ArrayList<EditRec> newTermBytes = new ArrayList<EditRec>();
    for(EditRec edit : editBuffer) {
      Bytes term = edit.term;
      term = term.subBytes(1, term.getLength()-1);
      newTermBytes.add(new EditRec(edit.docId, term, edit.isDeletion));
    }
    return newTermBytes;
  }
View Full Code Here

    for(int i=0; i<len; i++) {
      for(TokenRec rec : table.tokenRecs) {
        if (rec.token >= prefix.get(i)) {
          if (rec.token > prefix.get(i)) return null;
          if (rec.tokenTable==null) {
            Bytes pre = new SlicedBytes(prefix, 0, i+1);
            pre = new ArrayBytes(pre.getBytes()); // optimize
            RangeQueryNode ret = new BlueSteelPostingListQuery(pre, rec.segmentPush);
            return FilteredRangeQueryNode.make(ret, prefix, term1, term2, isExclusive1, isExclusive2);
          }
          table = rec.tokenTable;
          bos.write(rec.token);
View Full Code Here

TOP

Related Classes of dovetaildb.bytes.Bytes

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.