Menu

#19 Explicit data access language

open
nobody
None
5
2012-09-17
2002-06-07
No

Each ozone data repository consists of named objects
(which are inherently reachable) and objects which are
reachable from reachable objects. Each object contains
variables. A repository's state is made up of the state
of all variables of all objects.

A data access language is proposed which denotes
exactly one field of exactly one object (or it denotes
an unreachable field). This language only specifies
data location, not actions on that data.

The syntax of that language should be similar to the
syntax of data location constructs in Java.

Some examples:

db.objectForName("test")

denotes the object whose name is "test"

db.objectForName("test").field1

denotes the object variable "field1" of the object
whose name is "test"

db.objectForName("test").subobjects

denotes the object variable "subobjects" of the object
whose name is "test"

db.objectForName("test").subobjects[0]

denotes the first entry of the array which the variable
"subobjects" of the object whose name is "test" points to

db.objectForName("test").subobjects[0].anotherField

denotes the variable "anotherField" of the first entry
of the array "subobjects" which is referred by the
variable "subobjects" of the database object "test"

db.objectForName("test").subobjects.length

denotes the length of the array "subobjects" of the
database object "test"

It is important that, from the user view, it makes no
difference wether the reference is a local reference
(within an ObjectContainer) or a remote reference via
some proxy

Using this syntax, users and applications may walk
through the object graph as they desire.

This data location language may be the base of a
powerful query and update language. Access may not be
limited to fields, methods may be accessed as well.

One example of such a language

return
Query.sort(Query.for(db.objectForName("test").subobjects).allMatchesWhere(o.getName().compareTo("TeSt")>0),o.getName())

Would extract all entries of the array
db.objectForName("test").subobjects, select all entries
of that array where getName() returns a name which is
lexocographically greater than "TeSt" and sorts by that
name and returns the sorted selected entries.

In this case, Query.for() returns a special virtual
Collection for each real collection (arrays are
collections). This special collection supports the method
allMatchesWhere(), which returns a sub-collection based
on some criterion.

o in each "method call" is a wildcard for each object
iterated.

Note that this query-and-update language, while it may
be implemented as Java method calls, is only
descriptive. Thus, the database is allowed to optimize
if the result of the optimized action is the same as
the step-by-step interpreted one. However, to realize
such optimizations efficiently, the database should at
be at least able to optimize variable accessor accesses
to variable accesses (o.getName() to o.name). Such
optimizations are currently beyond implementability
without further research (on static bytecode
interpretation, so that an accessor method can be
recognized as such)

Discussion


Log in to post a comment.