|
|
|
|
|
|
| Author |
Message |
Haas *nix forums beginner
Joined: 09 Apr 2005
Posts: 5
|
Posted: Wed May 31, 2006 5:30 pm Post subject:
Re: Filter object
|
|
|
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
|
Posted: Wed May 31, 2006 3:06 pm Post subject:
Re: Filter object
|
|
|
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
|
Posted: Wed May 31, 2006 2:08 pm Post subject:
Re: Filter object
|
|
|
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
|
Posted: Wed May 31, 2006 1:52 pm Post subject:
Re: Filter object
|
|
|
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
|
Posted: Tue May 30, 2006 10:33 pm Post subject:
Filter object
|
|
|
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 |
|
 |
|
|
The time now is Fri Jan 09, 2009 6:07 am | All times are GMT
|
|
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
|
|