Hi!
What is the best data structure in Java for the next example:
I want to store different properties with their values in a structure that
is fast for inserts and even faster for retrival. It should also provide
the ability to search for only a fraction of the property.
Example:
- MASK_NAME.MASK_FIELD_NAME1.PROPERTY_NAME1 = VALUE1
- MASK_NAME.MASK_FIELD_NAME1.PROPERTY_NAME2 = VALUE2
- MASK_NAME.MASK_FIELD_NAME2.PROPERTY_NAME3 = VALUE3
- MASK_NAME.MASK_FIELD_NAME2.PROPERTY_NAME4 = VALUE4
So I want to store them into a structre and search over them like this:
- get me value for property MASK_NAME.MASK_FIELD_NAME1.PROPERTY_NAME1. This
returns VALUE1.
- get me all the properties for MASK_NAME.MASK_FIELD_NAME1 (specific field
on a form) and their values. This returns PROPERTY_NAME1 = VALUE1 and
PROPERTY_NAME2 = VALUE2
- who has a property named PROPERTY_NAME3. This returns
MASK_NAME.MASK_FIELD_NAME2.
Basically I want to do somekind of SQL queries over this structure.
Best regards,
Kovi

Signature
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
| Gregor Kovac | Gregor.Kovac@mikropis.si |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| In A World Without Fences Who Needs Gates? |
| Experience Linux. |
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Hendrik Maryns - 22 Feb 2006 11:49 GMT
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
NotDashEscaped: You need GnuPG to verify this message
Gregor Kova? schreef:
> Hi!
>
[quoted text clipped - 18 lines]
>
> Basically I want to do somekind of SQL queries over this structure.
Multiple nested hash maps? Solves insertion speed and querying of the
first two kinds. To get the third kind of query efficient, you will
need an additional hash with inverted values. You can use values() for
the answer to query 2.
H.

Signature
Hendrik Maryns
==================
www.lieverleven.be
http://aouw.org
Jacob - 22 Feb 2006 13:09 GMT
> What is the best data structure in Java for the next example:
> I want to store different properties with their values in a structure that
[quoted text clipped - 16 lines]
>
> Basically I want to do somekind of SQL queries over this structure.
The java.util.prefs.Preferences class looks very much like
this. It is basically a properties (key = value) type inside
a tree structure. I am sure you can use it as your backend
and provide a suitable public API on top of it.
tom fredriksen - 23 Feb 2006 10:56 GMT
Gregor Kova wrote:
> Hi!
>
[quoted text clipped - 9 lines]
>
> Basically I want to do somekind of SQL queries over this structure.
I dont think there is any thing out there that contains exactly what you
want so I think you have to create/extend some stuff yourself.
What you can do is create indexes for the data parts you are looking for
and store those parts in a hashmap or a RedBlack tree, then use an array
or ArrayList for the data it self which the indexes point to.
Example:
index 1 (hashmap):
key: MASK_FIELD_NAME1
value: LinkedList of array entries
index 2 (hashmap):
key: PROPERTY_NAME1
value: LinkedList of array entries
and so on.
/tom