StringMap to handle missing keys instead of throwing an exception
See original GitHub issueIssue Description
StringIndexerModel
has the property handleInvalid
with possible values:
- error
- skip
- keep
StringMap
doesn’t currently have such property. It always throws an exception if the key is missing in StringMapModel.labels
, so it’s currently “always handleInvalid=error”.
Would you be ok with adding the same property to StringMap
? If you like, I can make a pull request.
In StringMap
’s case I think there should be an additional parameter to specify the default value.
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
What is benefit of not raising error (like Python) when key is ...
Go does not raise errors. Go reports errors. A common use of a map element zero value:
Read more >How to Check If a Key Exists in a Map | Baeldung
Learn how to check if a key exists in a Map in Java and a common pitfall.
Read more >Handling missing keys in Python dictionaries - GeeksforGeeks
In python, dictionaries are containers that map one key to its value with access time complexity to be O(1). But in many applications, ......
Read more >Java Map Introduction
A map stores key/value pairs, where each key has an associated value. Given a particular key, the map can look up the associated...
Read more >Map key-not-found (null vs exception) - Google Groups
Map[key] returns null if key is not in the map. It could instead throw an exception, consistent with collections such as List and...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@juhoautio we don’t hardcode the attributes for each of the transformers, they’re all part of the Attributes map, you can take a look https://github.com/combust/bundle-protobuf/blob/master/bundle/bundle.proto#L135 and https://github.com/combust/bundle-protobuf/blob/master/bundle/bundle.proto#L112
PR has been merged, closing issue.