![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
#3
| |||
| |||
|
|
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...e-summary.html Another good starting point is to read Getting Started with the Persistence API: http://www.sleepycat.com/jedocs/Pers...API/index.html In the future I suggest posting questions about BDB Java Edition to the bdbje (AT) sleepycat (DOT) com mailing list, since this newsgroup is primarily for BDB C Edition. See: http://dev.sleepycat.com/community/discussion.html Thanks, Mark |
#4
| |||
| |||
|
|
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? |
#5
| |||
| |||
|
|
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/Pers.../EnvProps.html http://www.sleepycat.com/jedocs/java...CacheSize(long) Please do take a close look at the documentation above. Thanks, Mark |
![]() |
| Thread Tools | |
| Display Modes | |
| |