summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2011-09-29 00:59:16 +0000
committerDavid Robillard <d@drobilla.net>2011-09-29 00:59:16 +0000
commit829760ac063b9cbab3546fdb1d78cfac1ebd52fd (patch)
tree19cef72d0ef8e4d59df03930953f5d325165084a /src
parentba34cfd454a1d5bdbab60322966ef39236c9f5b8 (diff)
downloadsord-829760ac063b9cbab3546fdb1d78cfac1ebd52fd.tar.gz
sord-829760ac063b9cbab3546fdb1d78cfac1ebd52fd.tar.bz2
sord-829760ac063b9cbab3546fdb1d78cfac1ebd52fd.zip
Tidy.
git-svn-id: http://svn.drobilla.net/sord/trunk@166 3d64ff67-21c5-427c-a301-fe4f08042e5a
Diffstat (limited to 'src')
-rw-r--r--src/sord.c83
-rw-r--r--src/sord_test.c9
-rw-r--r--src/sordi.c2
-rw-r--r--src/syntax.c2
-rw-r--r--src/zix/common.h2
5 files changed, 51 insertions, 47 deletions
diff --git a/src/sord.c b/src/sord.c
index 4d8908c..87dfb10 100644
--- a/src/sord.c
+++ b/src/sord.c
@@ -68,18 +68,18 @@
/** Triple ordering */
typedef enum {
- SPO, ///< Subject, Predicate, Object
- SOP, ///< Subject, Object, Predicate
- OPS, ///< Object, Predicate, Subject
- OSP, ///< Object, Subject, Predicate
- PSO, ///< Predicate, Subject, Object
- POS, ///< Predicate, Object, Subject
- GSPO, ///< Graph, Subject, Predicate, Object
- GSOP, ///< Graph, Subject, Object, Predicate
- GOPS, ///< Graph, Object, Predicate, Subject
- GOSP, ///< Graph, Object, Subject, Predicate
- GPSO, ///< Graph, Predicate, Subject, Object
- GPOS, ///< Graph, Predicate, Object, Subject
+ SPO, ///< Subject, Predicate, Object
+ SOP, ///< Subject, Object, Predicate
+ OPS, ///< Object, Predicate, Subject
+ OSP, ///< Object, Subject, Predicate
+ PSO, ///< Predicate, Subject, Object
+ POS, ///< Predicate, Object, Subject
+ GSPO, ///< Graph, Subject, Predicate, Object
+ GSOP, ///< Graph, Subject, Object, Predicate
+ GOPS, ///< Graph, Object, Predicate, Subject
+ GOSP, ///< Graph, Object, Subject, Predicate
+ GPSO, ///< Graph, Predicate, Subject, Object
+ GPOS, ///< Graph, Predicate, Object, Subject
} SordOrder;
/** String name of each ordering (array indexed by SordOrder) */
@@ -99,10 +99,10 @@ static const int orderings[NUM_ORDERS][TUP_LEN] = {
/** World */
struct SordWorldImpl {
- ZixHash* names; ///< URI or blank node identifier string => ID
- ZixHash* langs; ///< Language tag => Interned language tag
- ZixHash* literals; ///< Literal => ID
- size_t n_nodes; ///< Number of nodes
+ ZixHash* names; ///< URI or blank node identifier string => ID
+ ZixHash* langs; ///< Language tag => Interned language tag
+ ZixHash* literals; ///< Literal => ID
+ size_t n_nodes; ///< Number of nodes
};
/** Store */
@@ -120,23 +120,23 @@ struct SordModelImpl {
/** Mode for searching or iteration */
typedef enum {
- ALL, ///< Iterate to end of store, returning all results, no filtering
- SINGLE, ///< Iteration over a single element (exact search)
- RANGE, ///< Iterate over range with equal prefix
- FILTER_RANGE, ///< Iterate over range with equal prefix, filtering
- FILTER_ALL ///< Iterate to end of store, filtering
+ ALL, ///< Iterate to end of store, returning all results, no filtering
+ SINGLE, ///< Iteration over a single element (exact search)
+ RANGE, ///< Iterate over range with equal prefix
+ FILTER_RANGE, ///< Iterate over range with equal prefix, filtering
+ FILTER_ALL ///< Iterate to end of store, filtering
} SearchMode;
/** Iterator over some range of a store */
struct SordIterImpl {
- const SordModel* sord; ///< Store this is an iterator for
- ZixTreeIter* cur; ///< Current DB cursor
- SordQuad pat; ///< Iteration pattern (in ordering order)
- int ordering[TUP_LEN]; ///< Store ordering
- SearchMode mode; ///< Iteration mode
- int n_prefix; ///< Length of range prefix (RANGE, FILTER_RANGE)
- bool end; ///< True iff reached end
- bool skip_graphs; ///< True iff iteration should ignore graphs
+ const SordModel* sord; ///< Store this is an iterator for
+ ZixTreeIter* cur; ///< Current DB cursor
+ SordQuad pat; ///< Iteration pattern (in ordering order)
+ int ordering[TUP_LEN]; ///< Store ordering
+ SearchMode mode; ///< Iteration mode
+ int n_prefix; ///< Length of range prefix (RANGE, FILTER_RANGE)
+ bool end; ///< True iff reached end
+ bool skip_graphs; ///< True iff iteration should ignore graphs
};
static unsigned
@@ -228,7 +228,7 @@ sord_node_compare(const SordNode* a, const SordNode* b)
}
return cmp;
default:
- break; // never reached
+ break; // never reached
}
assert(false);
return 0;
@@ -345,18 +345,18 @@ sord_iter_seek_match_range(SordIter* iter)
const SordNode** key = (const SordNode**)zix_tree_get(iter->cur);
if (sord_quad_match_inline(key, iter->pat))
- return false; // Found match
+ return false; // Found match
for (int i = 0; i < iter->n_prefix; ++i) {
const int idx = iter->ordering[i];
if (!sord_id_match(key[idx], iter->pat[idx])) {
- iter->end = true; // Reached end of valid range
+ iter->end = true; // Reached end of valid range
return true;
}
}
} while (!sord_iter_forward(iter));
- return (iter->end = true); // Reached end
+ return (iter->end = true); // Reached end
}
static SordIter*
@@ -396,7 +396,7 @@ sord_iter_new(const SordModel* sord, ZixTreeIter* cur, const SordQuad pat,
#ifdef SORD_DEBUG_ITER
SordQuad value;
sord_iter_get(iter, value);
- SORD_ITER_LOG("New %p pat=" TUP_FMT " cur=" TUP_FMT " end=%d skipgraphs=%d\n",
+ SORD_ITER_LOG("New %p pat=" TUP_FMT " cur=" TUP_FMT " end=%d skip=%d\n",
(void*)iter, TUP_FMT_ARGS(pat), TUP_FMT_ARGS(value),
iter->end, iter->skip_graphs);
#endif
@@ -469,7 +469,8 @@ sord_iter_next(SordIter* iter)
#ifdef SORD_DEBUG_ITER
SordQuad tup;
sord_iter_get(iter, tup);
- SORD_ITER_LOG("%p Increment to " TUP_FMT "\n", (void*)iter, TUP_FMT_ARGS(tup));
+ SORD_ITER_LOG("%p Increment to " TUP_FMT "\n",
+ (void*)iter, TUP_FMT_ARGS(tup));
#endif
return false;
}
@@ -768,7 +769,7 @@ sord_find(SordModel* sord, const SordQuad pat)
ordering[0], ordering[1], ordering[2], ordering[3]);
if (pat[0] && pat[1] && pat[2] && pat[3])
- mode = SINGLE; // No duplicate quads (Sord is a set)
+ mode = SINGLE; // No duplicate quads (Sord is a set)
ZixTree* const db = sord->indices[index_order];
ZixTreeIter* const cur = index_lower_bound(db, pat);
@@ -1056,7 +1057,7 @@ sord_node_from_serd_node(SordWorld* world,
buf[uri_len] = '\0';
SordNode* ret = sord_new_uri_counted(
world, buf, uri_prefix.len + uri_suffix.len,
- uri_prefix.len + uri_suffix.len); // FIXME: UTF-8
+ uri_prefix.len + uri_suffix.len); // FIXME: UTF-8
return ret;
}
case SERD_BLANK:
@@ -1115,9 +1116,9 @@ sord_add(SordModel* sord, const SordQuad tup)
for (unsigned i = 0; i < NUM_ORDERS; ++i) {
if (sord->indices[i]) {
if (!sord_add_to_index(sord, quad, i)) {
- assert(i == 0); // Assuming index coherency
+ assert(i == 0); // Assuming index coherency
free(quad);
- return false; // Quad already stored, do nothing
+ return false; // Quad already stored, do nothing
}
}
}
@@ -1145,8 +1146,8 @@ sord_remove(SordModel* sord, const SordQuad tup)
}
zix_tree_remove(sord->indices[i], cur);
} else {
- assert(i == 0); // Assuming index coherency
- return; // Quad not found, do nothing
+ assert(i == 0); // Assuming index coherency
+ return; // Quad not found, do nothing
}
}
}
diff --git a/src/sord_test.c b/src/sord_test.c
index b06fe19..cd6a6dc 100644
--- a/src/sord_test.c
+++ b/src/sord_test.c
@@ -24,7 +24,10 @@
static const int DIGITS = 3;
static const int MAX_NUM = 999;
-typedef struct { SordQuad query; int expected_num_results; } QueryTest;
+typedef struct {
+ SordQuad query;
+ int expected_num_results;
+} QueryTest;
#define USTR(s) ((const uint8_t*)(s))
@@ -35,7 +38,7 @@ uri(SordWorld* world, int num)
return 0;
char uri[] = "eg:000";
- char* uri_num = uri + 3; // First `0'
+ char* uri_num = uri + 3; // First `0'
snprintf(uri_num, DIGITS + 1, "%0*d", DIGITS, num);
return sord_new_uri(world, (const uint8_t*)uri);
}
@@ -266,7 +269,7 @@ main(int argc, char** argv)
static const size_t n_quads = 300;
static const int n_objects_per = 2;
- sord_free(NULL); // Shouldn't crash
+ sord_free(NULL); // Shouldn't crash
SordWorld* world = sord_world_new();
diff --git a/src/sordi.c b/src/sordi.c
index 9309e25..6339459 100644
--- a/src/sordi.c
+++ b/src/sordi.c
@@ -171,7 +171,7 @@ main(int argc, char** argv)
SerdURI base_uri = SERD_URI_NULL;
SerdNode base_uri_node = serd_node_new_uri_from_string(
base_uri_str, &base_uri, &base_uri);
-
+
if (!base_uri_node.buf) {
fprintf(stderr, "Invalid base URI <%s>\n", base_uri_str);
return 1;
diff --git a/src/syntax.c b/src/syntax.c
index d7e4195..eb9600f 100644
--- a/src/syntax.c
+++ b/src/syntax.c
@@ -140,7 +140,7 @@ write_statement(SordModel* sord, SerdWriter* writer, SordQuad tup,
}
SerdStatus st = SERD_SUCCESS;
- if (sord_node_is_inline_object(o)) {
+ if (sord_node_is_inline_object(o)) {
SordQuad sub_pat = { o, 0, 0, 0 };
SordIter* sub_iter = sord_find(sord, sub_pat);
diff --git a/src/zix/common.h b/src/zix/common.h
index a7edf76..7c8c942 100644
--- a/src/zix/common.h
+++ b/src/zix/common.h
@@ -60,7 +60,7 @@ typedef int (*ZixComparator)(const void* a, const void* b, void* user_data);
Function for testing equality of two elements.
*/
typedef bool (*ZixEqualFunc)(const void* a, const void* b);
-
+
/**@}
*/