r87826 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r87825‎ | r87826 | r87827 >
Date:16:32, 10 May 2011
Author:mkroetzsch
Status:deferred
Tags:
Comment:
+documentation
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SparqlStoreQueryEngine.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SparqlStoreQueryEngine.php
@@ -256,10 +256,21 @@
257257 */
258258 protected $m_store;
259259
 260+ /**
 261+ * Constructor.
 262+ *
 263+ * @param $store SMWStore that this object will use
 264+ */
260265 public function __construct( SMWStore $store ) {
261266 $this->m_store = $store;
262267 }
263268
 269+ /**
 270+ * Get the output number for a query in counting mode.
 271+ *
 272+ * @param $query SMWQuery
 273+ * @return integer
 274+ */
264275 public function getCountQueryResult( SMWQuery $query ) {
265276 $this->m_sortkeys = array(); // ignore sorting, just count
266277 $sparqlCondition = $this->getSparqlCondition( $query->getDescription() );
@@ -294,6 +305,12 @@
295306 }
296307 }
297308
 309+ /**
 310+ * Get the results for a query in instance retrieval mode.
 311+ *
 312+ * @param $query SMWQuery
 313+ * @return SMWQueryResult
 314+ */
298315 public function getInstanceQueryResult( SMWQuery $query ) {
299316 $this->m_sortkeys = $query->sortkeys;
300317 $sparqlCondition = $this->getSparqlCondition( $query->getDescription() );
@@ -326,6 +343,12 @@
327344 return $this->getQueryResultFromSparqlResult( $sparqlResultWrapper, $query );
328345 }
329346
 347+ /**
 348+ * Get the output string for a query in debugging mode.
 349+ *
 350+ * @param $query SMWQuery
 351+ * @return string
 352+ */
330353 public function getDebugQueryResult( SMWQuery $query ) {
331354 $this->m_sortkeys = $query->sortkeys;
332355 $sparqlCondition = $this->getSparqlCondition( $query->getDescription() );
@@ -424,6 +447,15 @@
425448 return $result;
426449 }
427450
 451+ /**
 452+ * Get a SMWSparqlCondition object for an SMWDescription.
 453+ * This conversion is implemented by a number of recursive functions,
 454+ * and this is the main entry point for this recursion. In particular,
 455+ * it resets global variables that are used for the construction.
 456+ *
 457+ * @param $description SMWDescription
 458+ * @return SMWSparqlCondition
 459+ */
428460 protected function getSparqlCondition( SMWDescription $description ) {
429461 $this->m_variableCounter = 0;
430462 $this->m_orderVariables = array();
@@ -433,7 +465,15 @@
434466 }
435467
436468 /**
437 - * Create an SMWSparqlCondition from the given SMWDescription.
 469+ * Recursively create an SMWSparqlCondition from an SMWDescription.
 470+ *
 471+ * @param $description SMWDescription
 472+ * @param $joinVariable string name of the variable that conditions
 473+ * will refer to
 474+ * @param $orderByProperty mixed SMWDIProperty or null, if given then
 475+ * this is the property the values of which this condition will refer
 476+ * to, and the condition should also enable ordering by this value
 477+ * @return SMWSparqlCondition
438478 */
439479 protected function buildSparqlCondition( SMWDescription $description, $joinVariable, $orderByProperty ) {
440480 if ( $description instanceof SMWSomeProperty ) {
@@ -455,6 +495,14 @@
456496 }
457497 }
458498
 499+ /**
 500+ * Recursively create an SMWSparqlCondition from an SMWConjunction.
 501+ *
 502+ * @param $description SMWConjunction
 503+ * @param $joinVariable string name, see buildSparqlCondition()
 504+ * @param $orderByProperty mixed SMWDIProperty or null, see buildSparqlCondition()
 505+ * @return SMWSparqlCondition
 506+ */
