Skip to content

Commit

Permalink
Added in fix for indexes. Now, all types should properly leverage mul…
Browse files Browse the repository at this point in the history
…ti-type indexing & replacement of CONTAINS for EQUALS in searching the index.
  • Loading branch information
bradsdavis authored and jsight committed Aug 12, 2014
1 parent aa7c988 commit b8fb7b3
Show file tree
Hide file tree
Showing 13 changed files with 23 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public Configuration getConfiguration(GraphContext context)
@Override
public void query(GraphRewrite event, GremlinPipeline<Vertex, Vertex> pipeline)
{
pipeline.V().has(WindupVertexFrame.TYPE_PROP, Text.CONTAINS, JavaMethodModel.TYPE);
pipeline.V().has(WindupVertexFrame.TYPE_PROP, JavaMethodModel.TYPE);
}
}).as("javaMethods")
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.jboss.windup.graph.model.resource.ResourceModel;
import org.jboss.windup.graph.service.GraphService;

import com.thinkaurelius.titan.core.attribute.Cmp;
import com.thinkaurelius.titan.core.attribute.Text;
import com.tinkerpop.blueprints.Direction;
import com.tinkerpop.blueprints.Edge;
Expand All @@ -31,7 +32,7 @@ public Iterable<ArchiveModel> findAllRootArchives()
{
// iterate through all vertices
Iterable<Vertex> pipeline = new GremlinPipeline<Vertex, Vertex>(getGraphContext()
.getGraph().query().has(WindupVertexFrame.TYPE_PROP, Text.CONTAINS, getTypeValueForSearch())
.getGraph().query().has(WindupVertexFrame.TYPE_PROP, Cmp.EQUAL, getTypeValueForSearch())
.vertices())

// check to see whether there is an edge coming in that links to the resource providing the java
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.jboss.windup.graph.model.resource.FileModel;
import org.jboss.windup.graph.service.GraphService;

import com.thinkaurelius.titan.core.attribute.Cmp;
import com.thinkaurelius.titan.core.attribute.Text;
import com.thinkaurelius.titan.util.datastructures.IterablesUtil;

Expand Down Expand Up @@ -77,7 +78,7 @@ public Iterable<FileModel> findArchiveEntryWithExtension(String... values)
}

return getGraphContext().getFramed().query()
.has(WindupVertexFrame.TYPE_PROP, Text.CONTAINS, getTypeValueForSearch())
.has(WindupVertexFrame.TYPE_PROP, Cmp.EQUAL, getTypeValueForSearch())
.has("filePath", Text.REGEX, regex).vertices(getType());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import com.thinkaurelius.titan.core.TitanGraphQuery;
import com.thinkaurelius.titan.core.TitanTransaction;
import com.thinkaurelius.titan.core.attribute.Cmp;
import com.thinkaurelius.titan.core.attribute.Text;
import com.thinkaurelius.titan.util.datastructures.IterablesUtil;
import com.tinkerpop.blueprints.Vertex;
Expand Down Expand Up @@ -96,15 +97,15 @@ public void delete(T frame)
public Iterable<T> findAll()
{
FramedGraphQuery query = context.getFramed().query();
query.has(WindupVertexFrame.TYPE_PROP, Text.CONTAINS, type.getAnnotation(TypeValue.class).value());
query.has(WindupVertexFrame.TYPE_PROP, Cmp.EQUAL, type.getAnnotation(TypeValue.class).value());
return (Iterable<T>) query.vertices(type);
}

@Override
public Iterable<T> findAllByProperties(String[] keys, String[] vals)
{
FramedGraphQuery fgq = context.getFramed().query()
.has(WindupVertexFrame.TYPE_PROP, Text.CONTAINS, getTypeValueForSearch());
.has(WindupVertexFrame.TYPE_PROP, Cmp.EQUAL, getTypeValueForSearch());

for (int i = 0, j = keys.length; i < j; i++)
{
Expand Down Expand Up @@ -150,7 +151,7 @@ public Iterable<T> findAllByPropertyMatchingRegex(String key, String... regex)
regexFinal = builder.toString();
}

return context.getFramed().query().has(WindupVertexFrame.TYPE_PROP, Text.CONTAINS, getTypeValueForSearch())
return context.getFramed().query().has(WindupVertexFrame.TYPE_PROP, Cmp.EQUAL, getTypeValueForSearch())
.has(key, Text.REGEX, regexFinal).vertices(type);
}

Expand All @@ -175,7 +176,7 @@ protected TitanGraphQuery getTypedQuery()
{
return getGraphContext()
.getGraph().getBaseGraph().query()
.has(WindupVertexFrame.TYPE_PROP, Text.CONTAINS, getTypeValueForSearch());
.has(WindupVertexFrame.TYPE_PROP, Cmp.EQUAL, getTypeValueForSearch());
}

