Skip to content

Commit 817e4f0

Browse files
committed
Usability improvements on public API
1 parent 7ca9e73 commit 817e4f0

File tree

3 files changed

+65
-65
lines changed

3 files changed

+65
-65
lines changed

RDFSharp/Model/RDFGraph.cs

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -234,11 +234,11 @@ public RDFGraph RemoveTriple(RDFTriple triple)
234234

235235
/// <summary>
236236
/// Removes the triples which satisfy the given combination of SPOL accessors<br/>
237-
/// (null values are handled as * selectors. Obj and Lit params must be mutually exclusive!)
237+
/// (null values are handled as * selectors. Object and Literal params must be mutually exclusive!)
238238
/// </summary>
239-
public RDFGraph RemoveTriples(RDFResource subj, RDFResource pred, RDFResource obj, RDFLiteral lit)
239+
public RDFGraph RemoveTriples(RDFResource s, RDFResource p, RDFResource o, RDFLiteral l)
240240
{
241-
foreach (RDFTriple triple in SelectTriples(subj, pred, obj, lit))
241+
foreach (RDFTriple triple in SelectTriples(s, p, o, l))
242242
Index.Remove(triple);
243243
return this;
244244
}
@@ -259,34 +259,34 @@ public bool ContainsTriple(RDFTriple triple)
259259

