logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

Catmandu::Fix::Bind::hashmap - a binder to add key/value pairs to an internal hashmap

Configuration

exporter:EXPORTER
       The name of an exporter to send the results to. Default: JSON  Extra parameters can be added:

           do hashmap(exporter: JSON, file:/tmp/data.json, count: 1)
             ...
           end

   store:STORE
       Send the output to a store instead of an exporter. Extra parameters can be added:

           do hashmap(store: MongoDB, database_name: test, bag: data, count: 1)
             ...
           end

   uniq:0|1
       When set to 1, then all values in the key 'value' will be made unique

   join:CHAR
       Join all the values of a key using a delimiter.

   count:0|1
       Don't store the values only count the number of key occurrences.

Description

       The hashmap binder will insert all key/value pairs given to a internal hashmap that can be exported using
       an Catmandu::Exporter.

       The 'key' fields in the internal hashmap will be exported as '_id' field.

       If the key in the hashmap Bind is an ARRAY, then multiple key/value pairs will be inserted into the
       hashmap.

       By default all the values will be added as an array to the hashmap. Every key will have one or more
       values. Use the 'join' parameter to create a string out of this array.

Name

       Catmandu::Fix::Bind::hashmap - a binder to add key/value pairs to an internal hashmap

See Also

       Catmandu::Fix::Bind

perl v5.40.0                                       2025-01-17                  Catmandu::Fix::Bind::hashmap(3pm)

Synopsis

        # Find non unique ISBN numbers in the record stream
        do hashmap(join: ',')
           copy_field(isbn,key)
           copy_field(_id,value)
        end

        # will export to the JSON exporter a hash map containing all isbn occurrences in the stream

        { "_id": "9781565920422" , "value": "rec0001,rec0329,rec1032" }
        { "_id": "9780596004927" , "value": "rec0718" }

        # Ignore the values. Count the number of ISBN occurrences in a stream
        # File: count.fix:
        do hashmap(count: 1)
           copy_field(isbn,key)
        end

        # Use the Null exporter to suppress the normal output
        $ cat /tmp/data.json | catmandu convert JSON --fix count.fix to Null

See Also