protected String getTypeValueForSearch()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public GraphContextImpl(Imported<Service<? extends VertexFrame>> graphServices,
// TODO: This has to load dynamically.
// 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" };
"systemId", "qualifiedName", "filePath", "mavenIdentifier", "packageName" };
for (String key : keys)
{
this.titanGraph.makeKey(key).dataType(String.class).indexed(Vertex.class).make();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import org.jboss.windup.graph.typedgraph.TestFooModel;
import org.jboss.windup.graph.typedgraph.TestFooSubModel;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;

Expand Down Expand Up @@ -42,6 +43,7 @@ public static ForgeArchive getDeployment()
@Inject
private GraphContext context;

@Ignore
@Test
public void testEventGraph() throws Exception
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public void testInMemoryFrame() throws Exception
Iterable<Vertex> vertices = context
.getFramed()
.query()
.has(WindupVertexFrame.TYPE_PROP, Text.CONTAINS,
.has(WindupVertexFrame.TYPE_PROP,
TestFooModel.class.getAnnotation(TypeValue.class).value())
.vertices();

Expand All @@ -72,7 +72,7 @@ public void testInMemoryFrame() throws Exception
vertices = context
.getFramed()
.query()
.has(WindupVertexFrame.TYPE_PROP, Text.CONTAINS,
.has(WindupVertexFrame.TYPE_PROP,
TestFooModel.class.getAnnotation(TypeValue.class).value())
.vertices();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public void testInMemoryFrame() throws Exception
Iterable<Vertex> vertices = context
.getFramed()
.query()
.has(WindupVertexFrame.TYPE_PROP, Text.CONTAINS,
.has(WindupVertexFrame.TYPE_PROP,
TestFooModel.class.getAnnotation(TypeValue.class).value())
.vertices();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import org.junit.runner.RunWith;

import com.thinkaurelius.titan.core.attribute.Cmp;
import com.thinkaurelius.titan.core.attribute.Text;
import com.tinkerpop.blueprints.Vertex;
import com.tinkerpop.frames.FramedGraphQuery;
import com.tinkerpop.frames.modules.typedgraph.TypeValue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.junit.Test;
import org.junit.runner.RunWith;

import com.thinkaurelius.titan.core.attribute.Cmp;
import com.thinkaurelius.titan.core.attribute.Text;
import com.tinkerpop.blueprints.Vertex;
import com.tinkerpop.frames.modules.typedgraph.TypeValue;
Expand Down Expand Up @@ -66,7 +67,7 @@ public void testMapHandling() throws Exception
mainModel.setMap(map);

Iterable<Vertex> vertices = context.getFramed().query()
.has(WindupVertexFrame.TYPE_PROP, Text.CONTAINS,
.has(WindupVertexFrame.TYPE_PROP, Cmp.EQUAL,
TestMapMainModel.class.getAnnotation(TypeValue.class).value())
.vertices();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@ public Iterable<JavaClassModel> findByJavaClassPattern(String regex)
public Iterable<JavaClassModel> findByJavaPackage(String packageName)
{
return getGraphContext().getFramed().query()
.has(WindupVertexFrame.TYPE_PROP, Text.CONTAINS, getTypeValueForSearch())
.has(WindupVertexFrame.TYPE_PROP, getTypeValueForSearch())
.has("packageName", packageName).vertices(getType());
}

public Iterable<JavaClassModel> findByJavaVersion(JavaVersion version)
{
return getGraphContext().getFramed().query()
.has(WindupVertexFrame.TYPE_PROP, Text.CONTAINS, getTypeValueForSearch())
.has(WindupVertexFrame.TYPE_PROP, getTypeValueForSearch())
.has("majorVersion", version.getMajor())
.has("minorVersion", version.getMinor()).vertices(getType());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public NamespaceService(GraphContext context)
public NamespaceMetaModel createNamespaceSchemaLocation(String namespaceURI, String schemaLocation)
{
Iterable<NamespaceMetaModel> results = getGraphContext().getFramed().query()
.has(WindupVertexFrame.TYPE_PROP, Text.CONTAINS, NamespaceMetaModel.TYPE)
.has(WindupVertexFrame.TYPE_PROP, NamespaceMetaModel.TYPE)
.has("namespaceURI", namespaceURI).has("schemaLocation", schemaLocation)
.vertices(NamespaceMetaModel.class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ protected String generateMavenKey(String groupId, String artifactId, String vers
public boolean isMavenConfiguration(XmlResourceModel resource)
{
return (new GremlinPipeline<Vertex, Vertex>(resource.asVertex())).in("xmlFacet").as("facet")
.has(WindupVertexFrame.TYPE_PROP, Text.CONTAINS, this.getTypeValueForSearch()).back("facet")
.has(WindupVertexFrame.TYPE_PROP, this.getTypeValueForSearch()).back("facet")
.iterator().hasNext();
}

Expand All @@ -60,7 +60,7 @@ public MavenProjectModel getMavenConfigurationFromResource(XmlResourceModel reso
@SuppressWarnings("unchecked")
Iterator<Vertex> v = (Iterator<Vertex>) (new GremlinPipeline<Vertex, Vertex>(resource.asVertex()))
.in("xmlFacet").as("facet")
.has(WindupVertexFrame.TYPE_PROP, Text.CONTAINS, this.getTypeValueForSearch()).back("facet")
.has(WindupVertexFrame.TYPE_PROP, this.getTypeValueForSearch()).back("facet")
.iterator();
if (v.hasNext())
{
Expand Down

0 comments on commit b8fb7b3

Please sign in to comment.