* Obtains the attribute. * @param ff flow file record * @param key key * @param caller_attribute caller supplied object in which we will copy the data ptr * @return 0 if successful, -1 if the key does not exist */
| 398 | * @return 0 if successful, -1 if the key does not exist |
| 399 | */ |
| 400 | int8_t get_attribute(const flow_file_record * ff, attribute * caller_attribute) { |
| 401 | NULL_CHECK(-1, ff, caller_attribute); |
| 402 | NULL_CHECK(-1, ff->attributes, caller_attribute->key); |
| 403 | auto attribute_map = static_cast<AttributeMap*>(ff->attributes); |
| 404 | auto find = attribute_map->find(caller_attribute->key); |
| 405 | if (find != attribute_map->end()) { |
| 406 | caller_attribute->value = static_cast<void*>(const_cast<char*>(find->second.data())); |
| 407 | caller_attribute->value_size = find->second.size(); |
| 408 | return 0; |
| 409 | } |
| 410 | return -1; |
| 411 | } |
| 412 | |
| 413 | int get_attribute_quantity(const flow_file_record *ff) { |
| 414 | NULL_CHECK(0, ff); |