File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to build smart key / value structure from input

 
Meir Yan
Ranch Hand
Posts: 599
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello
I have this scenario that im trying to find the best algorithm to implement it .
Im getting as input array that each element contains key value object


Im my application I need to hold some kind of table structure in memory (fetched from db ) .
Each row contains list of values and one more column that represent the name of all the values in that raw.
For example:

PKG_TYPE | CHECKED | SUSPEND | FREE
pkgFree , 1,0,0
pkgPay , 1,1,1
pkgDemo,0,1,1
all the numbers in this example are primary keys so when im getting the input array
I will get :
inputArr [0]=>checked,1
inputArr [1]=>suspend,0
inputArr [3]=>free,0

and according to these values I will get the service name in this case pkgFree.

My question is what is the best way to implement the in memory table ( it will contains like 300-500 raws )
And also how to perform this patch from this table when input is arriving.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You might concatenate the key parts into one String and use it as a HashMap key:

If the values are always 0 and 1, you can read them like a bitmap and convert them to ints:

Either of those sound useful?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic