The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Data::Seek::Search - Data::Seek Search Execution Class

VERSION

version 0.06

SYNOPSIS

    use Data::Seek::Search;

DESCRIPTION

Data::Seek::Search is a class within Data::Seek which provides the search mechanism for introspecting data structures.

ATTRIBUTES

cache

    $search->cache;
    $search->cache(1);

Encode the data structure and cache the result. Allows multiple queries to execute faster. Caching is disabled by default.

criteria

    $search->criteria;
    $search->criteria({
        '*'                       => 0,
        'person.name.first'       => 1,
        'person.name.last'        => 2,
        'person.settings.@.name'  => 3,
        'person.settings.@.type'  => 4,
        'person.settings.@.value' => 5,
    });

A collection of criterion which will be used to match nodes within the data structure when introspected, in the order registered.

data

    $search->data;
    $search->data(Data::Seek::Data->new(...));

The data structure to be introspected, must be a hash reference, blessed or not, which defaults to or becomes a Data::Seek::Data object.

data_cache

    $search->data_cache;
    $search->data_cache(Data::Seek::Data->new(...)->encode);

The encoded data structure to be introspected, must be an encoded hash reference, e.g. the result from calling the encode method on a Data::Seek::Data object.

ignore

    $search->ignore;
    $search->ignore(1);

Bypass exceptions thrown when a criterion finds an unknown or invalid node in the data structure.

METHODS

criterion

    $search->criterion('*');

Register a criterion to be used to introspect the registered data structure. A criterion is only valid if it begins with a array index, and array iterator, or a node key; Also can only contain letters, numbers, underscores, periods, and semi-colons. See Data::Seek::Concepts for more information.

perform

    my $dataset = $search->perform;

Introspect the data structure using the registered criteria and settings, and return a result set of operations and matching data nodes.

result

    my $result = $search->result;

Return a search result object, Data::Seek::Search::Result, based on the current search object.

AUTHOR

Al Newkirk <anewkirk@ana.io>

COPYRIGHT AND LICENSE

This software is copyright (c) 2014 by Al Newkirk.

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