Package org.lionsoul.ip2region.xdb
Class Searcher
- java.lang.Object
-
- org.lionsoul.ip2region.xdb.Searcher
-
public class Searcher extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static intHeaderInfoLengthstatic intSegmentIndexSizestatic byte[]shiftIndexstatic intVectorIndexColsstatic intVectorIndexRowsstatic intVectorIndexSize
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static longcheckIP(String ip)voidclose()static intgetInt(byte[] b, int offset)static intgetInt2(byte[] b, int offset)static longgetIntLong(byte[] b, int offset)intgetIOCount()static byte[]loadContent(RandomAccessFile handle)static byte[]loadContentFromFile(String dbPath)static HeaderloadHeader(RandomAccessFile handle)static HeaderloadHeaderFromFile(String dbPath)static byte[]loadVectorIndex(RandomAccessFile handle)static byte[]loadVectorIndexFromFile(String dbPath)static Stringlong2ip(long ip)static SearchernewWithBuffer(byte[] cBuff)static SearchernewWithFileOnly(String dbPath)static SearchernewWithVectorIndex(String dbPath, byte[] vectorIndex)protected voidread(int offset, byte[] buffer)Stringsearch(long ip)Stringsearch(String ipStr)
-
-
-
Field Detail
-
HeaderInfoLength
public static final int HeaderInfoLength
- See Also:
- Constant Field Values
-
VectorIndexRows
public static final int VectorIndexRows
- See Also:
- Constant Field Values
-
VectorIndexCols
public static final int VectorIndexCols
- See Also:
- Constant Field Values
-
VectorIndexSize
public static final int VectorIndexSize
- See Also:
- Constant Field Values
-
SegmentIndexSize
public static final int SegmentIndexSize
- See Also:
- Constant Field Values
-
shiftIndex
public static final byte[] shiftIndex
-
-
Constructor Detail
-
Searcher
public Searcher(String dbFile, byte[] vectorIndex, byte[] cBuff) throws IOException
- Throws:
IOException
-
-
Method Detail
-
newWithFileOnly
public static Searcher newWithFileOnly(String dbPath) throws IOException
- Throws:
IOException
-
newWithVectorIndex
public static Searcher newWithVectorIndex(String dbPath, byte[] vectorIndex) throws IOException
- Throws:
IOException
-
newWithBuffer
public static Searcher newWithBuffer(byte[] cBuff) throws IOException
- Throws:
IOException
-
close
public void close() throws IOException- Throws:
IOException
-
getIOCount
public int getIOCount()
-
search
public String search(long ip) throws IOException
- Throws:
IOException
-
read
protected void read(int offset, byte[] buffer) throws IOException- Throws:
IOException
-
loadHeader
public static Header loadHeader(RandomAccessFile handle) throws IOException
- Throws:
IOException
-
loadHeaderFromFile
public static Header loadHeaderFromFile(String dbPath) throws IOException
- Throws:
IOException
-
loadVectorIndex
public static byte[] loadVectorIndex(RandomAccessFile handle) throws IOException
- Throws:
IOException
-
loadVectorIndexFromFile
public static byte[] loadVectorIndexFromFile(String dbPath) throws IOException
- Throws:
IOException
-
loadContent
public static byte[] loadContent(RandomAccessFile handle) throws IOException
- Throws:
IOException
-
loadContentFromFile
public static byte[] loadContentFromFile(String dbPath) throws IOException
- Throws:
IOException
-
getIntLong
public static long getIntLong(byte[] b, int offset)
-
getInt
public static int getInt(byte[] b, int offset)
-
getInt2
public static int getInt2(byte[] b, int offset)
-
long2ip
public static String long2ip(long ip)
-
-