UNPKG

@infect/infect-rda-sample-storage

Version:

INFECT Sample Storage for RDA

86 lines (48 loc) 1.34 kB
// need to be able to filter ranges // need to be able to filter exact matches // need to be able to filter multiple fields // create indices for each field of the given filter requirement for the field // start filtering on the most specific filter const bacteriumFilter = new Map(); bacteriumFilter.set('Acineteobacter spp.', new Set()); const formFilter = new Map(); formFilter.set('coccus', new Set()); // get specifity for (const filter of filters) { const { field, value } = filter; } /** * first execute the filters on all filter nodes * then find the smallest result set * sort the remaing result sets by size ascending * iterate over the inital smallest set and look * if the next filter node has its value, if not remove * it from the smallest set and got to the next set * at tthe end you have the intersecting set with all * models already loaded. * * for equality filters, we can use simple maps, for * range filters there needs to be a binary tree * * it will be pretty fast my girl. */ class SearchTree { constructor() { } matchRanges(ranges) { } matchRange(fromValue, toValue) { } mathValues(values) { } match(value) { } intersect(arrays) { } set(key, value) { } has(key) { } remove(key) { } }