Public Member Functions | |
| __construct (&$parentstore, &$dbslave) | |
| refreshConceptCache (Title $concept) | |
| Refresh the concept cache for the given concept. | |
| deleteConceptCache ($concept) | |
| Delete the concept cache for the given concept. | |
| getQueryResult (SMWQuery $query) | |
| The new SQL store's implementation of query answering. | |
Protected Member Functions | |
| getDebugQueryResult (SMWQuery $query, $rootid) | |
| Using a preprocessed internal query description referenced by $rootid, compute the proper debug output for the given query. | |
| getCountQueryResult (SMWQuery $query, $rootid) | |
| Using a preprocessed internal query description referenced by $rootid, compute the proper counting output for the given query. | |
| getInstanceQueryResult (SMWQuery $query, $rootid) | |
| Using a preprocessed internal query description referenced by $rootid, compute the proper result instance output for the given query. | |
| compileQueries (SMWDescription $description) | |
| Create a new SMWSQLStore2Query object that can be used to obtain results for the given description. | |
| compilePropertyCondition (SMWSQLStore2Query $query, SMWDIProperty $property, SMWDescription $valuedesc) | |
| Modify the given query object to account for some property condition for the given property. | |
| getDBFieldsForDVIndex (array $objectFields, $index, &$smwidjoinfield) | |
| Helper function for matching an index that refers to the DB keys (and thus signature) of a datatype to the database fields of a fitting property table (the objectfields array of which is given). | |
| compileAttributeWhere ($query, SMWDescription $description, SMWSQLStore2Table $proptable, $valueIndex, $operator= 'AND') | |
| Given an SMWDescription that is just a conjunction or disjunction of SMWValueDescription objects, create and return a plain WHERE condition string for it. | |
| executeQueries (SMWSQLStore2Query &$query) | |
| Process stored queries and change store accordingly. | |
| executeHierarchyQuery (SMWSQLStore2Query &$query) | |
| Find subproperties or subcategories. | |
| applyOrderConditions ($qid) | |
| This function modifies the given query object at $qid to account for all ordering conditions in the SMWQuery $query. | |
| getSQLOptions (SMWQuery $query, $rootid) | |
| Get a SQL option array for the given query and preprocessed query object at given id. | |
| cleanUp () | |
| After querying, make sure no temporary database tables are left. | |
| getCreateTempIDTableSQL ($tablename) | |
| Get SQL code suitable to create a temporary table of the given name, used to store ids. | |
Protected Attributes | |
| $m_dbs | |
| Database slave to be used. | |
| $m_store | |
| Parent SMWSQLStore2. | |
| $m_qmode | |
| Query mode copied from given query. | |
| $m_queries = array() | |
| Array of generated SMWSQLStore2Query query descriptions (index => object). | |
| $m_querylog = array() | |
| Array of arrays of executed queries, indexed by the temporary table names results were fed into. | |
| $m_sortkeys | |
| Array of sorting requests ("Property_name" => "ASC"/"DESC"). | |
| $m_hierarchies = array() | |
| Cache of computed hierarchy queries for reuse ("catetgory/property value string" => "tablename"). | |
| $m_errors = array() | |
| Local collection of error strings, passed on to callers if possible. | |
Definition at line 58 of file SMW_SQLStore2_Queries.php.
| SMWSQLStore2QueryEngine::__construct | ( | &$ | parentstore, | |
| &$ | dbslave | |||
| ) |
Definition at line 81 of file SMW_SQLStore2_Queries.php.
| SMWSQLStore2QueryEngine::refreshConceptCache | ( | Title $ | concept | ) |
Refresh the concept cache for the given concept.
| $concept | Title |
Definition at line 93 of file SMW_SQLStore2_Queries.php.
References SMWSQLStore2Query::$qnum, $smwgQConceptFeatures, $smwgQMaxLimit, cleanUp(), compileQueries(), executeQueries(), SMWQuery::MODE_INSTANCES, and SMWDIWikiPage::newFromTitle().
| SMWSQLStore2QueryEngine::deleteConceptCache | ( | $ | concept | ) |
Delete the concept cache for the given concept.
| $concept | Title |
Definition at line 173 of file SMW_SQLStore2_Queries.php.
| SMWSQLStore2QueryEngine::getQueryResult | ( | SMWQuery $ | query | ) |
The new SQL store's implementation of query answering.
This function works in two stages: First, the nested conditions of the given query object are preprocessed to compute an abstract representation of the SQL query that is to be executed. Since query conditions correspond to joins with property tables in most cases, this abstract representation is essentially graph-like description of how property tables are joined. Moreover, this graph is tree-shaped, since all query conditions are tree-shaped. Each part of this abstract query structure is represented by an SMWSQLStore2Query object in the array m_queries.
As a second stage of processing, the thus prepared SQL query is actually executed. Typically, this means that the joins are collapsed into one SQL query to retrieve results. In some cases, such as in dbug mode, the execution might be restricted and not actually perform the whole query.
The two-stage process helps to separate tasks, and it also allows for better optimisations: it is left to the execution engine how exactly the query result is to be obtained. For example, one could pre-compute partial suib-results in temporary tables (or even cache them somewhere), instead of passing one large join query to the DB (of course, it might be large only if the configuration of SMW allows it). For some DBMS, a step-wise execution of the query might lead to better performance, since it exploits the tree-structure of the joins, which is important for fast processing -- not all DBMS might be able in seeing this by themselves.
| SMWQuery | $query |
Definition at line 209 of file SMW_SQLStore2_Queries.php.
References SMWSQLStore2Query::$qnum, $smwgIgnoreQueryErrors, $smwgQSortingSupport, SMWQuery::addErrors(), applyOrderConditions(), cleanUp(), compileQueries(), executeQueries(), getCountQueryResult(), getDebugQueryResult(), getInstanceQueryResult(), SMWQuery::MODE_COUNT, SMWQuery::MODE_DEBUG, and SMWQuery::MODE_NONE.
| SMWSQLStore2QueryEngine::getDebugQueryResult | ( | SMWQuery $ | query, | |
| $ | rootid | |||
| ) | [protected] |
Using a preprocessed internal query description referenced by $rootid, compute the proper debug output for the given query.
| SMWQuery | $query | |
| integer | $rootid |
Definition at line 303 of file SMW_SQLStore2_Queries.php.
References SMWStore::formatDebugOutput(), and getSQLOptions().
Referenced by getQueryResult().
| SMWSQLStore2QueryEngine::getCountQueryResult | ( | SMWQuery $ | query, | |
| $ | rootid | |||
| ) | [protected] |
Using a preprocessed internal query description referenced by $rootid, compute the proper counting output for the given query.
| SMWQuery | $query | |
| integer | $rootid |
Definition at line 346 of file SMW_SQLStore2_Queries.php.
Referenced by getQueryResult().
| SMWSQLStore2QueryEngine::getInstanceQueryResult | ( | SMWQuery $ | query, | |
| $ | rootid | |||
| ) | [protected] |
Using a preprocessed internal query description referenced by $rootid, compute the proper result instance output for the given query.
| SMWQuery | $query | |
| integer | $rootid |
Definition at line 386 of file SMW_SQLStore2_Queries.php.
References SMWQuery::getDescription(), and getSQLOptions().
Referenced by getQueryResult().
| SMWSQLStore2QueryEngine::compileQueries | ( | SMWDescription $ | description | ) | [protected] |
Create a new SMWSQLStore2Query object that can be used to obtain results for the given description.
The result is stored in $this->m_queries using a numeric key that is returned as a result of the function. Returns -1 if no query was created.
| SMWDescription | $description |
Definition at line 447 of file SMW_SQLStore2_Queries.php.
References SMWSQLStore2Query::$qnum, $smwgQConceptCacheLifetime, $smwgQConceptCaching, $smwgQFeatures, $smwgQMaxDepth, $smwgQMaxSize, and compilePropertyCondition().
Referenced by applyOrderConditions(), compilePropertyCondition(), getQueryResult(), and refreshConceptCache().
| SMWSQLStore2QueryEngine::compilePropertyCondition | ( | SMWSQLStore2Query $ | query, | |
| SMWDIProperty $ | property, | |||
| SMWDescription $ | valuedesc | |||
| ) | [protected] |
Modify the given query object to account for some property condition for the given property.
If it is not possible to generate a query for the given data, the query type is changed to SMW_SQL2_NOQUERY. Callers need to check for this and discard the query in this case.
Definition at line 593 of file SMW_SQLStore2_Queries.php.
References SMWSQLStore2Query::$qnum, compileAttributeWhere(), compileQueries(), SMWSQLStore2::findPropertyTableID(), SMWDIProperty::findPropertyTypeID(), getDBFieldsForDVIndex(), SMWDIProperty::getKey(), SMWSQLStore2::getPropertyTables(), and SMWSQLStore2::getTypeSignature().
Referenced by compileQueries().
| SMWSQLStore2QueryEngine::getDBFieldsForDVIndex | ( | array $ | objectFields, | |
| $ | index, | |||
| &$ | smwidjoinfield | |||
| ) | [protected] |
Helper function for matching an index that refers to the DB keys (and thus signature) of a datatype to the database fields of a fitting property table (the objectfields array of which is given).
The $fieldname is set call-by-ref, where the parameter $smwidjoinfield is set to the field of $objectfields on which smw_ids.smw_id needs to be joined if $smwidjoinfield refers to a field in smw_ids. This might be needed for page-type values. If the value is not in smw_ids, then $fieldname refers to $objectfields and $smwidjoinfield is false. If the given index could not be matched, $fieldname is false.
| array | $objectFields | |
| integer | $index | |
| $smwidjoinfield |
Definition at line 706 of file SMW_SQLStore2_Queries.php.
Referenced by compileAttributeWhere(), and compilePropertyCondition().
| SMWSQLStore2QueryEngine::compileAttributeWhere | ( | $ | query, | |
| SMWDescription $ | description, | |||
| SMWSQLStore2Table $ | proptable, | |||
| $ | valueIndex, | |||
| $ | operator = 'AND' | |||
| ) | [protected] |
Given an SMWDescription that is just a conjunction or disjunction of SMWValueDescription objects, create and return a plain WHERE condition string for it.
| $query | ||
| SMWDescription | $description | |
| SMWSQLStore2Table | $proptable | |
| integer | $valueIndex | |
| string | $operator |
Definition at line 741 of file SMW_SQLStore2_Queries.php.
References getDBFieldsForDVIndex(), and SMWCompatibilityHelpers::getDBkeysFromDataItem().
Referenced by compilePropertyCondition().
| SMWSQLStore2QueryEngine::executeQueries | ( | SMWSQLStore2Query &$ | query | ) | [protected] |
Process stored queries and change store accordingly.
The query obj is modified so that it contains non-recursive description of a select to execute for getting the actual result.
| SMWSQLStore2Query | $query |
Definition at line 827 of file SMW_SQLStore2_Queries.php.
References executeHierarchyQuery(), getCreateTempIDTableSQL(), and SMWQuery::MODE_DEBUG.
Referenced by getQueryResult(), and refreshConceptCache().
| SMWSQLStore2QueryEngine::executeHierarchyQuery | ( | SMWSQLStore2Query &$ | query | ) | [protected] |
Find subproperties or subcategories.
This may require iterative computation, and temporary tables are used in many cases.
| SMWSQLStore2Query | $query |
Definition at line 962 of file SMW_SQLStore2_Queries.php.
References $smwgQSubcategoryDepth, $smwgQSubpropertyDepth, getCreateTempIDTableSQL(), and SMWQuery::MODE_DEBUG.
Referenced by executeQueries().
| SMWSQLStore2QueryEngine::applyOrderConditions | ( | $ | qid | ) | [protected] |
This function modifies the given query object at $qid to account for all ordering conditions in the SMWQuery $query.
It is always required that $qid is the id of a query that joins with smw_ids so that the field alias.smw_title is $available for default sorting.
| integer | $qid |
Definition at line 1063 of file SMW_SQLStore2_Queries.php.
References compileQueries(), and SMWPropertyValue::makeUserProperty().
Referenced by getQueryResult().
| SMWSQLStore2QueryEngine::getSQLOptions | ( | SMWQuery $ | query, | |
| $ | rootid | |||
| ) | [protected] |
Get a SQL option array for the given query and preprocessed query object at given id.
| SMWQuery | $query | |
| integer | $rootid |
Definition at line 1103 of file SMW_SQLStore2_Queries.php.
References $smwgQRandSortingSupport, and $smwgQSortingSupport.
Referenced by getDebugQueryResult(), and getInstanceQueryResult().
| SMWSQLStore2QueryEngine::cleanUp | ( | ) | [protected] |
After querying, make sure no temporary database tables are left.
Definition at line 1128 of file SMW_SQLStore2_Queries.php.
References SMWQuery::MODE_DEBUG.
Referenced by getQueryResult(), and refreshConceptCache().
| SMWSQLStore2QueryEngine::getCreateTempIDTableSQL | ( | $ | tablename | ) | [protected] |
Get SQL code suitable to create a temporary table of the given name, used to store ids.
MySQL can do that simply by creating new temporary tables. PostgreSQL first checks if such a table exists, so the code is ready to reuse existing tables if the code was modified to keep them after query answering. Also, PostgreSQL tables will use a RULE to achieve built-in duplicate elimination. The latter is done using INSERT IGNORE in MySQL.
| string | $tablename |
Definition at line 1146 of file SMW_SQLStore2_Queries.php.
Referenced by executeHierarchyQuery(), and executeQueries().
SMWSQLStore2QueryEngine::$m_dbs [protected] |
SMWSQLStore2QueryEngine::$m_store [protected] |
SMWSQLStore2QueryEngine::$m_qmode [protected] |
Query mode copied from given query.
Some submethods act differently when in SMWQuery::MODE_DEBUG.
Definition at line 65 of file SMW_SQLStore2_Queries.php.
SMWSQLStore2QueryEngine::$m_queries = array() [protected] |
Array of generated SMWSQLStore2Query query descriptions (index => object).
Definition at line 67 of file SMW_SQLStore2_Queries.php.
SMWSQLStore2QueryEngine::$m_querylog = array() [protected] |
Array of arrays of executed queries, indexed by the temporary table names results were fed into.
Definition at line 69 of file SMW_SQLStore2_Queries.php.
SMWSQLStore2QueryEngine::$m_sortkeys [protected] |
Array of sorting requests ("Property_name" => "ASC"/"DESC").
Used during query processing (where these property names are searched while compiling the query conditions).
Definition at line 75 of file SMW_SQLStore2_Queries.php.
SMWSQLStore2QueryEngine::$m_hierarchies = array() [protected] |
Cache of computed hierarchy queries for reuse ("catetgory/property value string" => "tablename").
Definition at line 77 of file SMW_SQLStore2_Queries.php.
SMWSQLStore2QueryEngine::$m_errors = array() [protected] |
Local collection of error strings, passed on to callers if possible.
Definition at line 79 of file SMW_SQLStore2_Queries.php.
1.5.6