org.apache.lucene.spatial.prefix.tree

## Class LegacyCell

- java.lang.Object
- - org.apache.lucene.spatial.prefix.tree.LegacyCell

- All Implemented Interfaces:
    Cell, CellCanPrune
  Direct Known Subclasses:
    QuadPrefixTree.QuadCell

      public abstract class LegacyCell
      extends Object
      implements CellCanPrune

  The base for the original two SPT's: Geohash and Quad. Don't subclass this for new SPTs.
  NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected int` | `b_len`
    `protected int` | `b_off`
    `protected byte[]` | `bytes`
    `protected boolean` | `isLeaf`
    `protected org.locationtech.spatial4j.shape.Shape` | `shape`
    `protected org.locationtech.spatial4j.shape.SpatialRelation` | `shapeRel` When set via getSubCells(filter), it is the relationship between this cell and the given shape filter.

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `LegacyCell(byte[] bytes, int off, int len)` Warning: Refers to the same bytes (no copy).

  - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected static int` | `compare(byte[] aBytes, int aUpto, int a_length, byte[] bBytes, int bUpto, int b_length)` Copied from `BytesRef.compareTo(BytesRef)`.
    `int` | `compareToNoLeaf(Cell fromCell)` Equivalent to `this.getTokenBytesNoLeaf(null).compareTo(fromCell.getTokenBytesNoLeaf(null))`.
    `boolean` | `equals(Object obj)`
    `protected abstract SpatialPrefixTree` | `getGrid()`
    `int` | `getLevel()` Level 0 is the world (and has no parent), from then on a higher level means a smaller cell than the level before it.
    `protected abstract int` | `getMaxLevels()`
    `CellIterator` | `getNextLevelCells(org.locationtech.spatial4j.shape.Shape shapeFilter)` Gets the cells at the next grid cell level underneath this one, optionally filtered by `shapeFilter`.
    `org.locationtech.spatial4j.shape.SpatialRelation` | `getShapeRel()` Gets the relationship this cell has with the shape from which it was filtered from, assuming it came from a `CellIterator`.
    `protected abstract LegacyCell` | `getSubCell(org.locationtech.spatial4j.shape.Point p)` Performant implementations are expected to implement this efficiently by considering the current cell's boundary.
    `protected abstract Collection<Cell>` | `getSubCells()` Gets the cells at the next grid cell level that covers this cell.
    `BytesRef` | `getTokenBytesNoLeaf(BytesRef result)` Returns the bytes for this cell, without a leaf set.
    `BytesRef` | `getTokenBytesWithLeaf(BytesRef result)` Returns the bytes for this cell, with a leaf byte if this is a leaf cell.
    `int` | `hashCode()`
    `boolean` | `isLeaf()` Some cells are flagged as leaves, which are indexed as such.
    `boolean` | `isPrefixOf(Cell c)` Returns if the target term is within/underneath this cell; not necessarily a direct descendant.
    `protected void` | `readCell(BytesRef bytes)`
    `protected void` | `readLeafAdjust()`
    `void` | `setLeaf()` Set this cell to be a leaf.
    `void` | `setShapeRel(org.locationtech.spatial4j.shape.SpatialRelation rel)` See `Cell.getShapeRel()`.
    `String` | `toString()`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface org.apache.lucene.spatial.prefix.tree.CellCanPrune

      `getSubCellsSize`

    - ### Methods inherited from interface org.apache.lucene.spatial.prefix.tree.Cell

      `getShape`

