niXforums Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   PreferencesPreferences   Log in to check your private messagesLog in to check your private messages   Log inLog in 
·  nixdoc.net ·  man pages ·  Linux HOWTOs ·  FreeBSD Tips ·  Forums
navigation Forum index » Databases » Berkeley DB
Filter object
Post new topic   Reply to topic Page 1 of 1 [5 Posts] View previous topic :: View next topic
Author Message
Haas
*nix forums beginner


Joined: 09 Apr 2005
Posts: 5

PostPosted: Wed May 31, 2006 5:30 pm    Post subject: Re: Filter object Reply with quote

Ok Mark,

I understood, thank you again for the answer!

Now I'm starting to like DBD! :-)

Best regards.


mark.hayes@oracle.com wrote:
Quote:
Haas wrote:
Hello Mark,

First, thank you to answer my question!

You're welcome.

Based in your answer I have a new question:

If I had more than 5000 entity of person persisted in DB (for example)
and I need do the the filter, when I get the entities from DB by
"EntityCursor<Person> employees = dao.personBySsn.entities();", Do I
full the computer memory with any objects that I don't will use it?

No, you won't fill up memory. When you read records, BDB loads them
into its cache. When the cache fills up, the least recently used
record is removed from the cache. In general, the larger the cache the
better the performance.

The size of the JE (BDB Java Edition) cache is, by default, 60% of the
Java heap size. The Java heap size can be specified using the Java
-Xmx option, and is normally 64 MB by default. You can override the
size of the JE cache using the environment configuration cache size
property:

http://www.sleepycat.com/jedocs/PersistenceAPI/EnvProps.html
http://www.sleepycat.com/jedocs/java/com/sleepycat/je/EnvironmentMutableConfig.html#setCacheSize(long)

Please do take a close look at the documentation above.

Thanks,
Mark
Back to top
mark@sleepycat.com
*nix forums beginner


Joined: 22 Aug 2005
Posts: 18

PostPosted: Wed May 31, 2006 3:06 pm    Post subject: Re: Filter object Reply with quote

Haas wrote:
Quote:
Hello Mark,

First, thank you to answer my question!

You're welcome.

Quote:
Based in your answer I have a new question:

If I had more than 5000 entity of person persisted in DB (for example)
and I need do the the filter, when I get the entities from DB by
"EntityCursor<Person> employees = dao.personBySsn.entities();", Do I
full the computer memory with any objects that I don't will use it?

No, you won't fill up memory. When you read records, BDB loads them
into its cache. When the cache fills up, the least recently used
record is removed from the cache. In general, the larger the cache the
better the performance.

The size of the JE (BDB Java Edition) cache is, by default, 60% of the
Java heap size. The Java heap size can be specified using the Java
-Xmx option, and is normally 64 MB by default. You can override the
size of the JE cache using the environment configuration cache size
property:

http://www.sleepycat.com/jedocs/PersistenceAPI/EnvProps.html
http://www.sleepycat.com/jedocs/java/com/sleepycat/je/EnvironmentMutableConfig.html#setCacheSize(long)

Please do take a close look at the documentation above.

Thanks,
Mark
Back to top
Haas
*nix forums beginner


Joined: 09 Apr 2005
Posts: 5

PostPosted: Wed May 31, 2006 2:08 pm    Post subject: Re: Filter object Reply with quote

Hello Mark,

First, thank you to answer my question!

Based in your answer I have a new question:

If I had more than 5000 entity of person persisted in DB (for example)
and I need do the the filter, when I get the entities from DB by
"EntityCursor<Person> employees = dao.personBySsn.entities();", Do I
full the computer memory with any objects that I don't will use it?



mark.hayes@oracle.com wrote:
Quote:
Hello Haas,

Berkeley DB doesn't have "filters" or a query language -- it provides
direct access to the store using primary and secondary indices. This
direct access, and the associated high performance, is what
distinguishes BDB from other databases. We call our new API the Direct
Persistence Layer for this reason.

If you want to query by name and name is a secondary index
(personByName), then you can use a sub-index. For example:

EntityCursor<Person> employees =
dao.personByName.subIndex("Bob Smith").entities();
try {
for (Person employee : employees) {
/* do something */
}
} finally {
employees.close();
}

If there is no secondary index for the name field, simply loop through
the records by primary index (personBySsn) and check the name field.
This is what a query language does internally when there is no
secondary index. For example:

