Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extensive use of fx:anySlot - query not terminating #154

Closed
enridaga opened this issue Nov 24, 2021 · 1 comment
Closed

Extensive use of fx:anySlot - query not terminating #154

enridaga opened this issue Nov 24, 2021 · 1 comment
Labels
Bug Something isn't working

Comments

@enridaga
Copy link
Member

We stumbled on one query using fx:anySlot extensively, which does not terminate.

The query:

PREFIX fx: <http://sparql.xyz/facade-x/ns/>
PREFIX xyz: <http://sparql.xyz/facade-x/data/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX tsub: <http://sparql.xyz/example/tate/topic/>
PREFIX schema: <http://schema.org/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

CONSTRUCT {
	?artwork schema:about ?topic .
	?topic schema:name ?name .
} WHERE {
  SERVICE <x-sparql-anything:location=./a00002-1036.xml> {
	[] a xyz:children; fx:anySlot [a xyz:item; fx:anySlot [ a xyz:id; fx:anySlot ?topicId]; fx:anySlot [ a xyz:name; fx:anySlot ?name ]] .
#     The alternative without fx:anySlot works
#	[] a xyz:children; ?li1 [a xyz:item; ?li2 [ a xyz:id; ?li3 ?topicId]; ?li4 [ a xyz:name; ?li5 ?name ]] .
#     This pattern uses fx:anySlot once but does not seem to create problems (leaving this one only works)
	[] a xyz:url; fx:anySlot ?artworkUrl .
	BIND(IRI(?artworkUrl) as ?artwork) .
	BIND(IRI(CONCAT(STR(tsub:),STR(?topicId))) AS ?topic) .
	FILTER (?topicId != xyz:id) .
	FILTER (?name != xyz:name) .
	FILTER (?artworkUrl != xyz:url) .
  }
}

The data:

<artwork>
	<acno>A00002</acno>
	<acquisitionYear>1922</acquisitionYear>
	<creator>
		<name>Robert Blake</name>
		<birthYear>1762</birthYear>
		<gender>Male</gender>
		<id>38</id>
	</creator>
	<creditLine>Presented by Mrs John Richmond 1992</creditLine>
	<height>213</height>
	<id>1036</id>
	<medium>Graphite on paper</medium>
	<topics>
		<children>
			<children>
				<children>
					<item>
						<id>273</id>
						<name>comforting</name>
					</item>
					<item>
						<id>544</id>
						<name>embracing</name>
					</item>
					<item>
						<id>2653</id>
						<name>recoiling</name>
					</item>
				</children>
				<item>
					<id>177</id>
					<name>actions: expressive</name>
				</item>
			</children>
			<children>
				<children>
					<item>
						<id>451</id>
						<name>figure</name>
					</item>
				</children>
				<item>
					<id>95</id>
					<name>adults</name>
				</item>
			</children>
			<children>
				<children>
					<item>
						<id>799</id>
						<name>group</name>
					</item>
				</children>
				<item>
					<id>97</id>
					<name>groups</name>
				</item>
			</children>
			<item>
				<id>91</id>
				<name>people</name>
			</item>
		</children>
		<children>
			<children>
				<children>
					<item>
						<id>2815</id>
						<name>fear</name>
					</item>
				</children>
				<item>
					<id>31</id>
					<name>emotions and human qualities</name>
				</item>
			</children>
			<item>
				<id>29</id>
				<name>emotions, concepts and ideas</name>
			</item>
		</children>
		<item>
			<id>1</id>
			<name>topicRoot</name>
		</item>
	</topics>
	<title>Two Drawings of Frightened Figures, Probably for 'The Approach of Doom'</title>
	<units>mm</units>
	<url>https://www.tate.org.uk/art/artworks/blake-two-drawings-of-frightened-figures-probably-for-the-approach-of-doom-a00002</url>
	<width>311</width>
</artwork>

The query plan:

  (filter (exprlist (!= ?topicId <http://sparql.xyz/facade-x/data/id>) (!= ?name <http://sparql.xyz/facade-x/data/name>) (!= ?artworkUrl <http://sparql.xyz/facade-x/data/url>))
    (extend ((?topic (iri (concat "http://sparql.xyz/example/tate/topic/" (str ?topicId)))))
      (extend ((?artwork (iri ?artworkUrl)))
        (bgp
          (triple ??0 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://sparql.xyz/facade-x/data/children>)
          (triple ??0 <http://sparql.xyz/facade-x/ns/anySlot> ??1)
          (triple ??1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://sparql.xyz/facade-x/data/item>)
          (triple ??1 <http://sparql.xyz/facade-x/ns/anySlot> ??2)
          (triple ??2 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://sparql.xyz/facade-x/data/id>)
          (triple ??2 <http://sparql.xyz/facade-x/ns/anySlot> ?topicId)
          (triple ??1 <http://sparql.xyz/facade-x/ns/anySlot> ??3)
          (triple ??3 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://sparql.xyz/facade-x/data/name>)
          (triple ??3 <http://sparql.xyz/facade-x/ns/anySlot> ?name)
          (triple ??4 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://sparql.xyz/facade-x/data/url>)
          (triple ??4 <http://sparql.xyz/facade-x/ns/anySlot> ?artworkUrl)
        )))))

enridaga added a commit that referenced this issue Nov 24, 2021
@enridaga enridaga added the Bug Something isn't working label Dec 3, 2021
@luigi-asprino
Copy link
Member

The engine instantiated the triple pattern for evaluating the fx:anySlot property wrongly (subject and object were considered wildcards even if they were blank nodes).

luigi-asprino added a commit that referenced this issue Dec 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants