The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

FlyBy - Ad hoc denormalized querying

SYNOPSIS

  use FlyBy;

  my $fb = FlyBy->new;
  $fb->add_records({array => 'of'}, {hash => 'references'}, {with => 'fields'});
  my $arrayref_of_hashrefs = $fb->query([['key','value'], ['or', 'key', 'other value']]);

  # Or with a 'reduction list':
  my $array_ref = $fb->query([['key','value']], ['field']);
  my $array_ref_of_array_refs = $fb->query([['key','value']], ['field', 'other field']);

DESCRIPTION

FlyBy is a system to allow for ad hoc querying of data which may not exist in a traditional datastore at runtime

USAGE

add_records
  $fb->add_records({array => 'of'}, {hash => 'references'}, {with => 'fields'});

Supply one or more hash references to be added to the store. `croak` on error; returns `1` on success

query
  $fb->query("'type' IS 'shark' AND 'food' IS 'seal' -> 'called', 'lives_in'");

The query parameters are joined with `IS` for equality testing.

Multiple clauses are joined with an operation (one of: `AND`, `OR`, `AND NOT`) to indicate how to combine the results. Please note that they are evaluated in the supplied order which is significant to the results.

The optional reductions are prefaced with `->`.

If no reduction is provided a list of the full record hash references is returned. If a reduction list of length 1 is provided, a list of the distinct values for the matching key is returned. If a longer reduction list is provided, a list of distinct value array references (in the provided key order) is returned.

Will `croak` on improperly supplied query formats.

all_keys

Returns an array with all known keys against which one might query.

values_for_key

Returns an array of all known values for a given key.

CAVEATS

This software is in an early state. The internal representation and external API are subject to deep breaking change.

This software is not tuned for efficiency. If it is not being used to resolve many queries on each instance or if the data is available from a single canonical source, there are likely better solutions available in CPAN.

AUTHOR

Binary.com

COPYRIGHT

Copyright 2015- Binary.com

LICENSE

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.