EntityCursor<Person> employees =
dao.personBySsn.entities();
try {
for (Person employee : employees) {
if (employee.name.equals("Bob Smith")) {
/* do something */
}
}
} finally {
employees.close();
}

The code for the examples above was copied and modified from this page,
which is where you can start reading the Javadocs:

http://www.sleepycat.com/jedocs/java/com/sleepycat/persist/package-summary.html

Another good starting point is to read Getting Started with the
Persistence API:

http://www.sleepycat.com/jedocs/PersistenceAPI/index.html

In the future I suggest posting questions about BDB Java Edition to the
bdbje@sleepycat.com mailing list, since this newsgroup is primarily for
BDB C Edition. See:

http://dev.sleepycat.com/community/discussion.html

Thanks,
Mark
Back to top
mark@sleepycat.com
*nix forums beginner


Joined: 22 Aug 2005
Posts: 18

PostPosted: Wed May 31, 2006 1:52 pm    Post subject: Re: Filter object Reply with quote

Hello Haas,

Berkeley DB doesn't have "filters" or a query language -- it provides
direct access to the store using primary and secondary indices. This
direct access, and the associated high performance, is what
distinguishes BDB from other databases. We call our new API the Direct
Persistence Layer for this reason.

If you want to query by name and name is a secondary index
(personByName), then you can use a sub-index. For example:

EntityCursor<Person> employees =
dao.personByName.subIndex("Bob Smith").entities();
try {
for (Person employee : employees) {
/* do something */
}
} finally {
employees.close();
}

If there is no secondary index for the name field, simply loop through
the records by primary index (personBySsn) and check the name field.
This is what a query language does internally when there is no
secondary index. For example:

EntityCursor<Person> employees =
dao.personBySsn.entities();
try {
for (Person employee : employees) {
if (employee.name.equals("Bob Smith")) {
/* do something */
}
}
} finally {
employees.close();
}

The code for the examples above was copied and modified from this page,
which is where you can start reading the Javadocs:

http://www.sleepycat.com/jedocs/java/com/sleepycat/persist/package-summary.html

Another good starting point is to read Getting Started with the
Persistence API:

http://www.sleepycat.com/jedocs/PersistenceAPI/index.html

In the future I suggest posting questions about BDB Java Edition to the
bdbje@sleepycat.com mailing list, since this newsgroup is primarily for
BDB C Edition. See:

http://dev.sleepycat.com/community/discussion.html

Thanks,
Mark
Back to top
Haas
*nix forums beginner


Joined: 09 Apr 2005
Posts: 5

PostPosted: Tue May 30, 2006 10:33 pm    Post subject: Filter object Reply with quote

Peoples,

I'm trying to retrive objects that I put in JE BD using any filter to
do it, I'm using DataAccessor to get the objects from DB, but I'm can
retrive using any filter, how can I do it?

EntityCursor items = da.peopleByName.entities();

"da" is an instance of DataAcessor.

I can retrieve all objects that exists in db but I want only the
objects that que name init with "James" (for example), and the
DataAccessor give me all objects that the name init with "James".
Back to top
Google

Back to top
Display posts from previous:   
Post new topic   Reply to topic Page 1 of 1 [5 Posts] View previous topic :: View next topic
The time now is Fri Jan 09, 2009 6:07 am | All times are GMT
navigation Forum index » Databases » Berkeley DB
Jump to:  

Similar Topics
Topic Author Forum Replies Last Post
No new posts how can i use fstream object to clear file's content? horneye C++ 2 Fri Jul 21, 2006 7:52 am
No new posts CORBA object used in Vector niks C++ 0 Fri Jul 21, 2006 7:45 am
No new posts CORBA object used in Vector niks C++ 1 Fri Jul 21, 2006 7:40 am
No new posts Bug#379054: ITP: lisaac -- Lisaac is the first object-ori... picca frederic devel 0 Thu Jul 20, 2006 9:30 pm
No new posts ImportError: libclntsh.so.10.1: cannot open shared object... gmax2006 python 2 Thu Jul 20, 2006 7:05 pm

Bankruptcy | Short Bowel Syndrome | Bad Credit Credit Cards | Web Hosting | Movies download
Copyright © 2004-2005 DeniX Solutions SRL
 
Other DeniX Solutions sites: Unix/Linux blog |  electronics forum |  medicine forum |  science forum | 
Privacy Policy


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1872s ][ Queries: 20 (0.0951s) ][ GZIP on - Debug on ]