The Tiny HTM Library
|
HTM tree index implementation. More...
#include "tinyhtm/tree.h"
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <unistd.h>
#include "tinyhtm/varint.h"
Go to the source code of this file.
Functions | |
enum htm_errcode | htm_tree_init (struct htm_tree *tree, const char *const treefile, const char *const datafile) |
Initializes an HTM tree from the given tree and data files, returning HTM_OK on success. | |
void | htm_tree_destroy (struct htm_tree *tree) |
Releases the resources for the given HTM tree. | |
enum htm_errcode | htm_tree_lock (struct htm_tree *tree, size_t datathresh) |
Locks the HTM tree index in memory. | |
int64_t | htm_tree_s2circle_scan (const struct htm_tree *tree, const struct htm_v3 *center, double radius, enum htm_errcode *err) |
Returns the number of points in tree that are inside the spherical circle with the given center and radius. | |
int64_t | htm_tree_s2ellipse_scan (const struct htm_tree *tree, const struct htm_s2ellipse *ellipse, enum htm_errcode *err) |
Returns the number of points in tree that are inside the given spherical ellipse. | |
int64_t | htm_tree_s2cpoly_scan (const struct htm_tree *tree, const struct htm_s2cpoly *poly, enum htm_errcode *err) |
Returns the number of points in tree that are inside the given spherical convex polygon. |
HTM tree index implementation.
For API documentation, see tree.h.
Definition in file tree.c.
int64_t htm_tree_s2circle_scan | ( | const struct htm_tree * | tree, |
const struct htm_v3 * | center, | ||
double | radius, | ||
enum htm_errcode * | err | ||
) |
Returns the number of points in tree
that are inside the spherical circle with the given center and radius.
The implementation scans over all the points in the tree rather than taking advantage of the index. Therefore, this function is primarily useful for testing - application code should use htm_tree_s2circle_count() instead.
If an error occurs, the return value is negative, and *err
is set to an error code describing the reason for the failure.
Definition at line 202 of file tree.c.
References htm_tree::count, count, htm_tree::entries, HTM_ENULLPTR, HTM_RAD_PER_DEG, htm_v3_dist2(), and htm_tree_entry::v.
Referenced by htm_tree_s2circle_count(), and htm_tree_s2circle_range().
int64_t htm_tree_s2cpoly_scan | ( | const struct htm_tree * | tree, |
const struct htm_s2cpoly * | poly, | ||
enum htm_errcode * | err | ||
) |
Returns the number of points in tree
that are inside the given spherical convex polygon.
The implementation scans over all the points in the tree rather than taking advantage of the index. Therefore, this function is primarily useful for testing - application code should use htm_tree_s2cpoly_count() instead.
If an error occurs, the return value is negative, and *err
is set to an error code describing the reason for the failure.
Definition at line 257 of file tree.c.
References htm_tree::count, count, htm_tree::entries, HTM_ENULLPTR, htm_s2cpoly_cv3(), and htm_tree_entry::v.
Referenced by htm_tree_s2cpoly_count(), and htm_tree_s2cpoly_range().
int64_t htm_tree_s2ellipse_scan | ( | const struct htm_tree * | tree, |
const struct htm_s2ellipse * | ellipse, | ||
enum htm_errcode * | err | ||
) |
Returns the number of points in tree
that are inside the given spherical ellipse.
The implementation scans over all the points in the tree rather than taking advantage of the index. Therefore, this function is primarily useful for testing - application code should use htm_tree_s2ellipse_count() instead.
If an error occurs, the return value is negative, and *err
is set to an error code describing the reason for the failure.
Definition at line 234 of file tree.c.
References htm_tree::count, count, htm_tree::entries, HTM_ENULLPTR, htm_s2ellipse_cv3(), and htm_tree_entry::v.
Referenced by htm_tree_s2ellipse_count(), and htm_tree_s2ellipse_range().