5 |
:Author: Tuomas J. Lukka |
:Author: Tuomas J. Lukka |
6 |
:Last-Modified: $Date$ |
:Last-Modified: $Date$ |
7 |
:Revision: $Revision$ |
:Revision: $Revision$ |
8 |
:Status: Current |
:Status: Current, Partially preliminarily implemented (since in its own package) |
9 |
|
|
10 |
This document outlines the main issues in the Jena api |
This document outlines the main issues in the Jena api |
11 |
currently in use and proposes a lightweight api of our own |
currently in use and proposes a lightweight api of our own |
14 |
Issues |
Issues |
15 |
====== |
====== |
16 |
|
|
17 |
|
|
18 |
- Are there any APIs out there that already support our needs? |
- Are there any APIs out there that already support our needs? |
19 |
|
|
20 |
- Do we want implicit or explicit observers? |
- Do we want implicit or explicit observers? |
115 |
- What should the resource mapper and its methods be called? RMap? |
- What should the resource mapper and its methods be called? RMap? |
116 |
Nodes? |
Nodes? |
117 |
|
|
118 |
Still open, under consideration. |
RESOLVED: Nodes. It's the most descriptive. |
119 |
|
|
120 |
|
- Could we use e.g. int instead of Object for resources? |
121 |
|
|
122 |
|
RESOLVED: Can't do - with ints you won't know if there |
123 |
|
are any external references to it. |
124 |
|
|
125 |
|
With Object, you can use Weak maps to allow garbage collection |
126 |
|
but also allow the retaining of resource objects between |
127 |
|
different graphs. |
128 |
|
|
129 |
- For returning multiple values, should we use Iterators or something |
- For returning multiple values, should we use Iterators or something |
130 |
else? :: |
else? :: |
137 |
use simultaneously |
use simultaneously |
138 |
|
|
139 |
Thinking. |
Thinking. |
140 |
|
|
141 |
|
- What about queries with more than one component? Say, "give me all triples", |
142 |
|
or "give me all property-value pairs for the given subject node" |
143 |
|
|
144 |
|
- Why is the new API called swamp? |
145 |
|
|
146 |
|
RESOLVED: Fenfires spring out of swamps ;) |
147 |
|
|
148 |
Problems with jena |
Problems with jena |
149 |
================== |
================== |
150 |
|
|
192 |
The global resource mapper (has to be global since resources are model-agnostic) |
The global resource mapper (has to be global since resources are model-agnostic) |
193 |
is simple: The name must be short because it's so widely used. :: |
is simple: The name must be short because it's so widely used. :: |
194 |
|
|
195 |
public class RMap { |
public class Nodes { |
196 |
public static Object toModel(String res); |
public static Object get(String res); |
197 |
public static Object toModel(String res, int offs, int len); |
public static Object get(String res, int offs, int len); |
198 |
public static Object toModel(char[] res, int offs, int len); |
public static Object get(char[] res, int offs, int len); |
199 |
|
|
200 |
public static String toString(Object res); |
public static String toString(Object res); |
201 |
|
|
202 |
/** Append the string version of the resource to the given buffer. |
/** Append the string version of the resource to the given buffer. |
203 |
* In order to avoid creating too many String objects |
* In order to avoid creating too many String objects |
204 |
* when serializing a space, we |
* when serializing a space. |
205 |
|
*/ |
206 |
public static void appendToString(Object res, StringBuffer buf); |
public static void appendToString(Object res, StringBuffer buf); |
207 |
} |
} |
208 |
|
|
211 |
the toModel method overloaded with different parameter types allows the most efficient |
the toModel method overloaded with different parameter types allows the most efficient |
212 |
creation of resources without conversions. |
creation of resources without conversions. |
213 |
|
|
214 |
We *may* want to make RMap internally redirectable in the future to allow |
We *may* want to make Nodes internally redirectable in the future to allow |
215 |
alternate implementations; the static interface will not change. |
alternate implementations; the static interface will not change. |
216 |
|
|
217 |
The model object |
The model object |
221 |
To avoid this, we'll drop the semantics (subject,predicate,object) for now |
To avoid this, we'll drop the semantics (subject,predicate,object) for now |
222 |
and name all methods according to a general scheme. :: |
and name all methods according to a general scheme. :: |
223 |
|
|
224 |
public interface ConstFirstOrderGraph { |
public interface ConstGraph { |
225 |
public Object find1_11X(Object subject, Object predicate); |
Object find1_11X(Object subject, Object predicate); |
226 |
public Object find1_X11(Object predicate, Object subject); |
Object find1_X11(Object predicate, Object subject); |
227 |
... |
... |
228 |
public Iterator findN_11X(Object subject, Object predicate); |
Iterator findN_11X_Iter(Object subject, Object predicate); |
229 |
... |
... |
230 |
} |
} |
231 |
|
|
232 |
public interface FirstOrderGraph extends ConstFirstOrderGraph { |
public interface Graph extends ConstGraph { |
233 |
public void set1_11X(Object subject, Object predicate, Object object); |
void set1_11X(Object subject, Object predicate, Object object); |
234 |
public void set1_X11(Object subject, Object predicate, Object object); |
void set1_X11(Object subject, Object predicate, Object object); |
235 |
... |
... |
236 |
|
|
237 |
public void rm_1XX(Object subject); |
void rm_1XX(Object subject); |
238 |
public void rm_11X(Object subject, Object predicate); |
void rm_11X(Object subject, Object predicate); |
239 |
public void rm_X11(Object predicate, Object object); |
void rm_X11(Object predicate, Object object); |
240 |
... |
... |
241 |
|
|
242 |
/** Add the given triple to the model. |
/** Add the given triple to the model. |
243 |
*/ |
*/ |
244 |
public void add(Object subject, Object predicate, Object object); |
void add(Object subject, Object predicate, Object object); |
245 |
} |
} |
246 |
|
|
247 |
The functions are built by the following format: |
The functions are built by the following format: |
259 |
and return. Even if there are none, the iterator is created. |
and return. Even if there are none, the iterator is created. |
260 |
Only a single X may be used. |
Only a single X may be used. |
261 |
|
|
262 |
|
For instance, :: |
263 |
|
|
264 |
|
findN_1XA(node) |
265 |
|
|
266 |
|
returns all properties that the node has, and |
267 |
|
|
268 |
|
findN_XAA() |
269 |
|
|
270 |
|
finds all nodes that are the subject of any triple. |
271 |
|
|
272 |
set1 |
set1 |
273 |
Remove the other occurrences of the matching triples, replace them with the given |
Remove the other occurrences of the matching triples, replace them with the given |
274 |
new one. For example, if triples (a,b,c) and (a,b,d) and (a,e,d) are in the model, |
new one. For example, if triples (a,b,c) and (a,b,d) and (a,e,d) are in the model, |
278 |
|
|
279 |
the model will have the triples (a,b,g) and (a,e,d). |
the model will have the triples (a,b,g) and (a,e,d). |
280 |
Only a single X may be used (restriction may be lifted in the future). |
Only a single X may be used (restriction may be lifted in the future). |
281 |
|
Only 1 and X may be used. |
282 |
|
|
283 |
rm |
rm |
284 |
Remove the matching triples from the model. Any amount of Xs may be used. |
Remove the matching triples from the model. Any amount of Xs may be used. |
290 |
X |
X |
291 |
Requested / set |
Requested / set |
292 |
|
|
293 |
|
A |
294 |
|
Ignored - may be any |
295 |
|
|
296 |
The uniqueness exception |
The uniqueness exception |
297 |
------------------------ |
------------------------ |
298 |
|
|
305 |
public final Object object; |
public final Object object; |
306 |
} |
} |
307 |
|
|
308 |
|
The wildcards are set to null. |
309 |
|
|
310 |
|
|