mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-07-10 13:52:11 +02:00
Fix Cassandra schema and graph filter semantics (#680)
Schema fix (dtype/lang clustering key): - Add dtype and lang to PRIMARY KEY in quads_by_entity table - Add otype, dtype, lang to PRIMARY KEY in quads_by_collection table - Fixes deduplication bug where literals with same value but different datatype or language tag were collapsed (e.g., "thing" vs "thing"@en) - Update delete_collection to pass new clustering columns - Update tech spec to reflect new schema Graph filter semantics (simplified, no wildcard constant): - g=None means all graphs (no filter) - g="" means default graph only - g="uri" means specific named graph - Remove GRAPH_WILDCARD usage from EntityCentricKnowledgeGraph - Fix service.py streaming and non-streaming paths - Fix CLI to preserve empty string for -g '' argument
This commit is contained in:
parent
c951562189
commit
84941ce645
5 changed files with 102 additions and 65 deletions
|
|
@ -10,7 +10,7 @@ import json
|
|||
from cassandra.query import SimpleStatement
|
||||
|
||||
from .... direct.cassandra_kg import (
|
||||
EntityCentricKnowledgeGraph, GRAPH_WILDCARD, DEFAULT_GRAPH
|
||||
EntityCentricKnowledgeGraph, DEFAULT_GRAPH
|
||||
)
|
||||
from .... schema import TriplesQueryRequest, TriplesQueryResponse, Error
|
||||
from .... schema import Term, Triple, IRI, LITERAL, TRIPLE, BLANK
|
||||
|
|
@ -304,6 +304,13 @@ class Processor(TriplesQueryService):
|
|||
for t in resp:
|
||||
# Note: quads_by_collection uses 'd' for graph field
|
||||
g = t.d if hasattr(t, 'd') else DEFAULT_GRAPH
|
||||
# Filter by graph
|
||||
# g_val=None means all graphs (no filter)
|
||||
# g_val="" means default graph only
|
||||
# otherwise filter to specific named graph
|
||||
if g_val is not None:
|
||||
if g != g_val:
|
||||
continue
|
||||
term_type, datatype, language = get_object_metadata(t)
|
||||
quads.append((t.s, t.p, t.o, g, term_type, datatype, language))
|
||||
|
||||
|
|
@ -379,6 +386,15 @@ class Processor(TriplesQueryService):
|
|||
break
|
||||
|
||||
g = row.d if hasattr(row, 'd') else DEFAULT_GRAPH
|
||||
|
||||
# Filter by graph
|
||||
# g_val=None means all graphs (no filter)
|
||||
# g_val="" means default graph only
|
||||
# otherwise filter to specific named graph
|
||||
if g_val is not None:
|
||||
if g != g_val:
|
||||
continue
|
||||
|
||||
term_type, datatype, language = get_object_metadata(row)
|
||||
|
||||
# s and p are always IRIs in RDF
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue