Package dovetaildb.bytes

Examples of dovetaildb.bytes.Bytes


  public Collection<String> getObjectKeys() {
    // TODO: optimize this a bit
    HashSet<String> keys = new HashSet<String>(terms.length);
    for(int termIdx=0; termIdx<this.numTerms; termIdx++) {
      Bytes term = terms[termIdx];
      int len = term.getLength();
      for(int i=1; i<len; i++) {
        if (term.get(i) == ':') {
          try {
            keys.add(new String(term.subBytes(1, i-1).getBytes(), "utf-8"));
          } catch (UnsupportedEncodingException e) {
            throw new RuntimeException(e);
          }
          break;
        }
View Full Code Here


  }
 
  public int getArrayLength() {
    int maxIdx = -1;
    for(int termIdx=0; termIdx<this.numTerms; termIdx++) {
      Bytes term = terms[termIdx];
      int sz = term.getLength();
      int idx = (term.get(sz-2)<<8) | term.get(sz-1);
      if (idx > maxIdx) maxIdx = idx;
    }
    return maxIdx+1;
 
View Full Code Here

    return maxIdx+1;
 
 
  public String getString() {
    try {
      Bytes term = terms[0];
      byte[] bytes = new byte[term.getLength()-1];
      term.writeBytes(1, bytes);
      return new String(bytes, "utf-8");
    } catch (UnsupportedEncodingException e) {
      throw new RuntimeException(e);
    }
  }
View Full Code Here

    default: throw new RuntimeException();
    }
  }
 
  public double getDouble() {
    Bytes term = terms[0];
    if (term.get(0) != 'n') throw new RuntimeException();
    long bits = (((long)term.get(1)) << 8 * 7) |
          (((long)term.get(2)&0xFF) << 8 * 6) |
          (((long)term.get(3)&0xFF) << 8 * 5) |
          (((long)term.get(4)&0xFF) << 8 * 4) |
          (((long)term.get(5)&0xFF) << 8 * 3) |
          (((long)term.get(6)&0xFF) << 8 * 2) |
          (((long)term.get(7)&0xFF) << 8 * 1) |
          (((long)term.get(8)&0xFF) << 8 * 0);
   
    // see sencode for why we do these bit manipulations:
    if ((bits & 0x8000000000000000L) == 0) {
      bits ^= 0xFFFFFFFFFFFFFFFFL;
    } else {
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.