rename searchByStr to search and default the region encode to utf-8

This commit is contained in:
Lion 2022-07-06 16:55:35 +08:00
parent 4a2fae35e6
commit cbf79d4682
2 changed files with 3 additions and 3 deletions

View File

@ -89,7 +89,7 @@ public class SearchTest {
try {
double sTime = System.nanoTime();
String region = searcher.searchByStr(line);
String region = searcher.search(line);
long cost = TimeUnit.NANOSECONDS.toMicros((long) (System.nanoTime() - sTime));
System.out.printf("{region: %s, ioCount: %d, took: %d μs}\n", region, searcher.getIOCount(), cost);
} catch (Exception e) {

View File

@ -71,7 +71,7 @@ public class Searcher {
return ioCount;
}
public String searchByStr(String ipStr) throws Exception {
public String search(String ipStr) throws Exception {
long ip = checkIP(ipStr);
return search(ip);
}
@ -135,7 +135,7 @@ public class Searcher {
// load and return the region data
final byte[] regionBuff = new byte[dataLen];
read(dataPtr, regionBuff);
return new String(regionBuff);
return new String(regionBuff, "utf-8");
}
protected void read(int offset, byte[] buffer) throws IOException {