SMWSQLStoreLight Class Reference
[SMWStore]

Storage access class for using the standard MediaWiki SQL database for keeping semantic data. More...

Inherits SMWStore.

List of all members.

Public Member Functions

 getSemanticData ($subject, $filter=false)
 getPropertyValues ($subject, SMWDIProperty $property, $requestoptions=null, $outputformat= '')
 getPropertySubjects (SMWDIProperty $property, $value, $requestoptions=null)
 Get an array of all subjects that have the given value for the given property.
 getAllPropertySubjects (SMWDIProperty $property, $requestoptions=null)
 Get an array of all subjects that have some value for the given property.
 getProperties ($subject, $requestoptions=null)
 getInProperties (SMWDataValue $value, $requestoptions=null)
 Implementation of SMWStore::getInProperties().
 deleteSubject (Title $subject)
 Delete all semantic properties that the given subject has.
 doDataUpdate (SMWSemanticData $data)
 Update the semantic data stored for some individual.
 changeTitle (Title $oldtitle, Title $newtitle, $pageid, $redirid=0)
 Update the store to reflect a renaming of some article.
 getQueryResult (SMWQuery $query)
 Execute the provided query and return the result as an SMWQueryResult if the query was a usual instance retrieval query.
 getPropertiesSpecial ($requestoptions=null)
 Return all properties that have been used on pages in the wiki.
 getUnusedPropertiesSpecial ($requestoptions=null)
 Return all properties that have been declared in the wiki but that are not used on any page.
 getWantedPropertiesSpecial ($requestoptions=null)
 Return all properties that are used on some page but that do not have any page describing them.
 getStatistics ()
 Return statistical information as an associative array with the following keys:
  • 'PROPUSES': Number of property instances (value assignments) in the datatbase
  • 'USEDPROPS': Number of properties that are used with at least one value
  • 'DECLPROPS': Number of properties that have been declared (i.e.

 setup ($verbose=true)
 Setup all storage structures properly for using the store.
 drop ($verbose=true)
 Drop (delete) all storage structures created by setup().
 refreshData (&$index, $count, $namespaces=false, $usejobs=true)
 Refresh some objects in the store, addressed by numerical ids.
 refreshConceptCache ($concept)
 Refresh the concept cache for the given concept.
 deleteConceptCache ($concept)
 Delete the concept cache for the given concept.
 getConceptCacheStatus ($concept)
 Return status of the concept cache for the given concept as an array with key 'status' ('empty': not cached, 'full': cached, 'no': not cachable).
 reportProgress ($msg, $verbose=true)
 Print some output to indicate progress.

Static Public Member Functions

static findPropertyTableName ($property)
 Retrieve the name of the property table that is to be used for storing values for the given property object.
static findTypeTableName ($typeid)
 Retrieve the name of the property table that is to be used for storing values for the given property object.

Protected Member Functions

 setupTables ($verbose, $db)
 Create required SQL tables.
 getSQLOptions ($requestoptions, $valuecol= '')
 Transform input parameters into a suitable array of SQL options.
 getSQLConditions ($requestoptions, $valuecol= '', $labelcol= '', $addand=true)
 Transform input parameters into a suitable string of additional SQL conditions.
 applyRequestOptions ($data, $requestoptions)
 Not in all cases can requestoptions be forwarded to the DB using getSQLConditions() and getSQLOptions(): some data comes from caches that do not respect the options yet.
 deleteSemanticData (SMWWikiPageValue $subject)
 Delete all semantic data stored for the given subject.

Protected Attributes

 $m_semdata = array()
 Cache for SMWSemanticData objects, indexed by page ID.
 $m_sdstate = array()
 Like SMWSQLStoreLight::m_semdata, but containing arrays for indicating completeness of the SMWSemanticData objs.

Static Protected Attributes

static $in_getSemanticData = 0
 >0 while getSemanticData runs, used to prevent nested calls from clearing the cache while another call runs and is about to fill it with data

Static Private Attributes

static $special_types
 Data for which type ids should be stored in the special table? Special values must only have one DB key, stored as a 256byte string.


Detailed Description

Storage access class for using the standard MediaWiki SQL database for keeping semantic data.

This is a lightweight version of SMW's standard storage implementation, providing only basic data storage and retrieval but no querying (and no concept caching) or statistics.

Todo:
This implementation is not completed yet and should be considered experimental.

Definition at line 24 of file SMW_SQLStoreLight.php.


Member Function Documentation

SMWSQLStoreLight::getSemanticData ( subject,
filter = false 
)

TODO: can this still occur?

Definition at line 46 of file SMW_SQLStoreLight.php.

References $db, $filter, $in_getSemanticData, findTypeTableName(), and SMWWikiPageValue::makePageFromTitle().

Referenced by getPropertyValues().

SMWSQLStoreLight::getPropertyValues ( subject,
SMWDIProperty property,
requestoptions = null,
outputformat = '' 
)

SMWSQLStoreLight::getPropertySubjects ( SMWDIProperty property,
value,
requestoptions = null 
)

Get an array of all subjects that have the given value for the given property.

The result is an array of SMWDIWikiPage objects. If null is given as a value, all subjects having that property are returned.

Reimplemented from SMWStore.

Definition at line 138 of file SMW_SQLStoreLight.php.

References $db, findPropertyTableName(), getPropertyValues(), getSQLConditions(), getSQLOptions(), and SMWWikiPageValue::makePage().

Referenced by getAllPropertySubjects(), and getPropertyValues().

SMWSQLStoreLight::getAllPropertySubjects ( SMWDIProperty property,
requestoptions = null 
)

Get an array of all subjects that have some value for the given property.

The result is an array of SMWDIWikiPage objects.

Reimplemented from SMWStore.

Definition at line 172 of file SMW_SQLStoreLight.php.

References getPropertySubjects().

SMWSQLStoreLight::getProperties ( subject,
requestoptions = null 
)

Todo:
Restrict this function to SMWWikiPageValue subjects.

Definition at line 182 of file SMW_SQLStoreLight.php.

References $db, applyRequestOptions(), getSQLConditions(), and getSQLOptions().

Referenced by doDataUpdate().

SMWSQLStoreLight::getInProperties ( SMWDataValue value,
requestoptions = null 
)

Implementation of SMWStore::getInProperties().

This function is meant to be used for finding properties that link to wiki pages.

Todo:
When used for other datatypes, the function may return too many properties since it selects results by comparing the stored information (DB keys) only, while not currently comparing the type of the returned property to the type of the queried data. So values with the same DB keys can be confused. This is a minor issue now since no code is known to use this function in cases where this occurs.

Definition at line 223 of file SMW_SQLStoreLight.php.

References $db, applyRequestOptions(), findTypeTableName(), getSQLConditions(), getSQLOptions(), and SMWDataValue::getTypeID().

SMWSQLStoreLight::deleteSubject ( Title $  subject  ) 

Delete all semantic properties that the given subject has.

This includes relations, attributes, and special properties. This does not delete the respective text from the wiki, but only clears the stored data.

Parameters:
Title $subject

Reimplemented from SMWStore.

Definition at line 255 of file SMW_SQLStoreLight.php.

References deleteSemanticData(), and SMWWikiPageValue::makePageFromTitle().

SMWSQLStoreLight::doDataUpdate ( SMWSemanticData data  ) 

Update the semantic data stored for some individual.

The data is given as a SMWSemanticData object, which contains all semantic data for one particular subject.

Parameters:
SMWSemanticData $data

Reimplemented from SMWStore.

Definition at line 266 of file SMW_SQLStoreLight.php.

References $db, deleteSemanticData(), findPropertyTableName(), getProperties(), getPropertyValues(), and SMWSemanticData::getSubject().

SMWSQLStoreLight::changeTitle ( Title $  oldtitle,
Title $  newtitle,
pageid,
redirid = 0 
)

Update the store to reflect a renaming of some article.

Normally this happens when moving pages in the wiki, and in this case there is also a new redirect page generated at the old position. The title objects given are only used to specify the name of the title before and after the move -- do not use their IDs for anything! The ID of the moved page is given in $pageid, and the ID of the newly created redirect, if any, is given by $redirid. If no new page was created, $redirid will be 0.

Reimplemented from SMWStore.

Definition at line 301 of file SMW_SQLStoreLight.php.

SMWSQLStoreLight::getQueryResult ( SMWQuery query  ) 

Execute the provided query and return the result as an SMWQueryResult if the query was a usual instance retrieval query.

In the case that the query asked for a plain string (querymode MODE_COUNT or MODE_DEBUG) a plain wiki and HTML-compatible string is returned.

Parameters:
SMWQuery $query
Returns:
SMWQueryResult

Reimplemented from SMWStore.

Definition at line 316 of file SMW_SQLStoreLight.php.

SMWSQLStoreLight::getPropertiesSpecial ( requestoptions = null  ) 

Return all properties that have been used on pages in the wiki.

The result is an array of arrays, each containing a property title and a count. The expected order is alphabetical w.r.t. to property title texts.

Parameters:
SMWRequestOptions $requestoptions
Returns:
array

Reimplemented from SMWStore.

Definition at line 322 of file SMW_SQLStoreLight.php.

SMWSQLStoreLight::getUnusedPropertiesSpecial ( requestoptions = null  ) 

Return all properties that have been declared in the wiki but that are not used on any page.

Stores might restrict here to those properties that have been given a type if they have no efficient means of accessing the set of all pages in the property namespace.

Parameters:
SMWRequestOptions $requestoptions
Returns:
array of SMWDIProperty

Reimplemented from SMWStore.

Definition at line 326 of file SMW_SQLStoreLight.php.

SMWSQLStoreLight::getWantedPropertiesSpecial ( requestoptions = null  ) 

Return all properties that are used on some page but that do not have any page describing them.

Stores that have no efficient way of accessing the set of all existing pages can extend this list to all properties that are used but do not have a type assigned to them.

Parameters:
SMWRequestOptions $requestoptions
Returns:
array of array( SMWDIProperty, int )

Reimplemented from SMWStore.

Definition at line 330 of file SMW_SQLStoreLight.php.

SMWSQLStoreLight::getStatistics (  ) 

Return statistical information as an associative array with the following keys:

  • 'PROPUSES': Number of property instances (value assignments) in the datatbase
  • 'USEDPROPS': Number of properties that are used with at least one value
  • 'DECLPROPS': Number of properties that have been declared (i.e.

assigned a type)

Returns:
array

Reimplemented from SMWStore.

Definition at line 334 of file SMW_SQLStoreLight.php.

SMWSQLStoreLight::setup ( verbose = true  ) 

Setup all storage structures properly for using the store.

This function performs tasks like creation of database tables. It is called upon installation as well as on upgrade: hence it must be able to upgrade existing storage structures if needed. It should return "true" if successful and return a meaningful string error message otherwise.

The parameter $verbose determines whether the procedure is allowed to report on its progress. This is doen by just using print and possibly ob_flush/flush. This is also relevant for preventing timeouts during long operations. All output must be valid in an HTML context, but should preferrably be plain text, possibly with some linebreaks and weak markup.

Parameters:
boolean $verbose

Reimplemented from SMWStore.

Definition at line 340 of file SMW_SQLStoreLight.php.

References $db, reportProgress(), and setupTables().

SMWSQLStoreLight::setupTables ( verbose,
db 
) [protected]

Create required SQL tables.

This function also performs upgrades of table contents when required.

Definition at line 352 of file SMW_SQLStoreLight.php.

References $db, SMWSQLHelpers::getStandardDBType(), reportProgress(), SMWSQLHelpers::setupIndex(), and SMWSQLHelpers::setupTable().

Referenced by setup().

SMWSQLStoreLight::drop ( verbose = true  ) 

Drop (delete) all storage structures created by setup().

This will delete all semantic data and possibly leave the wiki uninitialised.

Parameters:
boolean $verbose

Reimplemented from SMWStore.

Definition at line 381 of file SMW_SQLStoreLight.php.

References $db, and reportProgress().

SMWSQLStoreLight::refreshData ( &$  index,
count,
namespaces = false,
usejobs = true 
)

Refresh some objects in the store, addressed by numerical ids.

The meaning of the ids is private to the store, and does not need to reflect the use of IDs elsewhere (e.g. page ids). The store is to refresh $count objects starting from the given $index. Typically, updates are achieved by generating update jobs. After the operation, $index is set to the next index that should be used for continuing refreshing, or to -1 for signaling that no objects of higher index require refresh. The method returns a decimal number between 0 and 1 to indicate the overall progress of the refreshing (e.g. 0.7 if 70% of all objects were refreshed).

The optional parameter $namespaces may contain an array of namespace constants. If given, only objects from those namespaces will be refreshed. The default value FALSE disables this feature.

The optional parameter $usejobs indicates whether updates should be processed later using MediaWiki jobs, instead of doing all updates immediately. The default is TRUE.

Parameters:
$index integer
$count integer
$namespaces mixed array or false
$usejobs boolean
Returns:
decimal between 0 and 1 to indicate the overall progress of the refreshing

Reimplemented from SMWStore.

Definition at line 395 of file SMW_SQLStoreLight.php.

References $db.

SMWSQLStoreLight::refreshConceptCache ( concept  ) 

Refresh the concept cache for the given concept.

Parameters:
$concept Title

Definition at line 440 of file SMW_SQLStoreLight.php.

SMWSQLStoreLight::deleteConceptCache ( concept  ) 

Delete the concept cache for the given concept.

Parameters:
$concept Title

Definition at line 449 of file SMW_SQLStoreLight.php.

SMWSQLStoreLight::getConceptCacheStatus ( concept  ) 

Return status of the concept cache for the given concept as an array with key 'status' ('empty': not cached, 'full': cached, 'no': not cachable).

If status is not 'no', the array also contains keys 'size' (query size), 'depth' (query depth), 'features' (query features). If status is 'full', the array also contains keys 'date' (timestamp of cache), 'count' (number of results in cache).

Parameters:
$concept Title or SMWWikiPageValue

Definition at line 463 of file SMW_SQLStoreLight.php.

SMWSQLStoreLight::getSQLOptions ( requestoptions,
valuecol = '' 
) [protected]

Transform input parameters into a suitable array of SQL options.

The parameter $valuecol defines the string name of the column to which sorting requests etc. are to be applied.

Definition at line 475 of file SMW_SQLStoreLight.php.

Referenced by getInProperties(), getProperties(), getPropertySubjects(), and getPropertyValues().

SMWSQLStoreLight::getSQLConditions ( requestoptions,
valuecol = '',
labelcol = '',
addand = true 
) [protected]

Transform input parameters into a suitable string of additional SQL conditions.

The parameter $valuecol defines the string name of the column to which value restrictions etc. are to be applied.

Parameters:
$requestoptions object with options
$valuecol name of SQL column to which conditions apply
$labelcol name of SQL column to which string conditions apply, if any
$addand Boolean to indicate whether the string should begin with " AND " if non-empty

TODO avoid doing this here again, all callers should have one

Definition at line 500 of file SMW_SQLStoreLight.php.

References $db, SMWStringCondition::STRCOND_MID, SMWStringCondition::STRCOND_POST, and SMWStringCondition::STRCOND_PRE.

Referenced by getInProperties(), getProperties(), and getPropertySubjects().

SMWSQLStoreLight::applyRequestOptions ( data,
requestoptions 
) [protected]

Not in all cases can requestoptions be forwarded to the DB using getSQLConditions() and getSQLOptions(): some data comes from caches that do not respect the options yet.

This method takes an array of results (SMWDataValue objects) *of the same type* and applies the given requestoptions as appropriate.

Definition at line 534 of file SMW_SQLStoreLight.php.

References findTypeTableName(), SMWStringCondition::STRCOND_MID, SMWStringCondition::STRCOND_POST, and SMWStringCondition::STRCOND_PRE.

Referenced by getInProperties(), getProperties(), and getPropertyValues().

SMWSQLStoreLight::reportProgress ( msg,
verbose = true 
)

Print some output to indicate progress.

The output message is given by $msg, while $verbose indicates whether or not output is desired at all.

Definition at line 609 of file SMW_SQLStoreLight.php.

Referenced by drop(), setup(), and setupTables().

static SMWSQLStoreLight::findPropertyTableName ( property  )  [static]

Retrieve the name of the property table that is to be used for storing values for the given property object.

Definition at line 624 of file SMW_SQLStoreLight.php.

References findTypeTableName().

Referenced by doDataUpdate(), getPropertySubjects(), and getPropertyValues().

static SMWSQLStoreLight::findTypeTableName ( typeid  )  [static]

Retrieve the name of the property table that is to be used for storing values for the given property object.

Definition at line 632 of file SMW_SQLStoreLight.php.

References $special_types.

Referenced by applyRequestOptions(), findPropertyTableName(), getInProperties(), and getSemanticData().

SMWSQLStoreLight::deleteSemanticData ( SMWWikiPageValue subject  )  [protected]

Delete all semantic data stored for the given subject.

Used for update purposes.

Definition at line 644 of file SMW_SQLStoreLight.php.

References $db, and SMWWikiPageValue::getTitle().

Referenced by deleteSubject(), and doDataUpdate().


Member Data Documentation

SMWSQLStoreLight::$m_semdata = array() [protected]

Cache for SMWSemanticData objects, indexed by page ID.

Definition at line 27 of file SMW_SQLStoreLight.php.

SMWSQLStoreLight::$m_sdstate = array() [protected]

Like SMWSQLStoreLight::m_semdata, but containing arrays for indicating completeness of the SMWSemanticData objs.

Definition at line 29 of file SMW_SQLStoreLight.php.

SMWSQLStoreLight::$in_getSemanticData = 0 [static, protected]

>0 while getSemanticData runs, used to prevent nested calls from clearing the cache while another call runs and is about to fill it with data

Definition at line 31 of file SMW_SQLStoreLight.php.

Referenced by getSemanticData().

SMWSQLStoreLight::$special_types [static, private]

Initial value:

 array(
                '__typ' => true, // Special type page type
                '__tls' => true, // Special type list for _rec properties
                '__sps' => true, // Special string type
                '__spu' => true, // Special uri type
                '__spf' => true, // Special form type (for Semantic Forms)
                '__imp' => true, // Special import vocabulary type
        )
Data for which type ids should be stored in the special table? Special values must only have one DB key, stored as a 256byte string.

Definition at line 35 of file SMW_SQLStoreLight.php.

Referenced by findTypeTableName().


The documentation for this class was generated from the following file:

Generated on Sun Mar 18 07:15:45 2012 for Semantic MediaWiki by  doxygen 1.5.6