- - ### Field Detail

    - #### bytes

          protected byte[] bytes

    - #### b_off

          protected int b_off

    - #### b_len

          protected int b_len

    - #### isLeaf

          protected boolean isLeaf

    - #### shapeRel

          protected org.locationtech.spatial4j.shape.SpatialRelation shapeRel

      When set via getSubCells(filter), it is the relationship between this cell and the given shape filter. Doesn't participate in shape equality.

    - #### shape

          protected org.locationtech.spatial4j.shape.Shape shape

  - ### Constructor Detail

    - #### LegacyCell

          protected LegacyCell(byte[] bytes,
                               int off,
                               int len)

      Warning: Refers to the same bytes (no copy). If `setLeaf()` is subsequently called then it may modify bytes.

  - ### Method Detail

    - #### readCell

          protected void readCell(BytesRef bytes)

    - #### readLeafAdjust

          protected void readLeafAdjust()

    - #### getGrid

          protected abstract SpatialPrefixTree getGrid()

    - #### getMaxLevels

          protected abstract int getMaxLevels()

    - #### getShapeRel

          public org.locationtech.spatial4j.shape.SpatialRelation getShapeRel()

      Description copied from interface: `Cell`
      Gets the relationship this cell has with the shape from which it was filtered from, assuming it came from a `CellIterator`. Arguably it belongs there but it's very convenient here.
      Specified by:
        `getShapeRel` in interface `Cell`

    - #### setShapeRel

          public void setShapeRel(org.locationtech.spatial4j.shape.SpatialRelation rel)

      Description copied from interface: `Cell`
      See `Cell.getShapeRel()`.
      Specified by:
        `setShapeRel` in interface `Cell`

    - #### isLeaf

          public boolean isLeaf()

      Description copied from interface: `Cell`
      Some cells are flagged as leaves, which are indexed as such. A leaf cell is either within some shape or it both intersects and the cell is at an accuracy threshold such that no smaller cells for the shape will be represented.
      Specified by:
        `isLeaf` in interface `Cell`

    - #### setLeaf

          public void setLeaf()

      Description copied from interface: `Cell`
      Set this cell to be a leaf. Warning: never call on a cell initialized to reference the same bytes from termsEnum, which should be treated as immutable. Note: not supported at level 0.
      Specified by:
        `setLeaf` in interface `Cell`

    - #### getTokenBytesWithLeaf

          public BytesRef getTokenBytesWithLeaf(BytesRef result)

      Description copied from interface: `Cell`
      Returns the bytes for this cell, with a leaf byte if this is a leaf cell. The result param is used to save object allocation, though its bytes aren't used.
      Specified by:
        `getTokenBytesWithLeaf` in interface `Cell`
      Parameters:
        `result` - where the result goes, or null to create new

    - #### getTokenBytesNoLeaf

          public BytesRef getTokenBytesNoLeaf(BytesRef result)

      Description copied from interface: `Cell`
      Returns the bytes for this cell, without a leaf set. The bytes should sort before `Cell.getTokenBytesWithLeaf(org.apache.lucene.util.BytesRef)`. The result param is used to save object allocation, though its bytes aren't used.
      Specified by:
        `getTokenBytesNoLeaf` in interface `Cell`
      Parameters:
        `result` - where the result goes, or null to create new

    - #### getLevel

          public int getLevel()

      Description copied from interface: `Cell`
      Level 0 is the world (and has no parent), from then on a higher level means a smaller cell than the level before it.
      Specified by:
        `getLevel` in interface `Cell`

    - #### getNextLevelCells

          public CellIterator getNextLevelCells(org.locationtech.spatial4j.shape.Shape shapeFilter)

      Description copied from interface: `Cell`
      Gets the cells at the next grid cell level underneath this one, optionally filtered by `shapeFilter`. The returned cells should have `Cell.getShapeRel()` set to their relation with `shapeFilter`. In addition, for non-points `Cell.isLeaf()` must be true when that relation is WITHIN.

      IMPORTANT: Cells returned from this iterator can be shared, as well as the bytes.

      Precondition: Never called when getLevel() == maxLevel.

      Specified by:
        `getNextLevelCells` in interface `Cell`
      Parameters:
        `shapeFilter` - an optional filter for the returned cells.
      Returns:
        A set of cells (no dups), sorted. Not Modifiable.

    - #### getSubCell

          protected abstract LegacyCell getSubCell(org.locationtech.spatial4j.shape.Point p)

      Performant implementations are expected to implement this efficiently by considering the current cell's boundary.

      Precondition: Never called when getLevel() == maxLevel. Precondition: this.getShape().relate(p) != DISJOINT.

    - #### getSubCells

          protected abstract Collection<Cell> getSubCells()

      Gets the cells at the next grid cell level that covers this cell. Precondition: Never called when getLevel() == maxLevel.
      Returns:
        A set of cells (no dups), sorted, modifiable, not empty, not null.

    - #### isPrefixOf

          public boolean isPrefixOf(Cell c)

      Description copied from interface: `Cell`
      Returns if the target term is within/underneath this cell; not necessarily a direct descendant.
      Specified by:
        `isPrefixOf` in interface `Cell`
      Parameters:
        `c` - the term

    - #### compareToNoLeaf

          public int compareToNoLeaf(Cell fromCell)

      Description copied from interface: `Cell`
      Equivalent to `this.getTokenBytesNoLeaf(null).compareTo(fromCell.getTokenBytesNoLeaf(null))`.
      Specified by:
        `compareToNoLeaf` in interface `Cell`

    - #### compare

          protected static int compare(byte[] aBytes,
                                       int aUpto,
                                       int a_length,
                                       byte[] bBytes,
                                       int bUpto,
                                       int b_length)

      Copied from `BytesRef.compareTo(BytesRef)`. This is to avoid creating a BytesRef.

    - #### equals

          public boolean equals(Object obj)

      Overrides:
        `equals` in class `Object`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

Copyright © 2000-2019 Apache Software Foundation. All Rights Reserved.