修改示例

This commit is contained in:
韩帅 2022-10-12 20:24:31 +08:00
parent b2ba5d58e4
commit 78fcbb5346
1 changed files with 11 additions and 5 deletions

View File

@ -31,8 +31,8 @@ public class SearcherTest {
} }
// 2、查询 // 2、查询
String ip = "1.2.3.4";
try { try {
String ip = "1.2.3.4";
long sTime = System.nanoTime(); long sTime = System.nanoTime();
String region = searcher.search(ip); String region = searcher.search(ip);
long cost = TimeUnit.NANOSECONDS.toMicros((long) (System.nanoTime() - sTime)); long cost = TimeUnit.NANOSECONDS.toMicros((long) (System.nanoTime() - sTime));
@ -42,7 +42,10 @@ public class SearcherTest {
} }
// 3、关闭资源 // 3、关闭资源
searcher.close(); try {
searcher.close();
} catch (Exception e) {
}
// 备注:并发使用,每个线程需要创建一个独立的 searcher 对象单独使用。 // 备注:并发使用,每个线程需要创建一个独立的 searcher 对象单独使用。
} }
@ -80,8 +83,8 @@ public class SearcherTest {
} }
// 3、查询 // 3、查询
String ip = "1.2.3.4";
try { try {
String ip = "1.2.3.4";
long sTime = System.nanoTime(); long sTime = System.nanoTime();
String region = searcher.search(ip); String region = searcher.search(ip);
long cost = TimeUnit.NANOSECONDS.toMicros((long) (System.nanoTime() - sTime)); long cost = TimeUnit.NANOSECONDS.toMicros((long) (System.nanoTime() - sTime));
@ -91,7 +94,10 @@ public class SearcherTest {
} }
// 4、关闭资源 // 4、关闭资源
searcher.close(); try {
searcher.close();
} catch (Exception e) {
}
// 备注:每个线程需要单独创建一个独立的 Searcher 对象,但是都共享全局的制度 vIndex 缓存。 // 备注:每个线程需要单独创建一个独立的 Searcher 对象,但是都共享全局的制度 vIndex 缓存。
} }
@ -129,8 +135,8 @@ public class SearcherTest {
} }
// 3、查询 // 3、查询
String ip = "1.2.3.4";
try { try {
String ip = "1.2.3.4";
long sTime = System.nanoTime(); long sTime = System.nanoTime();
String region = searcher.search(ip); String region = searcher.search(ip);
long cost = TimeUnit.NANOSECONDS.toMicros((long) (System.nanoTime() - sTime)); long cost = TimeUnit.NANOSECONDS.toMicros((long) (System.nanoTime() - sTime));