I am storing a relatively small amount (perhaps may be larger in the future) and then searching it but this is proving to be a bit of a bottleneck in my project.
To expand I have up to a few thousand rows and a few columns. I wish to be able search with the ability to specify a simple match with match all wildcards for any element. All the insertion can take place at construction, ideally duplicates wouldn't exist and the amount of querying outweighs table construction quite considerably. I also need to be able to compare tables to see if the contain the same elements (differences between them aren't needed). Objects that are stored can be hashed but are not ordered. This is all stored in memory.
So initially I started with a simple hashset:
Set<ArrayWrapper> data = new HashSet<ArrayWrapper>();
where ArrayWrapper
is a simple wrapper for an Object[]
. This obviously is slow for searching with wildcards, e.g. {new Integer(3), null, "Test", null}
where null
means match anything. I added an index for the least wildcarded value which helps but I feel there may be a better solution?