260260
/// <summary>
261261
/// Selects the triples which satisfy the given combination of SPOL accessors<br/>
262-
/// (null values are handled as * selectors. Obj and Lit params must be mutually exclusive!)
262+
/// (null values are handled as * selectors. Object and Literal params must be mutually exclusive!)
263263
/// </summary>
264264
/// <exception cref="RDFModelException"></exception>
265-
public List<RDFTriple> SelectTriples(RDFResource subj, RDFResource pred, RDFResource obj, RDFLiteral lit)
265+
public List<RDFTriple> SelectTriples(RDFResource s=null, RDFResource p=null, RDFResource o=null, RDFLiteral l=null)
266266
{
267267
#region Guards
268-
if (obj != null && lit != null)
268+
if (o != null && l != null)
269269
throw new RDFModelException("Cannot access a graph when both object and literals are given: they must be mutually exclusive!");
270270
#endregion
271271

272272
StringBuilder queryFilters = new StringBuilder(3);
273-
if (subj != null) queryFilters.Append('S');
274-
if (pred != null) queryFilters.Append('P');
275-
if (obj != null) queryFilters.Append('O');
276-
if (lit != null) queryFilters.Append('L');
273+
if (s != null) queryFilters.Append('S');
274+
if (p != null) queryFilters.Append('P');
275+
if (o != null) queryFilters.Append('O');
276+
if (l != null) queryFilters.Append('L');
277277
List<RDFHashedTriple> hashedTriples = queryFilters.ToString() switch
278278
{
279-
"S" => [.. Index.LookupIndexBySubject(subj).Select(t => Index.Hashes[t])],
280-
"P" => [.. Index.LookupIndexByPredicate(pred).Select(t => Index.Hashes[t])],
281-
"O" => [.. Index.LookupIndexByObject(obj).Select(t => Index.Hashes[t])],
282-
"L" => [.. Index.LookupIndexByLiteral(lit).Select(t => Index.Hashes[t])],
283-
"SP" => [.. Index.LookupIndexBySubject(subj).Intersect(Index.LookupIndexByPredicate(pred)).Select(t => Index.Hashes[t])],
284-
"SO" => [.. Index.LookupIndexBySubject(subj).Intersect(Index.LookupIndexByObject(obj)).Select(t => Index.Hashes[t])],
285-
"SL" => [.. Index.LookupIndexBySubject(subj).Intersect(Index.LookupIndexByLiteral(lit)).Select(t => Index.Hashes[t])],
286-
"PO" => [.. Index.LookupIndexByPredicate(pred).Intersect(Index.LookupIndexByObject(obj)).Select(t => Index.Hashes[t])],
287-
"PL" => [.. Index.LookupIndexByPredicate(pred).Intersect(Index.LookupIndexByLiteral(lit)).Select(t => Index.Hashes[t])],
288-
"SPO" => [.. Index.LookupIndexBySubject(subj).Intersect(Index.LookupIndexByPredicate(pred).Intersect(Index.LookupIndexByObject(obj))).Select(t => Index.Hashes[t])],
289-
"SPL" => [.. Index.LookupIndexBySubject(subj).Intersect(Index.LookupIndexByPredicate(pred).Intersect(Index.LookupIndexByLiteral(lit))).Select(t => Index.Hashes[t])],
279+
"S" => [.. Index.LookupIndexBySubject(s).Select(t => Index.Hashes[t])],
280+
"P" => [.. Index.LookupIndexByPredicate(p).Select(t => Index.Hashes[t])],
281+
"O" => [.. Index.LookupIndexByObject(o).Select(t => Index.Hashes[t])],
282+
"L" => [.. Index.LookupIndexByLiteral(l).Select(t => Index.Hashes[t])],
283+
"SP" => [.. Index.LookupIndexBySubject(s).Intersect(Index.LookupIndexByPredicate(p)).Select(t => Index.Hashes[t])],
284+
"SO" => [.. Index.LookupIndexBySubject(s).Intersect(Index.LookupIndexByObject(o)).Select(t => Index.Hashes[t])],
285+
"SL" => [.. Index.LookupIndexBySubject(s).Intersect(Index.LookupIndexByLiteral(l)).Select(t => Index.Hashes[t])],
286+
"PO" => [.. Index.LookupIndexByPredicate(p).Intersect(Index.LookupIndexByObject(o)).Select(t => Index.Hashes[t])],
287+
"PL" => [.. Index.LookupIndexByPredicate(p).Intersect(Index.LookupIndexByLiteral(l)).Select(t => Index.Hashes[t])],
288+
"SPO" => [.. Index.LookupIndexBySubject(s).Intersect(Index.LookupIndexByPredicate(p).Intersect(Index.LookupIndexByObject(o))).Select(t => Index.Hashes[t])],
289+
"SPL" => [.. Index.LookupIndexBySubject(s).Intersect(Index.LookupIndexByPredicate(p).Intersect(Index.LookupIndexByLiteral(l))).Select(t => Index.Hashes[t])],
290290
_ => [.. Index.Hashes.Values]
291291
};
292292

@@ -296,11 +296,11 @@ public List<RDFTriple> SelectTriples(RDFResource subj, RDFResource pred, RDFReso
296296

297297
/// <summary>
298298
/// Gets the subgraph containing the triples which satisfy the given combination of SPOL accessors<br/>
299-
/// (null values are handled as * selectors. Obj and Lit params must be mutually exclusive!)
299+
/// (null values are handled as * selectors. Object and Literal params must be mutually exclusive!)
300300
/// </summary>
301301
/// <exception cref="RDFModelException"></exception>
302-
public RDFGraph this[RDFResource subj, RDFResource pred, RDFResource obj, RDFLiteral lit]
303-
=> new RDFGraph(SelectTriples(subj, pred, obj, lit));
302+
public RDFGraph this[RDFResource s=null, RDFResource p=null, RDFResource o=null, RDFLiteral l=null]
303+
=> new RDFGraph(SelectTriples(s, p, o, l));
304304
#endregion
305305

306306
#region Set

RDFSharp/Store/Engines/RDFMemoryStore.cs

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -195,11 +195,11 @@ public override RDFStore RemoveQuadruple(RDFQuadruple quadruple)
195195

196196
/// <summary>
197197
/// Removes the quadruples which satisfy the given combination of CSPOL accessors<br/>
198-
/// (null values are handled as * selectors. Obj and Lit params must be mutually exclusive!)
198+
/// (null values are handled as * selectors. Object and Literal params must be mutually exclusive!)
199199
/// </summary>
200-
public override RDFStore RemoveQuadruples(RDFContext ctx, RDFResource subj, RDFResource pred, RDFResource obj, RDFLiteral lit)
200+
public override RDFStore RemoveQuadruples(RDFContext c=null, RDFResource s=null, RDFResource p=null, RDFResource o=null, RDFLiteral l=null)
201201
{
202-
foreach (RDFQuadruple quadruple in SelectQuadruples(ctx, subj, pred, obj, lit))
202+
foreach (RDFQuadruple quadruple in SelectQuadruples(c, s, p, o, l))
203203
Index.Remove(quadruple);
204204
return this;
205205
}
@@ -220,47 +220,47 @@ public override bool ContainsQuadruple(RDFQuadruple quadruple)
220220

221221
/// <summary>
222222
/// Selects the quadruples which satisfy the given combination of CSPOL accessors<br/>
223-
/// (null values are handled as * selectors. Obj and Lit params must be mutually exclusive!)
223+
/// (null values are handled as * selectors. Object and Literal params must be mutually exclusive!)
224224
/// </summary>
225225
/// <exception cref="RDFStoreException"></exception>
226-
public override List<RDFQuadruple> SelectQuadruples(RDFContext ctx, RDFResource subj, RDFResource pred,RDFResource obj, RDFLiteral lit)
226+
public override List<RDFQuadruple> SelectQuadruples(RDFContext c=null, RDFResource s=null, RDFResource p=null, RDFResource o=null, RDFLiteral l=null)
227227
{
228228
#region Guards
229-
if (obj != null && lit != null)
229+
if (o != null && l != null)
230230
throw new RDFStoreException("Cannot access a store when both object and literals are given: they must be mutually exclusive!");
231231
#endregion
232232

233233
StringBuilder queryFilters = new StringBuilder(4);
234-
if (ctx != null) queryFilters.Append('C');
235-
if (subj != null) queryFilters.Append('S');
236-
if (pred != null) queryFilters.Append('P');
237-
if (obj != null) queryFilters.Append('O');
238-
if (lit != null) queryFilters.Append('L');
234+
if (c != null) queryFilters.Append('C');
235+
if (s != null) queryFilters.Append('S');
236+
if (p != null) queryFilters.Append('P');
237+
if (o != null) queryFilters.Append('O');
238+
if (l != null) queryFilters.Append('L');
239239
List<RDFHashedQuadruple> hashedQuadruples = queryFilters.ToString() switch
240240
{
241-
"C" => [.. Index.LookupIndexByContext(ctx).Select(q => Index.Hashes[q])],
242-
"S" => [.. Index.LookupIndexBySubject(subj).Select(q => Index.Hashes[q])],
243-
"P" => [.. Index.LookupIndexByPredicate(pred).Select(q => Index.Hashes[q])],
244-
"O" => [.. Index.LookupIndexByObject(obj).Select(q => Index.Hashes[q])],
245-
"L" => [.. Index.LookupIndexByLiteral(lit).Select(q => Index.Hashes[q])],
246-
"CS" => [.. Index.LookupIndexByContext(ctx).Intersect(Index.LookupIndexBySubject(subj)).Select(q => Index.Hashes[q])],
247-
"CP" => [.. Index.LookupIndexByContext(ctx).Intersect(Index.LookupIndexByPredicate(pred)).Select(q => Index.Hashes[q])],
248-
"CO" => [.. Index.LookupIndexByContext(ctx).Intersect(Index.LookupIndexByObject(obj)).Select(q => Index.Hashes[q])],
249-
"CL" => [.. Index.LookupIndexByContext(ctx).Intersect(Index.LookupIndexByLiteral(lit)).Select(q => Index.Hashes[q])],
250-
"CSP" => [.. Index.LookupIndexByContext(ctx).Intersect(Index.LookupIndexBySubject(subj).Intersect(Index.LookupIndexByPredicate(pred))).Select(q => Index.Hashes[q])],
251-
"CSO" => [.. Index.LookupIndexByContext(ctx).Intersect(Index.LookupIndexBySubject(subj).Intersect(Index.LookupIndexByObject(obj))).Select(q => Index.Hashes[q])],
252-
"CSL" => [.. Index.LookupIndexByContext(ctx).Intersect(Index.LookupIndexBySubject(subj).Intersect(Index.LookupIndexByLiteral(lit))).Select(q => Index.Hashes[q])],
253-
"CPO" => [.. Index.LookupIndexByContext(ctx).Intersect(Index.LookupIndexByPredicate(pred).Intersect(Index.LookupIndexByObject(obj))).Select(q => Index.Hashes[q])],
254-
"CPL" => [.. Index.LookupIndexByContext(ctx).Intersect(Index.LookupIndexByPredicate(pred).Intersect(Index.LookupIndexByLiteral(lit))).Select(q => Index.Hashes[q])],
255-
"CSPO" => [.. Index.LookupIndexByContext(ctx).Intersect(Index.LookupIndexBySubject(subj).Intersect(Index.LookupIndexByPredicate(pred).Intersect(Index.LookupIndexByObject(obj)))).Select(t => Index.Hashes[t])],
256-
"CSPL" => [.. Index.LookupIndexByContext(ctx).Intersect(Index.LookupIndexBySubject(subj).Intersect(Index.LookupIndexByPredicate(pred).Intersect(Index.LookupIndexByLiteral(lit)))).Select(t => Index.Hashes[t])],
257-
"SP" => [.. Index.LookupIndexBySubject(subj).Intersect(Index.LookupIndexByPredicate(pred)).Select(q => Index.Hashes[q])],
258-
"SO" => [.. Index.LookupIndexBySubject(subj).Intersect(Index.LookupIndexByObject(obj)).Select(q => Index.Hashes[q])],
259-
"SL" => [.. Index.LookupIndexBySubject(subj).Intersect(Index.LookupIndexByLiteral(lit)).Select(q => Index.Hashes[q])],
260-
"PO" => [.. Index.LookupIndexByPredicate(pred).Intersect(Index.LookupIndexByObject(obj)).Select(q => Index.Hashes[q])],
261-
"PL" => [.. Index.LookupIndexByPredicate(pred).Intersect(Index.LookupIndexByLiteral(lit)).Select(q => Index.Hashes[q])],
262-
"SPO" => [.. Index.LookupIndexBySubject(subj).Intersect(Index.LookupIndexByPredicate(pred).Intersect(Index.LookupIndexByObject(obj))).Select(q => Index.Hashes[q])],
263-
"SPL" => [.. Index.LookupIndexBySubject(subj).Intersect(Index.LookupIndexByPredicate(pred).Intersect(Index.LookupIndexByLiteral(lit))).Select(q => Index.Hashes[q])],
241+
"C" => [.. Index.LookupIndexByContext(c).Select(q => Index.Hashes[q])],
242+
"S" => [.. Index.LookupIndexBySubject(s).Select(q => Index.Hashes[q])],
243+
"P" => [.. Index.LookupIndexByPredicate(p).Select(q => Index.Hashes[q])],
244+
"O" => [.. Index.LookupIndexByObject(o).Select(q => Index.Hashes[q])],
245+
"L" => [.. Index.LookupIndexByLiteral(l).Select(q => Index.Hashes[q])],
246+
"CS" => [.. Index.LookupIndexByContext(c).Intersect(Index.LookupIndexBySubject(s)).Select(q => Index.Hashes[q])],
247+
"CP" => [.. Index.LookupIndexByContext(c).Intersect(Index.LookupIndexByPredicate(p)).Select(q => Index.Hashes[q])],
248+
"CO" => [.. Index.LookupIndexByContext(c).Intersect(Index.LookupIndexByObject(o)).Select(q => Index.Hashes[q])],
249+
"CL" => [.. Index.LookupIndexByContext(c).Intersect(Index.LookupIndexByLiteral(l)).Select(q => Index.Hashes[q])],
250+
"CSP" => [.. Index.LookupIndexByContext(c).Intersect(Index.LookupIndexBySubject(s).Intersect(Index.LookupIndexByPredicate(p))).Select(q => Index.Hashes[q])],
251+
"CSO" => [.. Index.LookupIndexByContext(c).Intersect(Index.LookupIndexBySubject(s).Intersect(Index.LookupIndexByObject(o))).Select(q => Index.Hashes[q])],
252+
"CSL" => [.. Index.LookupIndexByContext(c).Intersect(Index.LookupIndexBySubject(s).Intersect(Index.LookupIndexByLiteral(l))).Select(q => Index.Hashes[q])],
253+
"CPO" => [.. Index.LookupIndexByContext(c).Intersect(Index.LookupIndexByPredicate(p).Intersect(Index.LookupIndexByObject(o))).Select(q => Index.Hashes[q])],
254+
"CPL" => [.. Index.LookupIndexByContext(c).Intersect(Index.LookupIndexByPredicate(p).Intersect(Index.LookupIndexByLiteral(l))).Select(q => Index.Hashes[q])],
255+
"CSPO" => [.. Index.LookupIndexByContext(c).Intersect(Index.LookupIndexBySubject(s).Intersect(Index.LookupIndexByPredicate(p).Intersect(Index.LookupIndexByObject(o)))).Select(t => Index.Hashes[t])],
256+
"CSPL" => [.. Index.LookupIndexByContext(c).Intersect(Index.LookupIndexBySubject(s).Intersect(Index.LookupIndexByPredicate(p).Intersect(Index.LookupIndexByLiteral(l)))).Select(t => Index.Hashes[t])],
257+
"SP" => [.. Index.LookupIndexBySubject(s).Intersect(Index.LookupIndexByPredicate(p)).Select(q => Index.Hashes[q])],
258+
"SO" => [.. Index.LookupIndexBySubject(s).Intersect(Index.LookupIndexByObject(o)).Select(q => Index.Hashes[q])],
259+
"SL" => [.. Index.LookupIndexBySubject(s).Intersect(Index.LookupIndexByLiteral(l)).Select(q => Index.Hashes[q])],
260+
"PO" => [.. Index.LookupIndexByPredicate(p).Intersect(Index.LookupIndexByObject(o)).Select(q => Index.Hashes[q])],
261+
"PL" => [.. Index.LookupIndexByPredicate(p).Intersect(Index.LookupIndexByLiteral(l)).Select(q => Index.Hashes[q])],
262+
"SPO" => [.. Index.LookupIndexBySubject(s).Intersect(Index.LookupIndexByPredicate(p).Intersect(Index.LookupIndexByObject(o))).Select(q => Index.Hashes[q])],
263+
"SPL" => [.. Index.LookupIndexBySubject(s).Intersect(Index.LookupIndexByPredicate(p).Intersect(Index.LookupIndexByLiteral(l))).Select(q => Index.Hashes[q])],
264264
_ => [.. Index.Hashes.Values]
265265
};
266266

RDFSharp/Store/RDFStore.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@ public bool Equals(RDFStore other)
8383

8484
/// <summary>
8585
/// Removes the quadruples which satisfy the given combination of CSPOL accessors<br/>
86-
/// (null values are handled as * selectors. Obj and Lit params must be mutually exclusive!)
86+
/// (null values are handled as * selectors. Object and Literal params must be mutually exclusive!)
8787
/// </summary>
88-
public abstract RDFStore RemoveQuadruples(RDFContext ctx, RDFResource subj, RDFResource pred, RDFResource obj, RDFLiteral lit);
88+
public abstract RDFStore RemoveQuadruples(RDFContext c=null, RDFResource s=null, RDFResource p=null, RDFResource o=null, RDFLiteral l=null);
8989

9090
/// <summary>
9191
/// Clears the quadruples of the store
@@ -101,18 +101,18 @@ public bool Equals(RDFStore other)
101101

102102
/// <summary>
103103
/// Selects the quadruples which satisfy the given combination of CSPOL accessors<br/>
104-
/// (null values are handled as * selectors. Obj and Lit params must be mutually exclusive!)
104+
/// (null values are handled as * selectors. Object and Literal params must be mutually exclusive!)
105105
/// </summary>
106106
/// <exception cref="RDFStoreException"></exception>
107-
public abstract List<RDFQuadruple> SelectQuadruples(RDFContext ctx, RDFResource subj, RDFResource pred, RDFResource obj, RDFLiteral lit);
107+
public abstract List<RDFQuadruple> SelectQuadruples(RDFContext c=null, RDFResource s=null, RDFResource p=null, RDFResource o=null, RDFLiteral l=null);
108108

109109
/// <summary>
110110
/// Gets a memory store containing quadruples which satisfy the given combination of CSPOL accessors<br/>
111-
/// (null values are handled as * selectors. Obj and Lit params must be mutually exclusive!)
111+
/// (null values are handled as * selectors. Object and Literal params must be mutually exclusive!)
112112
/// </summary>
113113
/// <exception cref="RDFStoreException"></exception>
114-
public RDFMemoryStore this[RDFContext ctx, RDFResource subj, RDFResource pred, RDFResource obj, RDFLiteral lit]
115-
=> new RDFMemoryStore(SelectQuadruples(ctx, subj, pred, obj, lit));
114+
public RDFMemoryStore this[RDFContext c=null, RDFResource s=null, RDFResource p=null, RDFResource o=null, RDFLiteral l=null]
115+
=> new RDFMemoryStore(SelectQuadruples(c, s, p, o, l));
116116

117117
/// <summary>
118118
/// Gets a list containing the graphs saved in the store

0 commit comments

Comments
 (0)