Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / February 2006

Tip: Looking for answers? Try searching our database.

The best data structure

Thread view: 
Gregor Kovač - 22 Feb 2006 11:35 GMT
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
   


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.