Add DbSearcher(dbConfig, dbBinStr) construct method specified by Wendal at https://gitee.com/lionsoul/ip2region/issues/IILFL

This commit is contained in:
lionsoul 2018-10-02 11:14:31 +08:00
parent 6027ba7146
commit 8494e1075d
1 changed files with 17 additions and 0 deletions

View File

@ -58,6 +58,23 @@ public class DbSearcher
raf = new RandomAccessFile(dbFile, "r"); 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 * get the region with a int ip address with memory binary search algorithm
* *