-
Notifications
You must be signed in to change notification settings - Fork 173
/
SPOAccessPath.java
310 lines (284 loc) · 9.39 KB
/
SPOAccessPath.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
/**
Copyright (C) SYSTAP, LLC 2006-2015. All rights reserved.
Contact:
SYSTAP, LLC
2501 Calvert ST NW #106
Washington, DC 20008
licenses@systap.com
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package com.bigdata.rdf.spo;
import com.bigdata.bop.IPredicate;
import com.bigdata.journal.IIndexManager;
import com.bigdata.rdf.store.AbstractTripleStore;
import com.bigdata.relation.IRelation;
import com.bigdata.relation.accesspath.AccessPath;
import com.bigdata.relation.accesspath.IAccessPath;
import com.bigdata.striterator.IChunkedOrderedIterator;
import com.bigdata.striterator.IKeyOrder;
/**
* {@link IAccessPath} implementation for an {@link SPORelation}.
*
* @author <a href="mailto:thompsonbry@users.sourceforge.net">Bryan Thompson</a>
* @version $Id$
*/
public class SPOAccessPath extends AccessPath<ISPO> {
/**
*
* @param relation (optional).
* @param indexManager (required)
* @param timestamp
* @param predicate
* @param keyOrder
*/
public SPOAccessPath(final IRelation<ISPO> relation,
final IIndexManager localIndexManager,
final IPredicate<ISPO> predicate, final IKeyOrder<ISPO> keyOrder) {
super(relation, localIndexManager, predicate, keyOrder);
}
/**
* Strengthens the return type.
* <p>
* {@inheritDoc}
*/
public SPOAccessPath init() {
super.init();
return this;
}
/**
* Strengthened return type.
* <p>
* {@inheritDoc}
*/
@Override
public SPORelation getRelation() {
return (SPORelation) super.getRelation();
}
/**
* Strengthened return type.
* <p>
* {@inheritDoc}
*/
@Override
public SPOPredicate getPredicate() {
return (SPOPredicate) super.getPredicate();
}
// /**
// * Strengthened return type.
// * <p>
// * {@inheritDoc}
// */
// @Override
// @SuppressWarnings("rawtypes")
// public IV get(final int index) {
//
// return (IV) super.get(index);
//
// }
/**
* Overridden to delegate to
* {@link AbstractTripleStore#removeStatements(IChunkedOrderedIterator)} in
* order to (a) write on all access paths; (b) handle statement identifiers,
* including truth maintenance for statement identifiers; and (c) if
* justifications are being maintained, then retract justifications having
* no support once the statements visitable by this access path have been
* retracted.
*/
@Override
public long removeAll() {
return getRelation().getContainer().removeStatements(iterator());
}
// /**
// * Return a new {@link SPOAccessPath} where the context position has been
// * bound to the specified constant. The context position MUST be a variable.
// * All instances of that variable will be replaced by the specified
// * constant. This is used to constrain an access path to each graph in the
// * set of default graphs when evaluating a SPARQL query against the
// * "default graph".
// * <p>
// * Note: The added constraint may mean that a different index provides more
// * efficient traversal. For scale-out, this means that the data may be on
// * different index partition.
// *
// * @param c
// * The context term identifier.
// *
// * @return The constrained {@link IAccessPath}.
// *
// * @deprecated with {@link DefaultGraphSolutionExpander} and
// * {@link NamedGraphSolutionExpander}.
// */
// public SPOAccessPath bindContext(final IV c) {
//
// return bindPosition(3, c);
//
// }
//
// /**
// * Return a new {@link SPOAccessPath} where the given position has been
// * bound to the specified constant. The given position MUST be a variable.
// * All instances of that variable will be replaced by the specified
// * constant.
// * <p>
// * Note: The added constraint may mean that a different index provides more
// * efficient traversal. For scale-out, this means that the data may be on
// * different index partition.
// *
// * @param position
// * The position to replace.
// * @param v
// * The constant value to which the variable at the given position
// * is to be set
// *
// * @return The constrained {@link IAccessPath}.
// *
// * @deprecated with {@link #bindContext(IV)}
// */
// private SPOAccessPath bindPosition(final int position, final IV v) {
//
// if (v == null) {
//
// // or return EmptyAccessPath.
// throw new IllegalArgumentException();
//
// }
//
// final IVariableOrConstant<IV> var = getPredicate().get(position);
//
// /*
// * Constrain the access path by setting the given position on its
// * predicate.
// *
// * Note: This option will always do better when you are running against
// * local data (LocalTripleStore).
// */
//
// final SPOPredicate p;
//
// if (position == 3 && var == null) {
//
// /*
// * The context position was never set on the original predicate, so
// * it is neither a variable nor a constant. In this case we just set
// * the context position to the desired constant.
// */
//
// p = getPredicate().setC(new Constant<IV>(v));
//
// } else if (var.isVar()) {
//
// /*
// * The context position is a variable. Replace all occurrences of
// * that variable in the predicate with the desired constant.
// */
//
// p = getPredicate().asBound(new ListBindingSet(//
// new IVariable[] { (IVariable<IV>) var },//
// new IConstant[] { new Constant<IV>(v) }//
// ));
// } else {
//
// /*
// * The context position is already bound to a constant.
// */
//
// if (var.get().equals(v)) {
//
// /*
// * The desired constant is already specified for the context
// * position.
// */
//
// return this;
//
// }
//
// /*
// * A different constant is already specified for the context
// * position. This is an error since you are only allowed to add
// * constraint, not change an existing constraint.
// */
//
// throw new IllegalStateException();
//
// }
//
// /*
// * Let the relation figure out which access path is best given that
// * added constraint.
// */
//
// return (SPOAccessPath) this.getRelation().getAccessPath(p);
//
// }
//
// /**
// * Return a new {@link SPOAccessPath} where the given positions have been bound to the specified constants. The given positions MUST all be variables. All
// * instances of that variable will be replaced by the specified constant.
// * <p>
// * Note: The added constraints may mean that a different index provides more efficient traversal. For scale-out, this means that the data may be on
// * different index partition.
// *
// * @param values
// * The constant values used to constrain the accesspath.
// *
// * @return The constrained {@link IAccessPath}.
// */
// public SPOAccessPath bindPosition(final IV[] values) {
// IVariableOrConstant<IV> s = null, p = null, o = null, c = null;
//
// s = getPredicate().get(0);
// if (values[0] != null) {
// if (s.isVar()) {
// s = new Constant<IV>(values[0]);
// }
// }
//
// p = getPredicate().get(1);
// if (values[1] != null) {
// if (p.isVar()) {
// p = new Constant<IV>(values[1]);
// }
// }
// o = getPredicate().get(2);
// if (values[2] != null) {
// if (o.isVar()) {
// o = new Constant<IV>(values[2]);
// }
// }
// c = getPredicate().get(3);
// if (values[3] != null) {
// if (c == null || c.isVar()) {
// c = new Constant<IV>(values[3]);
// }
// }
// /*
// * Constrain the access path by setting the given positions on its
// * predicate.
// *
// * Note: This option will always do better when you are running against
// * local data (LocalTripleStore).
// */
//
// final SPOPredicate pred = getPredicate().reBound(s, p, o, c);
//
// /*
// * Let the relation figure out which access path is best given that
// * added constraint.
// */
//
// final SPOAccessPath spoa = (SPOAccessPath) this.getRelation()
// .getAccessPath(pred);
//
// return spoa;
// }
}