diff options
author | David Robillard <d@drobilla.net> | 2011-02-04 00:57:51 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2011-02-04 00:57:51 +0000 |
commit | a161fecabd48e7b42c313dcc0132c7c5378d9ca2 (patch) | |
tree | e9dd7efd2c305c9134bd92d84958d339dfb93150 /src | |
parent | 0c7ba16331f4219dba705acd19d0cd3599e4e50d (diff) | |
download | sord-a161fecabd48e7b42c313dcc0132c7c5378d9ca2.tar.gz sord-a161fecabd48e7b42c313dcc0132c7c5378d9ca2.tar.bz2 sord-a161fecabd48e7b42c313dcc0132c7c5378d9ca2.zip |
Fix iterating over ranges within a graph.
git-svn-id: http://svn.drobilla.net/sord/trunk@17 3d64ff67-21c5-427c-a301-fe4f08042e5a
Diffstat (limited to 'src')
-rw-r--r-- | src/sord.c | 16 | ||||
-rw-r--r-- | src/syntax.c | 2 |
2 files changed, 13 insertions, 5 deletions
@@ -261,7 +261,7 @@ sord_iter_forward(SordIter iter) { if (!iter->skip_graphs) { iter->cur = g_sequence_iter_next(iter->cur); - return !g_sequence_iter_is_end(iter->cur); + return g_sequence_iter_is_end(iter->cur); } const SordID* key = (const SordID*)g_sequence_get(iter->cur); @@ -359,8 +359,9 @@ sord_iter_new(Sord sord, GSequenceIter* cur, const SordTuple pat, #ifdef SORD_DEBUG_ITER SordTuple value; sord_iter_get(iter, value); - SORD_ITER_LOG("New %p pat=" TUP_FMT " cur=" TUP_FMT " end=%d\n", (void*)iter, - TUP_FMT_ARGS(pat), TUP_FMT_ARGS(value), iter->end); + SORD_ITER_LOG("New %p pat=" TUP_FMT " cur=" TUP_FMT " end=%d skipgraphs=%d\n", + (void*)iter, TUP_FMT_ARGS(pat), TUP_FMT_ARGS(value), + iter->end, iter->skip_graphs); #endif return iter; } @@ -396,14 +397,17 @@ sord_iter_next(SordIter iter) break; case SINGLE: iter->end = true; + SORD_ITER_LOG("%p reached single end\n", (void*)iter); break; case RANGE: - // At the end if the MSN no longer matches + SORD_ITER_LOG("%p range next\n", (void*)iter); + // At the end if the MSNs no longer match key = (const SordID*)g_sequence_get(iter->cur); assert(key); for (int i = 0; i < iter->n_prefix; ++i) { if (!sord_id_match(key[i], iter->pat[i])) { iter->end = true; + SORD_ITER_LOG("%p reached non-match end\n", (void*)iter); break; } } @@ -417,6 +421,8 @@ sord_iter_next(SordIter iter) sord_iter_seek_match(iter); break; } + } else { + SORD_ITER_LOG("%p reached index end\n", (void*)iter); } if (iter->end) { @@ -730,7 +736,7 @@ sord_find(Sord sord, const SordTuple pat) const SordID c = pat[ordering[2]]; // ... const SordID d = pat[ordering[3]]; // Least Significant Node (LSN) - if (a && b && c) + if (a && b && c && d) mode = SINGLE; // No duplicate tuples (Sord is a set) SordTuple search_key = { a, b, c, d }; diff --git a/src/syntax.c b/src/syntax.c index 47e2d52..ac1a766 100644 --- a/src/syntax.c +++ b/src/syntax.c @@ -15,6 +15,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include <assert.h> #include <stdlib.h> #include <string.h> @@ -164,6 +165,7 @@ event_statement(void* handle, tup[2] = object_node; if (state->graph_uri_node) { + assert(graph->type == SERD_NOTHING); tup[3] = state->graph_uri_node; } else { tup[3] = (graph && graph->buf) |