Class Index

  • All Implemented Interfaces:
    java.lang.Iterable<byte[]>

    public class Index
    extends java.lang.Object
    implements java.lang.Iterable<byte[]>
      0 -> 0, 122 -> 1 123 -> 123, 244 -> 2 245 -> 245, ...
     
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      (package private) class  Index.Page  
    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) java.util.LinkedHashMap<java.lang.Integer,​Index.Page> cache  
      (package private) int capacity  
      (package private) java.nio.channels.FileChannel file  
      (package private) static int INDEX  
      (package private) int keySize  
      (package private) static int KEYSIZE  
      (package private) static int LEAF  
      (package private) static int MAGIC  
      private int nextPage  
      (package private) int pageSize  
      Index.Page root  
      (package private) java.nio.MappedByteBuffer settings  
      (package private) static int SIGNATURE  
      (package private) int valueSize  
    • Constructor Summary

      Constructors 
      Constructor Description
      Index​(java.io.File file, int keySize)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) Index.Page allocate​(boolean leaf)  
      void close()  
      (package private) Index.Page getPage​(int number)  
      void insert​(byte[] k, long v)  
      java.util.Iterator<byte[]> iterator()  
      long search​(byte[] k)  
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.lang.Iterable

        forEach, spliterator
    • Constructor Detail

      • Index

        public Index​(java.io.File file,
                     int keySize)
              throws java.io.IOException
        Throws:
        java.io.IOException
    • Method Detail

      • insert

        public void insert​(byte[] k,
                           long v)
                    throws java.lang.Exception
        Throws:
        java.lang.Exception
      • search

        public long search​(byte[] k)
                    throws java.lang.Exception
        Throws:
        java.lang.Exception
      • allocate

        Index.Page allocate​(boolean leaf)
                     throws java.io.IOException
        Throws:
        java.io.IOException
      • getPage

        Index.Page getPage​(int number)
                    throws java.io.IOException
        Throws:
        java.io.IOException
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • close

        public void close()
                   throws java.io.IOException
        Throws:
        java.io.IOException
      • iterator

        public java.util.Iterator<byte[]> iterator()
        Specified by:
        iterator in interface java.lang.Iterable<byte[]>