Andrew Maltsev
and 1 contributors

NAME

XAO::IndexerSupport - utility functions for XAO::Indexer

SYNOPSIS

  use XAO::IndexerSupport;

DESCRIPTION

This is a very specific module used by XAO::Indexer internally.

METHODS

sorted_intersection

C-optimized variant of finding the intersection of multiple arrays sorted in the same way (all being sub-sets of some master sorted set). Used when finding multiple words search results.

sorted_intersection_perl

Pure-perl variant of finding the intersection of multiple arrays sorted in the same way (all being sub-sets of some master sorted set). Used when finding multiple words search results.

Not used except for benchmarking.

template_sort_clear

Clears data from the internal index, but keeps the memory still allocated. Useful if a different ordering of the same data is about to be used.

This is called automatically in template_sort_prepare(), no need to call it manually.

template_sort_compare

Compares positions of two U32 arguments in the array template_sort_prepare() was called on.

template_sort_free

Frees memory occupied by the internal index.

template_sort_position

For a given unsigned integer returns its position in the array template_sort_prepare() was called on.

template_sort_prepare

Gets a reference to an array of unsigned integers (U32) and prepares internal index for later sorting of its subsets using this array as a template.

The C routine underneath is optimised for the case of relatively sequential distribution of integers in the array -- meaning that the order can be anything, but they are not randomly distributed over the entire U32 range, they form a couple of clusters instead. This is usually the case with auto-increment database IDs.

Performance wise there is no difference, but it will take much more memory if the distribution is random.

template_sort_print_tree

For debugging only -- prints the internal index representation to the standard error.

template_sort

Takes a reference to an array of integers -- a subset of array earlier given to template_sort_prepare(). Returns a reference to an sorted array.

Values that are not in the template array will be grouped in the end in random order.

AUTHOR

Andrew Maltsev <am@xao.com>

SEE ALSO

XAO::Indexer.