NAME
Catmandu::Fix::Bind::hashmap - a binder to add key/value pairs to an internal hashmap
SYNOPSIS
# Find all ISBN in a stream
do hashmap(exporter => JSON, join => ',')
# Need an identity binder to group all operations that calculate key_value pairs
do identity()
copy_field(isbn,key)
copy_field(_id,value)
end
end
# will export to the YAML exporter a hash map containing all isbn occurrences in the stream
{ "_id": "ISBN1" , "value": "0121,12912,121" }
{ "_id": "ISBN2" , "value": "102012" }
# Count the number of ISBN occurrences in a stream
# File: count.fix:
do hashmap(count: 1)
do identity()
copy_field(isbn,key)
end
end
# Use the Null exporter to suppress the normal output
$ cat /tmp/data.json | catmandu convert JSON --fix count.fix to Null
DESCRIPTION
The hashmap binder will insert all key/value pairs given to a internal hashmap that can be exported using an Catmandu::Exporter.
If the key 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.
CONFIGURATION
exporter: EXPORTER
The name of an exporter to send the results to. Default: JSON
store: STORE
Send the output to a store instead of an exporter.
unique: 0|1
All the values for the a key will be 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 occurences.
AUTHOR
Patrick Hochstenbach - Patrick.Hochstenbach@UGent.be