You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@clerezza.apache.org by re...@apache.org on 2011/03/06 18:32:34 UTC
svn commit: r1078521 - in
/incubator/clerezza/issues/CLEREZZA-388/rdf.cris/core/src/main/scala/org/apache/clerezza/rdf/cris:
GraphIndexer.scala VirtualProperty.scala
Author: reto
Date: Sun Mar 6 17:32:33 2011
New Revision: 1078521
URL: http://svn.apache.org/viewvc?rev=1078521&view=rev
Log:
CLEREZZA-388: recreating index when base property of virtual property changed
Modified:
incubator/clerezza/issues/CLEREZZA-388/rdf.cris/core/src/main/scala/org/apache/clerezza/rdf/cris/GraphIndexer.scala
incubator/clerezza/issues/CLEREZZA-388/rdf.cris/core/src/main/scala/org/apache/clerezza/rdf/cris/VirtualProperty.scala
Modified: incubator/clerezza/issues/CLEREZZA-388/rdf.cris/core/src/main/scala/org/apache/clerezza/rdf/cris/GraphIndexer.scala
URL: http://svn.apache.org/viewvc/incubator/clerezza/issues/CLEREZZA-388/rdf.cris/core/src/main/scala/org/apache/clerezza/rdf/cris/GraphIndexer.scala?rev=1078521&r1=1078520&r2=1078521&view=diff
==============================================================================
--- incubator/clerezza/issues/CLEREZZA-388/rdf.cris/core/src/main/scala/org/apache/clerezza/rdf/cris/GraphIndexer.scala (original)
+++ incubator/clerezza/issues/CLEREZZA-388/rdf.cris/core/src/main/scala/org/apache/clerezza/rdf/cris/GraphIndexer.scala Sun Mar 6 17:32:33 2011
@@ -72,6 +72,10 @@ class GraphIndexer(definitionGraph: Trip
private[this] var type2IndexedProperties: Map[UriRef, Seq[VirtualProperty]] = null
private[this] var property2TypeMap = Map[VirtualProperty, mutable.Set[UriRef]]()
+ private[this] var property2IncludingVProperty = new mutable.HashMap[UriRef, mutable.Set[VirtualProperty]]()
+ with mutable.MultiMap[UriRef, VirtualProperty] {
+ override def default(u: UriRef) = mutable.Set[VirtualProperty]()
+ }
//private[this] var indexedProperties: Seq[UriRef] = null
protected def processDefinitions() {
@@ -98,7 +102,6 @@ class GraphIndexer(definitionGraph: Trip
import collection.JavaConversions._
new PathVirtualProperty(uriPropertyList)
} else {
- //TODO add other cases
if ((r!).isInstanceOf[UriRef]) {
new PropertyHolder((r!).asInstanceOf[UriRef])
} else {
@@ -119,6 +122,9 @@ class GraphIndexer(definitionGraph: Trip
} else {
property2TypeMap += (vProp -> mutable.Set(tUri))
}
+ for (baseProperty <- vProp.baseProperties) {
+ property2IncludingVProperty.addBinding(baseProperty, vProp)
+ }
vProp
})
type2IndexedProperties = Map(type2IndexedPropertiesTuples: _*)
@@ -160,8 +166,9 @@ class GraphIndexer(definitionGraph: Trip
}, new FilterTriple(null, null, null) {
override def `match`(triple: Triple) = {
val predicate = triple.getPredicate
- //TODO check indirectly involved properties
- property2TypeMap.contains(new PropertyHolder(predicate))
+ //check indirectly involved properties
+ val vProperties = property2IncludingVProperty(predicate)
+ vProperties.exists(vProperty => property2TypeMap.contains(vProperty))
}
})
Modified: incubator/clerezza/issues/CLEREZZA-388/rdf.cris/core/src/main/scala/org/apache/clerezza/rdf/cris/VirtualProperty.scala
URL: http://svn.apache.org/viewvc/incubator/clerezza/issues/CLEREZZA-388/rdf.cris/core/src/main/scala/org/apache/clerezza/rdf/cris/VirtualProperty.scala?rev=1078521&r1=1078520&r2=1078521&view=diff
==============================================================================
--- incubator/clerezza/issues/CLEREZZA-388/rdf.cris/core/src/main/scala/org/apache/clerezza/rdf/cris/VirtualProperty.scala (original)
+++ incubator/clerezza/issues/CLEREZZA-388/rdf.cris/core/src/main/scala/org/apache/clerezza/rdf/cris/VirtualProperty.scala Sun Mar 6 17:32:33 2011
@@ -31,11 +31,13 @@ abstract class VirtualProperty {
*/
val stringKey: String
def value(node: RichGraphNode): Seq[String]
+ val baseProperties: Set[UriRef]
}
case class PropertyHolder(property: UriRef) extends VirtualProperty {
val stringKey = property.getUnicodeString
def value(node: RichGraphNode): Seq[String] = for (v <- node/property) yield v*
+ val baseProperties = Set(property)
}
case class JoinVirtualProperty(properties: List[VirtualProperty]) extends VirtualProperty {
@@ -44,6 +46,7 @@ case class JoinVirtualProperty(propertie
property.value(node).mkString(" ")
}).mkString(" ")
def value(node: RichGraphNode): Seq[String] = Seq(singleValue(node))
+ val baseProperties = (for (p <- properties) yield p.baseProperties).flatten.toSet
}
case class PathVirtualProperty(properties: List[UriRef]) extends VirtualProperty {
@@ -58,6 +61,7 @@ case class PathVirtualProperty(propertie
}
getPathResults(node, properties)
}
+ val baseProperties = properties.toSet
}
object VirtualProperty {