Re: Decline of Science: Computer Science and Databases

From: Carl Rosenberger <carl_at_db4o.com>
Date: Mon, 4 Nov 2002 11:41:13 +0100
Message-ID: <aq5icv$i0j$06$1_at_news.t-online.com>


Lauri Pietarinen wrote:
> I think I lost you here... What is actually happening
> in your example? What is the query being executed?

Are the examples really that hard to read?

I will add some comments:

> > public ObjectSet undefinedExtent() {
> > Query q = db.query();
> > q.descend("name").constrain("db").like();
> > return q.execute();
> > }

SELECT FROM [all tables] WHERE name LIKE 'db';

> > public ObjectSet callBackByInterface() {
> > Query q = db.query();
> > q.constrain(Fast.class);
> > q.constrain(new Evaluation() {
> > public void evaluate(Candidate candidate) {
> > candidate.include(
> > ((Fast) candidate.getObject()).getSpeed() > 1000
> > );
> > }
> > });
> > return q.execute();
> > }
> >
> > interface Fast {
> > int getSpeed();
> > }

For each stored object that implements the interface "Fast", execute the method "getSpeed()" on the server and add the object to the query resultset if the method returns a value greater than 1000.

> > public ObjectSet callBackRegularExpression() {
> > Query q = db.query();
> > Query qName = q.descend("name");
> > final Pattern pattern = Pattern.compile("*4o*");
> > qName.constrain(new Evaluation() {
> > public void evaluate(Candidate candidate) {
> > candidate.include(pattern.matcher(
> > ((String) candidate.getObject())).matches()
> > );
> > }
> > });
> > return q.execute();
> > }

For all stored objects that have a member "name", add all objects to the resultset, where the value of name matches the regular expression "*4o*.

> > public ObjectSet dualClass() {
> > Query q = db.query();
> > q.constrain(Consultant.class).or(q.constrain(Coach.class));
> > q.descend("salary").constrain(new Double(200000)).greater();
> > return q.execute();
> > }

SELECT FROM Consultant, Coach WHERE .salary > 200000;

> > public ObjectSet executeAnyNode() {
> > Query q = db.query();
> > q.constrain(Person.class);
> > Query qContact = q.descend("contact");
> > return qContact.execute();
> > }

SELECT Person.contact FROM Person;

Kind regards,
Carl

--
Carl Rosenberger
db4o - database for objects - http://www.db4o.com
Received on Mon Nov 04 2002 - 11:41:13 CET

Original text of this message