Add DbSearcher(dbConfig, dbBinStr) construct method specified by Wendal at https://gitee.com/lionsoul/ip2region/issues/IILFL
This commit is contained in:
parent
6027ba7146
commit
8494e1075d
|
|
@ -58,6 +58,23 @@ public class DbSearcher
|
|||
raf = new RandomAccessFile(dbFile, "r");
|
||||
}
|
||||
|
||||
/**
|
||||
* construct method with self-define std ip2region bianry string support
|
||||
* Thanks to the issue from Wendal at https://gitee.com/lionsoul/ip2region/issues/IILFL
|
||||
*
|
||||
* @param dbConfig
|
||||
* @param dbBinStr
|
||||
*/
|
||||
public DbSearcher(DbConfig dbConfig, byte[] dbBinStr)
|
||||
{
|
||||
this.dbConfig = dbConfig;
|
||||
this.dbBinStr = dbBinStr;
|
||||
|
||||
firstIndexPtr = Util.getIntLong(dbBinStr, 0);
|
||||
lastIndexPtr = Util.getIntLong(dbBinStr, 4);
|
||||
totalIndexBlocks = (int)((lastIndexPtr - firstIndexPtr)/IndexBlock.getIndexBlockLength()) + 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* get the region with a int ip address with memory binary search algorithm
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in New Issue