java.lang.Object
com.maxmind.geoip.LookupService.Walker
Enclosing class:
LookupService

private class LookupService.Walkerextends Object
Walks the search tree once, writing every address that maps to one segment.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final byte[]
    Scratch buffer for one node pair.
    private final int
    Country segment index to walk.
    private final int
    Start offset of the first database segment.
    private final Writer
    Where the walk writes its output.
    private final int[]
    Child offsets read from a node.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Walker(int country, Writer out)
    Prepares to walk the database records for one country.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Only call once.
    private void
    walk(int offset, int ip, int depth)
    Recursive, depth first.

    Methods inherited from class Object

    clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • _country

      private final int _country
      Country segment index to walk.
    • _out

      private final Writer _out
      Where the walk writes its output.
    • _buf

      private final byte[] _buf
      Scratch buffer for one node pair.
    • _x

      private final int[] _x
      Child offsets read from a node.
    • _dbs0

      private final int _dbs0
      Start offset of the first database segment.
  • Constructor Details

    • Walker

      public Walker(int country, Writer out) throws IOException
      Prepares to walk the database records for one country.
      Parameters:
      country - the segment index of the country's record
      out - where the walk writes its output
      Throws:
      IOException - declared by the signature, not thrown here
  • Method Details

    • walk

      public void walk() throws IOException
      Only call once.
      Throws:
      IOException - if the database read fails
    • walk

      private void walk(int offset, int ip, int depth) throws IOException
      Recursive, depth first.
      Parameters:
      offset - the node offset to walk from
      ip - the IPv4 address being walked, packed big endian
      depth - the current depth in the tree
      Throws:
      IOException - if the database read fails