Documentation
¶
Index ¶
- type ByteRange
- type SpatialIndex2D
- func (index *SpatialIndex2D) GetIndexedPoint(x int, y int) ([]byte, error)
- func (index *SpatialIndex2D) GetOutputRange() ([]byte, []byte)
- func (index *SpatialIndex2D) GetPositionFromIndexedPoint(indexedPoint []byte) (int, int, error)
- func (index *SpatialIndex2D) GetValidInputRange() (int, int)
- func (index *SpatialIndex2D) RectangleToIndexedRanges(x, y, width, height int, iopsCostParam float32) ([]ByteRange, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type SpatialIndex2D ¶
type SpatialIndex2D struct {
// contains filtered or unexported fields
}
func NewSpatialIndex2D ¶
func NewSpatialIndex2D(integerBits int) (*SpatialIndex2D, error)
This is the only way to create an instance of SpatialIndex2D. integerBits must be 32 or 64. To use the int size of whatever processor you happen to be running on, like what golang itself does with the `int` type, you may simply pass in `bits.UintSize`.
func (*SpatialIndex2D) GetIndexedPoint ¶
func (index *SpatialIndex2D) GetIndexedPoint(x int, y int) ([]byte, error)
Returns a slice of 8 bytes which can be used as a key in a database index, to be spatial-range-queried by RectangleToIndexedRanges
func (*SpatialIndex2D) GetOutputRange ¶
func (index *SpatialIndex2D) GetOutputRange() ([]byte, []byte)
returns two byte slices of length 8, one representing the smallest key in the index and the other representing the largest possible key in the index returns (as hex) 0000000000000000, 4000000000000000 32 bit SpatialIndex2Ds always leave the last 4 bytes blank.
func (*SpatialIndex2D) GetPositionFromIndexedPoint ¶
func (index *SpatialIndex2D) GetPositionFromIndexedPoint(indexedPoint []byte) (int, int, error)
inverse of GetIndexedPoint. Return [x,y] position from an 8-byte spatial index key
func (*SpatialIndex2D) GetValidInputRange ¶
func (index *SpatialIndex2D) GetValidInputRange() (int, int)
returns the minimum and maximum values for x and y coordinates passed into the index. 64-bit SpatialIndex2D: -1073741823, 1073741823 32-bit SpatialIndex2D: -16383, 16383
func (*SpatialIndex2D) RectangleToIndexedRanges ¶
func (index *SpatialIndex2D) RectangleToIndexedRanges(x, y, width, height int, iopsCostParam float32) ([]ByteRange, error)
Returns a slice of 1 or more byte ranges (typically 1-4). The union of the results of database range queries over these ranges will contain AT LEAST all GetIndexedPoint(x,y) keys present within the rectangle defined by [x,y,width,height].
The results will probably also contain records outside the rectangle, it's up to you to filter them out.
iopsCostParam allows you to adjust a tradeoff between wasted I/O bandwidth and # of individual I/O operations. I think 1.0 is actually a very reasonable value to use for SSD & HDD (waste ~50% of bandwidth, save a lot of unneccessary I/O operations) if you have an extremely fast NVME SSD with a good driver, you might try 0.5 or 0.1, but I doubt it will make it any faster. 2 is probably way too much for any modern disk to benefit from, unless your data is VERY sparse