mvl_extent_index_lapply: Apply function to indices of rows with matching hashes

View source: R/RMVL.R

mvl_extent_index_lapplyR Documentation

Apply function to indices of rows with matching hashes

Description

Please use generic function mvl_index_lapply() instead.

Usage

mvl_extent_index_lapply(extent_index, data_list, fn)

Arguments

extent_index

MVL_OBJECT computed by mvl_write_extent_index()

data_list

a list of vectors of equal length. They can be MVL_OBJECTs or R vectors. If missing, scan the entire table one hash at a time.

fn

a function of two arguments - and index into data_list and a corresponding list of indices

Details

This function is passed the index computed by mvl_write_extent_index() and a list of vectors, which rows are used to compute 64-bit hashes. For each row, we call the function fn(i, idx), where i gives the index of query row, and idx gives the indices of with matching hashes.

64-bit hashes have very few collisions, nevertheless the user is advised to double check that the values actually match.

The hash computation is type dependent, so 1 stored as an integer will produce a different hash than when stored as floating point. This function accounts for this by internally converting to types the index was generated with.

Value

a list of results of function fn

See Also

mvl_index_lapply, mvl_group

Examples

## Not run: 
Mtmp<-mvl_open("tmp_a.mvl", append=TRUE, create=TRUE)
mvl_write_object(Mtmp, data.frame(x=runif(100), y=(1:100) %% 10), "df1")
Mtmp<-mvl_remap(Mtmp)
mvl_write_extent_index(Mtmp, list(Mtmp$df1[,"y",ref=TRUE]), "df1_extent_index_y")
Mtmp<-mvl_remap(Mtmp)
mvl_extent_index_lapply(Mtmp["df1_extent_index_y", ref=TRUE], list(c(2, 3)),
                                           function(i, idx) { return(list(i, idx))})
# Example of full scan
mvl_extent_index_lapply(Mtmp["df1_extent_index_y", ref=TRUE], ,
                                           function(i, idx) { return(list(i, idx))})

## End(Not run)

RMVL documentation built on Nov. 2, 2023, 6:09 p.m.