mirror of
https://github.com/netfun2000/ip2region.git
synced 2026-02-27 09:44:31 +08:00
maker constants define
This commit is contained in:
@@ -5,7 +5,62 @@
|
||||
// @Author Lion <chenxin619315@gmail.com>
|
||||
// @Date 2022/07/12
|
||||
|
||||
// --- Ip2Region v2.0 data structure
|
||||
//
|
||||
// +----------------+--------------------------+---------------+--------------+
|
||||
// | header space | vector speed up index | data payload | block index |
|
||||
// +----------------+--------------------------+---------------+--------------+
|
||||
// | 256 bytes | 512 KiB (fixed) | dynamic size | dynamic size |
|
||||
// +----------------+--------------------------+---------------+--------------+
|
||||
//
|
||||
// 1. padding space : for header info like block index ptr, version, release date eg ... or any other temporary needs.
|
||||
// -- 2bytes: version number, different version means structure update, it fixed to 2 for now
|
||||
// -- 2bytes: index algorithm code.
|
||||
// -- 4bytes: generate unix timestamp (version)
|
||||
// -- 4bytes: index block start ptr
|
||||
// -- 4bytes: index block end ptr
|
||||
//
|
||||
//
|
||||
// 2. data block : region or whatever data info.
|
||||
// 3. segment index block : binary index block.
|
||||
// 4. vector index block : fixed index info for block index search speed up.
|
||||
// space structure table:
|
||||
// -- 0 -> | 1rt super block | 2nd super block | 3rd super block | ... | 255th super block
|
||||
// -- 1 -> | 1rt super block | 2nd super block | 3rd super block | ... | 255th super block
|
||||
// -- 2 -> | 1rt super block | 2nd super block | 3rd super block | ... | 255th super block
|
||||
// -- ...
|
||||
// -- 255 -> | 1rt super block | 2nd super block | 3rd super block | ... | 255th super block
|
||||
//
|
||||
//
|
||||
// super block structure:
|
||||
// +-----------------------+----------------------+
|
||||
// | first index block ptr | last index block ptr |
|
||||
// +-----------------------+----------------------+
|
||||
//
|
||||
// data entry structure:
|
||||
// +--------------------+-----------------------+
|
||||
// | 2bytes (for desc) | dynamic length |
|
||||
// +--------------------+-----------------------+
|
||||
// data length whatever in bytes
|
||||
//
|
||||
// index entry structure
|
||||
// +------------+-----------+---------------+------------+
|
||||
// | 4bytes | 4bytes | 2bytes | 4 bytes |
|
||||
// +------------+-----------+---------------+------------+
|
||||
// start ip end ip data length data ptr
|
||||
|
||||
package org.lionsoul.ip2region.xdb;
|
||||
|
||||
public class Maker {
|
||||
// constants define
|
||||
public static final int VersionNo = 2;
|
||||
public static final int HeaderInfoLength = 256;
|
||||
public static final int VectorIndexRows = 256;
|
||||
public static final int VectorIndexCols = 256;
|
||||
public static final int VectorIndexSize = 8;
|
||||
public static final int SegmentIndexSize = 14;
|
||||
|
||||
public Maker() {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user