java - Whats faster? Get a null record or check existence? -


i have timeseries lookup. building , requesting corresponding keys if don't exist (getting null record) in span of time. there better way it? checking existence of key, prior example?

thanks

just records need.

my rule of thumb this: "if need know if key exists, check that. however, if first thing you're going key exists value, values."

in order check if exists, has lookup on key. difference between , returning value retrieving value. "get" operation have same lookup. if value none, there no additional overhead required return value, except couple bytes store "null" instead of false. however, if need know key exists, there's no reason return whole contents if does.


Comments

Popular posts from this blog

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - UML - How would you draw a try catch in a sequence diagram? -

c++ - No viable overloaded operator for references a map -