.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.43)
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings. \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote. \*(C+ will
.\" give a nicer C++. Capital omega is used to do unbreakable dashes and
.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
.\" nothing in troff, for use with C<>.
.tr \(*W-
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
. ds -- \(*W-
. ds PI pi
. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
. ds L" ""
. ds R" ""
. ds C` ""
. ds C' ""
'br\}
.el\{\
. ds -- \|\(em\|
. ds PI \(*p
. ds L" ``
. ds R" ''
. ds C`
. ds C'
'br\}
.\"
.\" Escape single quotes in literal strings from groff's Unicode transform.
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.\"
.\" If the F register is >0, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
.\" entries marked with X<> in POD. Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.\"
.\" Avoid warning from groff about undefined register 'F'.
.de IX
..
.nr rF 0
.if \n(.g .if rF .nr rF 1
.if (\n(rF:(\n(.g==0)) \{\
. if \nF \{\
. de IX
. tm Index:\\$1\t\\n%\t"\\$2"
..
. if !\nF==2 \{\
. nr % 0
. nr F 2
. \}
. \}
.\}
.rr rF
.\"
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
.\" Fear. Run. Save yourself. No user-serviceable parts.
. \" fudge factors for nroff and troff
.if n \{\
. ds #H 0
. ds #V .8m
. ds #F .3m
. ds #[ \f1
. ds #] \fP
.\}
.if t \{\
. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
. ds #V .6m
. ds #F 0
. ds #[ \&
. ds #] \&
.\}
. \" simple accents for nroff and troff
.if n \{\
. ds ' \&
. ds ` \&
. ds ^ \&
. ds , \&
. ds ~ ~
. ds /
.\}
.if t \{\
. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
.\}
. \" troff and (daisy-wheel) nroff accents
.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
.ds ae a\h'-(\w'a'u*4/10)'e
.ds Ae A\h'-(\w'A'u*4/10)'E
. \" corrections for vroff
.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
. \" for low resolution devices (crt and lpr)
.if \n(.H>23 .if \n(.V>19 \
\{\
. ds : e
. ds 8 ss
. ds o a
. ds d- d\h'-1'\(ga
. ds D- D\h'-1'\(hy
. ds th \o'bp'
. ds Th \o'LP'
. ds ae ae
. ds Ae AE
.\}
.rm #[ #] #H #V #F C
.\" ========================================================================
.\"
.IX Title "MaxMind::DB::Writer::Tree 3pm"
.TH MaxMind::DB::Writer::Tree 3pm "2022-10-20" "perl v5.36.0" "User Contributed Perl Documentation"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
.nh
.SH "NAME"
MaxMind::DB::Writer::Tree \- Tree representing a MaxMind DB database in memory \- then write it to a file
.SH "VERSION"
.IX Header "VERSION"
version 0.300003
.SH "SYNOPSIS"
.IX Header "SYNOPSIS"
.Vb 1
\& use MaxMind::DB::Writer::Tree;
\&
\& my %types = (
\& color => \*(Aqutf8_string\*(Aq,
\& dogs => [ \*(Aqarray\*(Aq, \*(Aqutf8_string\*(Aq ],
\& size => \*(Aquint16\*(Aq,
\& );
\&
\& my $tree = MaxMind::DB::Writer::Tree\->new(
\& ip_version => 6,
\& record_size => 24,
\& database_type => \*(AqMy\-IP\-Data\*(Aq,
\& languages => [\*(Aqen\*(Aq],
\& description => { en => \*(AqMy database of IP data\*(Aq },
\& map_key_type_callback => sub { $types{ $_[0] } },
\& );
\&
\& $tree\->insert_network(
\& \*(Aq8.8.8.0/24\*(Aq,
\& {
\& color => \*(Aqblue\*(Aq,
\& dogs => [ \*(AqFido\*(Aq, \*(AqMs. Pretty Paws\*(Aq ],
\& size => 42,
\& },
\& );
\&
\& open my $fh, \*(Aq>:raw\*(Aq, \*(Aq/path/to/my\-ip\-data.mmdb\*(Aq;
\& $tree\->write_tree($fh);
.Ve
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
This is the main class you'll use to write MaxMind \s-1DB\s0 database
files . This class represents the
database in memory. Once you've created the full tree you can write to a file.
.SH "API"
.IX Header "API"
This class provides the following methods:
.SS "MaxMind::DB::Writer::Tree\->\fBnew()\fP"
.IX Subsection "MaxMind::DB::Writer::Tree->new()"
This creates a new tree object. The constructor accepts the following
parameters:
.IP "\(bu" 4
ip_version
.Sp
The \s-1IP\s0 version for the database. It must be 4 or 6.
.Sp
This parameter is required.
.IP "\(bu" 4
record_size
.Sp
This is the record size in \fIbits\fR. This should be one of 24, 28, 32 (in
theory any number divisible by 4 up to 128 will work but the available readers
all expect 24\-32).
.Sp
This parameter is required.
.IP "\(bu" 4
database_type
.Sp
This is a string containing the database type. This can be anything,
really. MaxMind uses strings like \*(L"GeoIP2\-City\*(R", \*(L"GeoIP2\-Country\*(R", etc.
.Sp
This parameter is required.
.IP "\(bu" 4
languages
.Sp
This should be an array reference of languages used in the database, like
\&\*(L"en\*(R", \*(L"zh-TW\*(R", etc. This is useful as metadata for database readers and end users.
.Sp
This parameter is optional.
.IP "\(bu" 4
description
.Sp
This is a hashref where the keys are language names and the values are
descriptions of the database in that language. For example, you might have
something like:
.Sp
.Vb 4
\& {
\& en => \*(AqMy IP data\*(Aq,
\& fr => q{Mon Data d\*(AqIP},
\& }
.Ve
.Sp
This parameter is required.
.IP "\(bu" 4
map_key_type_callback
.Sp
This is a subroutine reference that is called in order to determine how to
store each value in a map (hash) data structure. See \*(L"\s-1DATA TYPES\*(R"\s0 below for
more details.
.Sp
This parameter is required.
.IP "\(bu" 4
merge_record_collisions
.Sp
By default, when an insert collides with a previous insert, the new data
simply overwrites the old data where the two networks overlap.
.Sp
If this is set to true, then on a collision, the writer will merge the old
data with the new data. The merge strategy employed is controlled by the
\&\f(CW\*(C`merge_strategy\*(C'\fR attribute, described below.
.Sp
This parameter is optional. It defaults to false unless \f(CW\*(C`merge_strategy\*(C'\fR is
set to something other than \f(CW\*(C`none\*(C'\fR.
.Sp
This parameter is deprecated. New code should just set \f(CW\*(C`merge_strategy\*(C'\fR
directly.
.Sp
\&\fBThis parameter is deprecated. Use \f(CB\*(C`merge_strategy\*(C'\fB instead.\fR
.IP "\(bu" 4
merge_strategy
.Sp
Controls what merge strategy is employed.
.RS 4
.IP "\(bu" 8
none
.Sp
No merging will be done. \f(CW\*(C`merge_record_collisions\*(C'\fR must either be not set or
set to false.
.IP "\(bu" 8
toplevel
.Sp
If both data structures are hashrefs then the data from the top level keys in
the new data structure are copied over to the existing data structure,
potentially replacing any existing values for existing keys completely.
.IP "\(bu" 8
recurse
.Sp
Recursively merges the new data structure with the old data structure. Hash
values and array elements are either \- in the case of simple values \- replaced
with the new values, or \- in the case of complex structures \- have their values
recursively merged.
.Sp
For example if this data is originally inserted for an \s-1IP\s0 range:
.Sp
.Vb 7
\& {
\& families => [ {
\& husband => \*(AqFred\*(Aq,
\& wife => \*(AqWilma\*(Aq,
\& }, ],
\& year => 1960,
\& }
.Ve
.Sp
And then this subsequent data is inserted for a range covered by the previous
\&\s-1IP\s0 range:
.Sp
.Vb 11
\& {
\& families => [ {
\& wife => \*(AqWilma\*(Aq,
\& child => \*(AqPebbles\*(Aq,
\& }, {
\& husband => \*(AqBarney\*(Aq,
\& wife => \*(AqBetty\*(Aq,
\& child => \*(AqBamm\-Bamm\*(Aq,
\& }, ],
\& company => \*(AqHanna\-Barbera Productions\*(Aq,
\& }
.Ve
.Sp
Then querying within the range will produce the results:
.Sp
.Vb 10
\& {
\& families => [ {
\& husband => \*(AqFred\*(Aq,
\& wife => \*(AqWilma\*(Aq, # note replaced value
\& child => \*(AqPebbles\*(Aq,
\& }, {
\& husband => \*(AqBarney\*(Aq,
\& wife => \*(AqBetty\*(Aq,
\& child => \*(AqBamm\-Bamm\*(Aq,
\& }, ],
\& year => 1960,
\& company => \*(AqHanna\-Barbera Productions\*(Aq,
\& }
.Ve
.IP "\(bu" 8
add-only-if-parent-exists
.Sp
With this merge strategy, data will only be inserted when there is already a
record for the network (or sub-network). Similarly, when merging the data
record with an existing data record, no new hash or array references will be
created within the data record for the new data. For instance, if the original
data record is \f(CW\*(C`{parent_a =\*(C'\fR {sibling => 1}}> and \f(CW\*(C`{parent_a =\*(C'\fR {child_a =>
1}, parent_b => {child_b => 1}}> is inserted, only \f(CW\*(C`child_a\*(C'\fR, not \f(CW\*(C`child_b\*(C'\fR,
will appear in the merged record.
.Sp
This option is intended to be used when inserting data that supplements
existing data but that is not independently useful.
.RE
.RS 4
.Sp
In all merge strategies attempting to merge two differing data structures
causes an exception.
.Sp
This parameter is optional. If \f(CW\*(C`merge_record_collisions\*(C'\fR is true, this
defaults to \f(CW\*(C`toplevel\*(C'\fR; otherwise, it defaults to \f(CW\*(C`none\*(C'\fR.
.RE
.IP "\(bu" 4
alias_ipv6_to_ipv4
.Sp
If this is true then the final database will map some IPv6 ranges to the IPv4
range. These ranges are:
.RS 4
.IP "\(bu" 8
::ffff:0:0/96
.Sp
This is the IPv4\-mapped IPv6 range
.IP "\(bu" 8
2001::/32
.Sp
This is the Teredo range. Note that lookups for Teredo ranges will find the
Teredo server's IPv4 address, not the client's IPv4.
.IP "\(bu" 8
2002::/16
.Sp
This is the 6to4 range
.RE
.RS 4
.Sp
When aliasing is enabled, insertions into the aliased locations will throw an
exception. Inserting a network containing them does not throw an exception, but
no information will be stored for the aliased locations.
.Sp
To insert an IPv4 address, insert it using IPv4 notation or insert
directly into ::/96.
.Sp
Aliased nodes are \fInot\fR followed when merging nodes. Only merges into the
original IPv4 location, ::/96, will be followed.
.Sp
This parameter is optional. It defaults to false.
.RE
.IP "\(bu" 4
remove_reserved_networks
.Sp
If this is true, reserved networks may not be inserted.
.Sp
Attempts to insert these networks or any inside them will be silently ignored.
Inserting a network containing them does not throw an exception, but no
information will be stored for the reserved sections.
.Sp
Reserved networks that are globally routable to an individual device, such as
Teredo, may still be added.
.Sp
This parameter is optional. It defaults to true.
.ie n .SS "$tree\->insert_network( $network, $data, $additional_args )"
.el .SS "\f(CW$tree\fP\->insert_network( \f(CW$network\fP, \f(CW$data\fP, \f(CW$additional_args\fP )"
.IX Subsection "$tree->insert_network( $network, $data, $additional_args )"
This method expects two parameters. The first is a network in \s-1CIDR\s0 notation.
The second can be any Perl data structure (except a coderef, glob, or
filehandle).
.PP
The \f(CW$data\fR payload is encoded according to the MaxMind \s-1DB\s0 database format
spec . The short overview is that
anything that can be encoded in \s-1JSON\s0 can be stored in an \s-1MMDB\s0 file. It can
also handle unsigned 64\-bit and 128\-bit integers if they are passed as
Math::UInt128 objects.
.PP
\&\f(CW$additional_args\fR is a hash reference containing additional arguments that
change the behavior of the insert. The following arguments are supported:
.IP "\(bu" 3
\&\f(CW\*(C`merge_strategy\*(C'\fR
.Sp
When set, the tree's default merge strategy will be overridden for the
insertion with this merge strategy.
.IP "\(bu" 3
\&\f(CW\*(C`force_overwrite\*(C'\fR
.Sp
This make the merge strategy for the insert \f(CW\*(C`none\*(C'\fR.
.Sp
\&\fBThis option is deprecated.\fR
.IP "\(bu" 3
\&\f(CW\*(C`insert_only_if_parent_exists\*(C'\fR
.Sp
This make the merge strategy for the insert \f(CW\*(C`add\-only\-if\-parent\-exists\*(C'\fR.
.Sp
\&\fBThis option is deprecated.\fR
.PP
\fIInsert Order, Merging, and Overwriting\fR
.IX Subsection "Insert Order, Merging, and Overwriting"
.PP
When \f(CW\*(C`merge_strategy\*(C'\fR is \fInone\fR, the last insert \*(L"wins\*(R". This
means that if you insert \f(CW\*(C`1.2.3.255/32\*(C'\fR and then \f(CW\*(C`1.2.3.0/24\*(C'\fR, the data for
\&\f(CW\*(C`1.2.3.255/24\*(C'\fR will overwrite the data you previously inserted for
\&\f(CW\*(C`1.2.3.255/232\*(C'\fR. On the other hand, if you insert \f(CW\*(C`1.2.3.255/32\*(C'\fR last, then
the tree will be split so that the \f(CW\*(C`1.2.3.0 \- 1.2.3.254\*(C'\fR range has different
data than \f(CW1.2.3.255\fR.
.PP
In this scenario, if you want to make sure that no data is overwritten then
you need to sort your input by network prefix length.
.PP
When \f(CW\*(C`merge_strategy\*(C'\fR is not \fInone\fR, then records will be merged based on
the particular strategy. For instance, the \f(CW\*(C`1.2.3.255/32\*(C'\fR network will end up
with its data plus the data provided for the \f(CW\*(C`1.2.3.0/24\*(C'\fR network, while
\&\f(CW\*(C`1.2.3.0 \- 1.2.3.254\*(C'\fR will have the expected data. The merge strategy can be
changed on a per-insert basis by using the \f(CW\*(C`merge_strategy\*(C'\fR argument when
inserting a network as discussed above.
.ie n .SS "$tree\->insert_range( $first_ip, $last_ip, $data, $additional_args )"
.el .SS "\f(CW$tree\fP\->insert_range( \f(CW$first_ip\fP, \f(CW$last_ip\fP, \f(CW$data\fP, \f(CW$additional_args\fP )"
.IX Subsection "$tree->insert_range( $first_ip, $last_ip, $data, $additional_args )"
This method is similar to \f(CW\*(C`insert_network()\*(C'\fR, except that it takes an \s-1IP\s0
range rather than a network. The first parameter is the first \s-1IP\s0 address in
the range. The second is the last \s-1IP\s0 address in the range. The third is a
Perl data structure containing the data to be inserted. The final parameter
are additional arguments, as outlined for \f(CW\*(C`insert_network()\*(C'\fR.
.ie n .SS "$tree\->remove_network( $network )"
.el .SS "\f(CW$tree\fP\->remove_network( \f(CW$network\fP )"
.IX Subsection "$tree->remove_network( $network )"
This method removes the network from the database. It takes one parameter, the
network in \s-1CIDR\s0 notation.
.ie n .SS "$tree\->write_tree($fh)"
.el .SS "\f(CW$tree\fP\->write_tree($fh)"
.IX Subsection "$tree->write_tree($fh)"
Given a filehandle, this method writes the contents of the tree as a MaxMind
\&\s-1DB\s0 database to that filehandle.
.ie n .SS "$tree\->iterate($object)"
.el .SS "\f(CW$tree\fP\->iterate($object)"
.IX Subsection "$tree->iterate($object)"
This method iterates over the tree by calling methods on the passed
object. The object must have at least one of the following three methods:
\&\f(CW\*(C`process_empty_record\*(C'\fR, \f(CW\*(C`process_node_record\*(C'\fR, \f(CW\*(C`process_data_record\*(C'\fR.
.PP
The iteration is done in depth-first order, which means that it visits each
network in order.
.PP
Each method on the object is called with the following position parameters:
.IP "\(bu" 4
The node number as a 64\-bit number.
.IP "\(bu" 4
A boolean indicating whether or not this is the right or left record for the
node. True for right, false for left.
.IP "\(bu" 4
The first \s-1IP\s0 number in the node's network as a 128\-bit number.
.IP "\(bu" 4
The prefix length for the node's network.
.IP "\(bu" 4
The first \s-1IP\s0 number in the record's network as a 128\-bit number.
.IP "\(bu" 4
The prefix length for the record's network.
.PP
If the record is a data record, the final argument will be the Perl data
structure associated with the record.
.PP
The record's network is what matches with a given data structure for data
records.
.PP
For node (and alias) records, the final argument will be the number of the
node that this record points to.
.PP
For empty records, there are no additional arguments.
.ie n .SS "$tree\->freeze_tree($filename)"
.el .SS "\f(CW$tree\fP\->freeze_tree($filename)"
.IX Subsection "$tree->freeze_tree($filename)"
Given a file name, this method freezes the tree to that file. Unlike the
\&\f(CW\*(C`write_tree()\*(C'\fR method, this method does write out a MaxMind \s-1DB\s0 file. Instead,
it writes out something that can be quickly thawed via the \f(CW\*(C`MaxMind::DB::Writer::Tree\->new_from_frozen_tree\*(C'\fR constructor. This is useful if
you want to pass the in-memory representation of the tree between processes.
.ie n .SS "$tree\->\fBip_version()\fP"
.el .SS "\f(CW$tree\fP\->\fBip_version()\fP"
.IX Subsection "$tree->ip_version()"
Returns the tree's \s-1IP\s0 version, as passed to the constructor.
.ie n .SS "$tree\->\fBrecord_size()\fP"
.el .SS "\f(CW$tree\fP\->\fBrecord_size()\fP"
.IX Subsection "$tree->record_size()"
Returns the tree's record size, as passed to the constructor.
.ie n .SS "$tree\->\fBmerge_record_collisions()\fP"
.el .SS "\f(CW$tree\fP\->\fBmerge_record_collisions()\fP"
.IX Subsection "$tree->merge_record_collisions()"
Returns a boolean indicating whether the tree will merge colliding records, as
determined by the merge strategy.
.PP
\&\fBThis is deprecated.\fR
.ie n .SS "$tree\->\fBmerge_strategy()\fP"
.el .SS "\f(CW$tree\fP\->\fBmerge_strategy()\fP"
.IX Subsection "$tree->merge_strategy()"
Returns the merge strategy used when two records collide.
.ie n .SS "$tree\->\fBmap_key_type_callback()\fP"
.el .SS "\f(CW$tree\fP\->\fBmap_key_type_callback()\fP"
.IX Subsection "$tree->map_key_type_callback()"
Returns the callback used to determine the type of a map's values, as passed
to the constructor.
.ie n .SS "$tree\->\fBdatabase_type()\fP"
.el .SS "\f(CW$tree\fP\->\fBdatabase_type()\fP"
.IX Subsection "$tree->database_type()"
Returns the tree's database type, as passed to the constructor.
.ie n .SS "$tree\->\fBlanguages()\fP"
.el .SS "\f(CW$tree\fP\->\fBlanguages()\fP"
.IX Subsection "$tree->languages()"
Returns the tree's languages, as passed to the constructor.
.ie n .SS "$tree\->\fBdescription()\fP"
.el .SS "\f(CW$tree\fP\->\fBdescription()\fP"
.IX Subsection "$tree->description()"
Returns the tree's description hashref, as passed to the constructor.
.ie n .SS "$tree\->\fBalias_ipv6_to_ipv4()\fP"
.el .SS "\f(CW$tree\fP\->\fBalias_ipv6_to_ipv4()\fP"
.IX Subsection "$tree->alias_ipv6_to_ipv4()"
Returns a boolean indicating whether the tree will alias some IPv6 ranges to
their corresponding IPv4 ranges when the tree is written to disk.
.SS "MaxMind::DB::Writer::Tree\->\fBnew_from_frozen_tree()\fP"
.IX Subsection "MaxMind::DB::Writer::Tree->new_from_frozen_tree()"
This method constructs a tree from a file containing a frozen tree.
.PP
This method accepts the following parameters:
.IP "\(bu" 4
filename
.Sp
The filename containing the frozen tree.
.Sp
This parameter is required.
.IP "\(bu" 4
map_key_type_callback
.Sp
This is a subroutine reference that is called in order to determine how to
store each value in a map (hash) data structure. See \*(L"\s-1DATA TYPES\*(R"\s0 below for
more details.
.Sp
This needs to be passed because subroutine references cannot be reliably
serialized and restored between processes.
.Sp
This parameter is required.
.IP "\(bu" 4
database_type
.Sp
Override the \f(CW\*(C` of the frozen tree. This accepts a string of
the same form as the \f(CW\*(C` constructor.
.Sp
This parameter is optional.
.IP "\(bu" 4
description
.Sp
Override the \f(CW\*(C` of the frozen tree. This accepts a hashref of
the same form as the \f(CW\*(C` constructor.
.Sp
This parameter is optional.
.IP "\(bu" 4
merge_strategy
.Sp
Override the \f(CW\*(C` setting for the frozen tree.
.Sp
This parameter is optional.
.SS "Caveat for Freeze/Thaw"
.IX Subsection "Caveat for Freeze/Thaw"
The frozen tree is more or less the raw C data structures written to disk. As
such, it is very much not portable, and your ability to thaw a tree on a
machine not identical to the one on which it was written is not guaranteed.
.PP
In addition, there is no guarantee that the freeze/thaw format will be stable
across different versions of this module.
.SH "DATA TYPES"
.IX Header "DATA TYPES"
The MaxMind \s-1DB\s0 file format is strongly typed. Because Perl is not strongly
typed, you will need to explicitly specify the types for each piece of
data. Currently, this class assumes that your top-level data structure for an
\&\s-1IP\s0 address will always be a map (hash). You can then provide a
\&\f(CW\*(C`map_key_type_callback\*(C'\fR subroutine that will be called as the data is
serialized. This callback is given a key name and is expected to return that
key's data type.
.PP
Let's use the following structure as an example:
.PP
.Vb 9
\& {
\& names => {
\& en => \*(AqUnited States\*(Aq,
\& es => \*(AqEstados Unidos\*(Aq,
\& },
\& population => 319_000_000,
\& fizzle_factor => 65.7294,
\& states => [ \*(AqAlabama\*(Aq, \*(AqAlaska\*(Aq, ... ],
\& }
.Ve
.PP
Given this data structure, our \f(CW\*(C`map_key_type_callback\*(C'\fR might look something like this:
.PP
.Vb 8
\& my %types = (
\& names => \*(Aqmap\*(Aq,
\& en => \*(Aqutf8_string\*(Aq,
\& es => \*(Aqutf8_string\*(Aq,
\& population => \*(Aquint32\*(Aq,
\& fizzle_factor => \*(Aqdouble\*(Aq,
\& states => [ \*(Aqarray\*(Aq, \*(Aqutf8_string\*(Aq ],
\& );
\&
\& sub {
\& my $key = shift;
\& return $type{$key};
\& }
.Ve
.PP
If the callback returns \f(CW\*(C`undef\*(C'\fR, the serialization code will throw an
error. Note that for an array we return a 2 element arrayref where the first
element is \f(CW\*(Aqarray\*(Aq\fR and the second element is the type of content in the
array.
.PP
The valid types are:
.IP "\(bu" 4
utf8_string
.IP "\(bu" 4
uint16
.IP "\(bu" 4
uint32
.IP "\(bu" 4
uint64
.IP "\(bu" 4
uint128
.IP "\(bu" 4
int32
.IP "\(bu" 4
double
.Sp
64 bits of precision.
.IP "\(bu" 4
float
.Sp
32 bits of precision.
.IP "\(bu" 4
boolean
.IP "\(bu" 4
map
.IP "\(bu" 4
array
.SH "SUPPORT"
.IX Header "SUPPORT"
Bugs may be submitted through .
.SH "AUTHORS"
.IX Header "AUTHORS"
.IP "\(bu" 4
Olaf Alders
.IP "\(bu" 4
Greg Oschwald
.IP "\(bu" 4
Dave Rolsky
.IP "\(bu" 4
Mark Fowler
.SH "COPYRIGHT AND LICENSE"
.IX Header "COPYRIGHT AND LICENSE"
This software is copyright (c) 2018 by MaxMind, Inc.
.PP
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.