459507 protected function buildConjunctionCondition( SMWConjunction $description, $joinVariable, $orderByProperty ) {
460508 $subDescriptions = $description->getDescriptions();
461509 if ( count( $subDescriptions ) == 0 ) { // empty conjunction: true
@@ -521,6 +569,14 @@
522570 return $result;
523571 }
524572
 573+ /**
 574+ * Recursively create an SMWSparqlCondition from an SMWDisjunction.
 575+ *
 576+ * @param $description SMWDisjunction
 577+ * @param $joinVariable string name, see buildSparqlCondition()
 578+ * @param $orderByProperty mixed SMWDIProperty or null, see buildSparqlCondition()
 579+ * @return SMWSparqlCondition
 580+ */
525581 protected function buildDisjunctionCondition( SMWDisjunction $description, $joinVariable, $orderByProperty ) {
526582 $subDescriptions = $description->getDescriptions();
527583 if ( count( $subDescriptions ) == 0 ) { // empty disjunction: false
@@ -584,6 +640,14 @@
585641
586642 }
587643
 644+ /**
 645+ * Recursively create an SMWSparqlCondition from an SMWSomeProperty.
 646+ *
 647+ * @param $description SMWSomeProperty
 648+ * @param $joinVariable string name, see buildSparqlCondition()
 649+ * @param $orderByProperty mixed SMWDIProperty or null, see buildSparqlCondition()
 650+ * @return SMWSparqlCondition
 651+ */
588652 protected function buildPropertyCondition( SMWSomeProperty $description, $joinVariable, $orderByProperty ) {
589653 $diProperty = $description->getProperty();
590654
@@ -642,6 +706,14 @@
643707 return $result;
644708 }
645709
 710+ /**
 711+ * Create an SMWSparqlCondition from an SMWClassDescription.
 712+ *
 713+ * @param $description SMWClassDescription
 714+ * @param $joinVariable string name, see buildSparqlCondition()
 715+ * @param $orderByProperty mixed SMWDIProperty or null, see buildSparqlCondition()
 716+ * @return SMWSparqlCondition
 717+ */
646718 protected function buildClassCondition( SMWClassDescription $description, $joinVariable, $orderByProperty ) {
647719 $condition = '';
648720 $namespaces = array();
@@ -669,6 +741,14 @@
670742 return $result;
671743 }
672744
 745+ /**
 746+ * Create an SMWSparqlCondition from an SMWValueDescription.
 747+ *
 748+ * @param $description SMWValueDescription
 749+ * @param $joinVariable string name, see buildSparqlCondition()
 750+ * @param $orderByProperty mixed SMWDIProperty or null, see buildSparqlCondition()
 751+ * @return SMWSparqlCondition
 752+ */
673753 protected function buildValueCondition( SMWValueDescription $description, $joinVariable, $orderByProperty ) {
674754 $dataItem = $description->getDataItem();
675755 $expElement = SMWExporter::getDataItemExpElement( $dataItem );
@@ -704,12 +784,25 @@
705785 return $result;
706786 }
707787
 788+ /**
 789+ * Create an SMWSparqlCondition from an empty (true) description.
 790+ * May still require helper conditions for ordering.
 791+ *
 792+ * @param $joinVariable string name, see buildSparqlCondition()
 793+ * @param $orderByProperty mixed SMWDIProperty or null, see buildSparqlCondition()
 794+ * @return SMWSparqlCondition
 795+ */
708796 protected function buildTrueCondition( $joinVariable, $orderByProperty ) {
709797 $result = new SMWSparqlTrueCondition();
710798 $this->addOrderByDataForProperty( $result, $joinVariable, $orderByProperty );
711799 return $result;
712800 }
713801
 802+ /**
 803+ * Get a fresh unused variable name for building SPARQL conditions.
 804+ *
 805+ * @return string
 806+ */
714807 protected function getNextVariable() {
715808 return 'v' . ( ++$this->m_variableCounter );
716809 }

Status & tagging log