Package tokyocabinet

Examples of tokyocabinet.BDBCUR


 
  public List<byte[]> range(String key, int start, int end){
    if(start > end || end < 0 || start < 0)
      throw new RuntimeException("Invalid start and/or end context");
   
    BDBCUR cursor = this.goto_position(key, start);
   
    if(cursor == null)
      return null;
   
    int currentPos = 0;
    int distance   = end - start;
    List<byte[]> response = new ArrayList<byte[]>();
   
    while(currentPos <= distance){
      response.add(cursor.val());
     
      if(!cursor.next())
        break;
     
      currentPos++;
    }
   
View Full Code Here


   
    return response;
  }
 
  public int length(String key) {
    BDBCUR cursor = new BDBCUR(bdb);
   
    if(!cursor.jump(key))
      return 0;
   
    if(!Arrays.equals(cursor.key(),key.getBytes()))
      return 0;
   
    int length = 0;
    while(Arrays.equals(cursor.key(),key.getBytes())){
      length++;
     
      if(!cursor.next())
        return length;
    }
   
   
    return length;
View Full Code Here

TOP

Related Classes of tokyocabinet.BDBCUR

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.