Best way to manage ids

8 views
Skip to first unread message

Alain

unread,
Sep 29, 2012, 9:04:47 PM9/29/12
to simp...@googlegroups.com
I noticed that with the Database API when you re-open a db existing tables and indexes are reloaded. (was using RSS directly before).

Is there a way to query the database to find the id based on the name used during the createTable/createIndex?

Thanks
Alain

Dibyendu Majumdar

unread,
Sep 30, 2012, 3:14:45 AM9/30/12
to simp...@googlegroups.com
Unfortunately no as currently the caller is required to maintain a
mapping from name to container id. The name isn't used other than the
initial creation of table and related objects.
> --
> You received this message because you are subscribed to the Google Groups
> "SimpleDBM User Group" group.
> To view this discussion on the web, visit
> https://groups.google.com/d/msg/simpledbm/-/kCoKJSMsdFoJ.
> To post to this group, send an email to simp...@googlegroups.com.
> To unsubscribe from this group, send email to
> simpledbm+...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/simpledbm?hl=en-GB.

Alain

unread,
Sep 30, 2012, 8:56:15 AM9/30/12
to simp...@googlegroups.com
Taking a look at the code I was wondering if something like this would work:

    public int getContainerId(String name) {
        StorageContainerInfo[] containers = getServer().getStorageManager().getActiveContainers();
        for (StorageContainerInfo sc : containers) {
        if (sc.getName().equals(name)) {
            return sc.getContainerId();
        }
        }
        return -1;  //not found
    }

Alain

Dibyendu Majumdar

unread,
Sep 30, 2012, 9:07:51 AM9/30/12
to simp...@googlegroups.com
That would indeed work - well spotted!

Alain

unread,
Sep 30, 2012, 3:49:58 PM9/30/12
to simp...@googlegroups.com
One more question.

Any reason why in DatabaseFactory we have the following:
  public static Database getDatabase(Platform platform, Properties properties) {
        return new DatabaseImpl(properties);
   }

where the platform is not passed to the  DatabaseImpl constructor that takes such an argument?

Alain

Dibyendu Majumdar

unread,
Oct 1, 2012, 6:38:55 AM10/1/12
to simp...@googlegroups.com
Hi,
Looks like a bug. Do you need me to issue a fix?
Regards

Alain

unread,
Oct 1, 2012, 7:38:16 AM10/1/12
to simp...@googlegroups.com
No, just fix it for the next release. Just something I noticed in trying to understand part of the code.

Alain
Reply all
Reply to author
Forward
0 new messages