Skip to content

Commit

Permalink
Merge pull request #498 from OndraZizka/fixClassifIndex-WINDUP-529
Browse files Browse the repository at this point in the history
WINDUP-529 Performance issue: Query requires iterating over all vertices [(ClassificationModel:classification = ...)]
  • Loading branch information
lincolnthree committed Mar 16, 2015
2 parents b243b4a + 938858c commit 73e71d2
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 13 deletions.
Expand Up @@ -142,24 +142,39 @@ public Graph configure(Graph baseGraph, FramedGraphConfiguration config)

private void initializeTitanManagement(TitanGraph titanGraph)
{
// TODO: This has to load dynamically.
// TODO: This has to load dynamically. WINDUP-198
// E.g. get all Model classes and look for @Indexed - org.jboss.windup.graph.api.model.anno.
String[] keys = new String[] { "namespaceURI", "schemaLocation", "publicId", "rootTagName",
"systemId", "qualifiedName", "filePath", "mavenIdentifier", "packageName", "classification" };
// We need to hard-code the property names here since we can't depend on rulesets' addons.
String[] keys = new String[] {
// rules/apps/xml/model/NamespaceMetaModel
"namespaceURI",
"schemaLocation",
// rules/apps/xml/model/XmlFileModel
"rootTagName",
// rules/apps/java/model/JavaClassModel
"qualifiedName",
// graph/model/resource/FileModel
"filePath",
// rules/apps/java/model/project/MavenProjectModel
"mavenIdentifier",
// JavaClassModel, JavaClassFileModel, JavaSourceFileModel, PackageModel - possible collision!
"packageName",

"DoctypeMeta:publicId", "DoctypeMeta:systemId",
"ClassificationModel:classification"
};

TitanManagement mgmt = titanGraph.getManagementSystem();

for (String key : keys)
{
PropertyKey propKey = mgmt.makePropertyKey(key).dataType(String.class).cardinality(Cardinality.SINGLE)
.make();
PropertyKey propKey = mgmt.makePropertyKey(key).dataType(String.class).cardinality(Cardinality.SINGLE).make();
mgmt.buildIndex(key, Vertex.class).addKey(propKey).buildCompositeIndex();
}

for (String key : new String[] { "referenceSourceSnippit" })
{
PropertyKey propKey = mgmt.makePropertyKey(key).dataType(String.class).cardinality(Cardinality.SINGLE)
.make();
PropertyKey propKey = mgmt.makePropertyKey(key).dataType(String.class).cardinality(Cardinality.SINGLE).make();
mgmt.buildIndex(key, Vertex.class).addKey(propKey).buildMixedIndex("search");
}

Expand Down Expand Up @@ -196,7 +211,7 @@ private TitanGraph initializeTitanGraph()
// turn on a db-cache that persists across txn boundaries, but make it relatively small
conf.setProperty("cache.db-cache", true);
conf.setProperty("cache.db-cache-clean-wait", 0);
conf.setProperty("cache.db-cache-size", .05);
conf.setProperty("cache.db-cache-size", .09);
conf.setProperty("cache.db-cache-time", 0);

conf.setProperty("index.search.backend", "lucene");
Expand Down
Expand Up @@ -7,14 +7,16 @@
import com.tinkerpop.frames.Property;
import com.tinkerpop.frames.modules.typedgraph.TypeValue;

@TypeValue("DoctypeMeta")
@TypeValue(DoctypeMetaModel.TYPE_ID)
public interface DoctypeMetaModel extends WindupVertexFrame
{
public static final String TYPE_ID = "DoctypeMeta";
public static final String TYPE_PREFIX = TYPE_ID + ":";

public static final String PROPERTY_BASE_URI = "baseURI";
public static final String PROPERTY_SYSTEM_ID = "systemId";
public static final String PROPERTY_PUBLIC_ID = "publicId";
public static final String PROPERTY_NAME = "name";
public static final String PROPERTY_BASE_URI = TYPE_PREFIX + "baseURI";
public static final String PROPERTY_SYSTEM_ID = TYPE_PREFIX + "systemId";
public static final String PROPERTY_PUBLIC_ID = TYPE_PREFIX + "publicId";
public static final String PROPERTY_NAME = TYPE_PREFIX + "name";

@Adjacency(label = "doctype", direction = Direction.IN)
public void addXmlResource(XmlFileModel facet);
Expand Down

0 comments on commit 73e71d2

Please sign in to comment.