segment contains and max ptr confirm

This commit is contained in:
lion 2025-09-11 15:18:43 +08:00
parent 6727987960
commit 23b2446736
2 changed files with 20 additions and 0 deletions

View File

@ -89,6 +89,11 @@ public class Segment {
return Util.ipToString(startIP) + "|" + Util.ipToString(endIP) + "|" + region;
}
// check if the an IP address in within this segment
public boolean contains(final byte[] ip) {
return Util.ipCompare(ip, startIP) >= 0 && Util.ipCompare(ip, endIP) <= 0;
}
// parser the Segment from an input string
public static Segment parse(String input) throws Exception {
final String[] ps = input.trim().split("\\|", 3);

View File

@ -0,0 +1,15 @@
package org.lionsoul.ip2region.xdb;
import org.junit.Test;
public class MakerTest {
private static final Log log = Log.getLogger(MakerTest.class);
@Test
public void testInit() {
log.infof("MaxFilePointer(%d bytes): %d", Maker.RuntimePtrSize, Maker.MaxFilePointer);
log.infof("MaxFilePoiner(5 bytes): %d", ((1L << (5 * 8)) - 1));
log.infof("MaxFilePoiner(6 bytes): %d", ((1L << (6 * 8)) - 1));
}
}