public class CallGraphWorker.CallGraph
extends java.lang.Object
PatternEngine
worker.Constructor and Description |
---|
CallGraph() |
Modifier and Type | Method and Description |
---|---|
org.apache.tinkerpop.gremlin.structure.Vertex |
addTable(org.apache.tinkerpop.gremlin.structure.Vertex schema,
Aast ast,
java.lang.String schemaname)
Create a new graph DB node associated with the given AST, representing a permanent schema
table.
|
void |
addTarget(org.apache.tinkerpop.gremlin.structure.Vertex node)
Add a new target, to be processed.
|
org.apache.tinkerpop.gremlin.structure.Vertex |
ambiguousNode()
Get the graph node to which all ambiguous call-sites link.
|
java.util.Set<java.lang.String> |
classHierarchy(java.lang.String clsName)
Resolve the class hierarchy starting with the current class.
|
void |
commit()
Commit the current transaction.
|
org.apache.tinkerpop.gremlin.structure.Vertex |
createAstNode(org.apache.tinkerpop.gremlin.structure.Vertex cntr,
Aast ast,
int type,
boolean entry)
Create a new graph DB node associated with the given AST which is by some external
resource.
|
org.apache.tinkerpop.gremlin.structure.Edge |
createEdge(org.apache.tinkerpop.gremlin.structure.Vertex out,
org.apache.tinkerpop.gremlin.structure.Vertex in,
java.lang.String label)
Create a new edge between the specified nodes, with the given label.
|
org.apache.tinkerpop.gremlin.structure.Vertex |
createExternalNode(java.lang.String label,
int type,
int domain)
Create an external node with the given type.
|
org.apache.tinkerpop.gremlin.structure.Vertex |
createFileResource(java.lang.String label,
int type,
java.lang.String filename)
Create a new graph DB node associated with the given file resource.
|
org.apache.tinkerpop.gremlin.structure.Vertex |
createIncludeFile(java.lang.String filename)
Create an include file vertex for the given filename.
|
void |
createIncludeGraph(Aast ast)
Create the include graph for the given external program.
|
private void |
createIncludeGraph(long fileSourceId,
org.apache.tinkerpop.gremlin.structure.Edge parentEdge,
HintsTreeNode root,
org.apache.tinkerpop.gremlin.structure.Vertex parent)
Create the include graph by walking the include tree specified by the root, recursively.
|
org.apache.tinkerpop.gremlin.structure.Vertex |
createNode(java.lang.String label,
long id,
int type,
int domain)
Create a new
node with the specified ID and type. |
java.util.Iterator<org.apache.tinkerpop.gremlin.structure.Edge> |
edgeInIterator(org.apache.tinkerpop.gremlin.structure.Vertex node,
java.lang.String label)
Create an iterator for all inbound edges with the given label.
|
java.util.Iterator<org.apache.tinkerpop.gremlin.structure.Edge> |
edgeIterator(org.apache.tinkerpop.gremlin.structure.Vertex node,
java.lang.String label)
Create an iterator for all outbound edges with the given label.
|
java.util.Iterator<org.apache.tinkerpop.gremlin.structure.Edge> |
edgeIterator(org.apache.tinkerpop.gremlin.structure.Vertex node,
java.lang.String label,
java.lang.String key,
java.lang.Object value)
Create an iterator for all outbound edges with the given label and property key and value.
|
org.apache.tinkerpop.gremlin.structure.Vertex |
findAdjacent(org.apache.tinkerpop.gremlin.structure.Vertex node,
int type,
java.lang.String label,
boolean dir)
Get the first adjacent node on the given direction, with the specified type and edge
label.
|
org.apache.tinkerpop.gremlin.structure.Vertex |
findAdjacent(org.apache.tinkerpop.gremlin.structure.Vertex node,
int type,
java.lang.String label,
java.lang.String prop,
java.lang.Object val,
boolean dir)
Get the first adjacent node on the given direction, with the specified type and edge
label.
|
org.apache.tinkerpop.gremlin.structure.Vertex |
findAstNode(long id)
Find the AST vertex in the
ProgressParserTokenTypes.AST_NODE resource domain. |
org.apache.tinkerpop.gremlin.structure.Edge |
findEdge(org.apache.tinkerpop.gremlin.structure.Vertex out,
org.apache.tinkerpop.gremlin.structure.Vertex in,
java.lang.String label)
Find an edge between the two nodes, which has the specified label.
|
org.apache.tinkerpop.gremlin.structure.Edge |
findEdge(org.apache.tinkerpop.gremlin.structure.Vertex out,
org.apache.tinkerpop.gremlin.structure.Vertex in,
java.lang.String label,
java.lang.String key,
java.lang.Object value)
Find an edge between the two nodes, which has the specified label and a property with
the given key and value.
|
org.apache.tinkerpop.gremlin.structure.Vertex |
findExternalNode(java.lang.String nodeKey,
java.lang.Object nodeValue)
Find the external node with the specified property.
|
org.apache.tinkerpop.gremlin.structure.Vertex |
findNodeById(int nodeType,
java.lang.Object id)
Find a node by its type and ID.
|
org.apache.tinkerpop.gremlin.structure.Vertex |
findOrCreateEvent(org.apache.tinkerpop.gremlin.structure.Vertex container,
java.lang.String event)
Find or create the vertex associated with the specified event.
|
org.apache.tinkerpop.gremlin.structure.Vertex |
findParentAstVertex(org.apache.tinkerpop.gremlin.structure.Vertex node,
int type)
Find the parent vertex having the given type.
|
org.apache.tinkerpop.gremlin.structure.Vertex |
findProcedureFile(org.apache.tinkerpop.gremlin.structure.Vertex node)
Find the procedure file associated with the given AST node.
|
org.apache.tinkerpop.gremlin.structure.Vertex |
findUniqueAdjacent(int type,
java.lang.Object id,
java.lang.String label,
boolean dir)
Find the adjacent vertex to the uniquely described vertex, via a unique edge
matching the given label.
|
org.apache.tinkerpop.gremlin.structure.Vertex |
findUniqueNode(java.lang.String key,
java.lang.Object val)
Find an unique node having a property with the given key and value.
|
java.util.Map<CallGraphWorker.CallSiteHint,java.lang.String> |
getCallSiteHintTargets(int callSiteKey,
int instance)
Get the targets for a specific call-site (which is determined to be ambiguous),
from the hints file.
|
java.lang.String |
getIncludeSourceFor(Aast ast)
Get the include source file for this AST.
|
boolean |
isCaseSensitive()
Check if we are in a case-sensitive OS, by reading the
case-sensitive configuration
parameter. |
boolean |
loadHints()
Loads the hints file for an AST if it exists and hasn't already been loaded.
|
void |
loadIncludeFiles()
Load all the include files (physical files) into the graph DB, as distinct nodes.
|
private PreprocessorHints |
loadPreprocessorHints(Aast ast)
Loads the preprocessor hints file for an AST if it exists and hasn't already been loaded.
|
private long |
nextExternalId(int type)
Compute the next available ID for an external node.
|
java.util.Iterator<org.apache.tinkerpop.gremlin.structure.Vertex> |
nodeIterator(java.lang.String key)
Create an iterator for all the nodes having a property with the specified key, regardless
of value.
|
java.util.Iterator<org.apache.tinkerpop.gremlin.structure.Vertex> |
nodeIterator(java.lang.String key,
java.lang.Object value)
Create an iterator for all the nodes having a property with the specified key and value.
|
java.util.Iterator<org.apache.tinkerpop.gremlin.structure.Vertex> |
nodeIterator(org.apache.tinkerpop.gremlin.structure.Vertex node,
java.lang.String key,
java.lang.Object value)
Create an iterator for all the nodes linked with an outbound edge which has a property
with the specified key and value.
|
java.util.Iterator<org.apache.tinkerpop.gremlin.structure.Vertex> |
nodeIterator(org.apache.tinkerpop.gremlin.structure.Vertex node,
java.lang.String label,
java.lang.String key,
java.lang.Object value,
boolean out)
Create an iterator for all the nodes linked with an outbound edge with the given label
and the target node having the given property value.
|
java.util.Iterator<org.apache.tinkerpop.gremlin.structure.Vertex> |
nodeIteratorV(org.apache.tinkerpop.gremlin.structure.Vertex node,
java.lang.String key,
java.lang.Object value)
Create an iterator for all the nodes linked with an outbound edge, which have a property
with the specified key and value.
|
boolean |
parameterTypeMatch(java.lang.String expected,
java.lang.String actual)
Check if the two lists of comma-separated parameter data types match.
|
java.lang.String |
prepareFilename(java.lang.String filename)
Prepare the procedure file name by replacing all windows-style separators with linux-style
separators and making the name lowercase, if we are on a case-insensitive OS.
|
void |
println(java.lang.String text)
Print output to the terminal if debug settings allow.
|
java.lang.Object |
property(org.apache.tinkerpop.gremlin.structure.Element element,
java.lang.String key)
Get the specified property from the given vertex or edge.
|
void |
property(org.apache.tinkerpop.gremlin.structure.Element element,
java.lang.String key,
java.lang.Object value)
Set the given property on the given vertex or edge.
|
void |
removeEdges(org.apache.tinkerpop.gremlin.structure.Vertex node,
boolean dir,
java.lang.String key,
java.lang.Object value)
For the specified node, remove all the edges in the given direction which match the
property key and property value.
|
void |
removeEdges(org.apache.tinkerpop.gremlin.structure.Vertex node,
boolean dir,
java.lang.String label,
java.lang.String key,
java.lang.Object value)
For the specified node, remove all the edges in the given direction which match the
label, property key and property value.
|
java.util.List<java.lang.String> |
resolveExternalPrograms(java.lang.String name)
Resolve all the external programs which match the given file name.
|
private java.lang.String |
reverseString(java.lang.String s)
Reverse the given string.
|
void |
setCollectTargets(boolean state)
Set the new state of the
CallGraphWorker.collectTargets flag. |
java.util.Iterator<org.apache.tinkerpop.gremlin.structure.Element> |
sortedResults(java.lang.Iterable<org.apache.tinkerpop.gremlin.structure.Element> elements,
java.lang.Object[] props)
Sort the given elements by the specified properties.
|
java.util.Iterator<org.apache.tinkerpop.gremlin.structure.Vertex> |
traversalIterator(org.apache.tinkerpop.gremlin.structure.Vertex root,
boolean dir)
Create a BFS node iterator starting with the given root, in the given direction.
|
java.util.Iterator<org.apache.tinkerpop.gremlin.structure.Vertex> |
traversalIterator(org.apache.tinkerpop.gremlin.structure.Vertex root,
java.lang.String label)
Create a BFS node iterator starting with the given root.
|
org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal<?,org.apache.tinkerpop.gremlin.structure.Vertex> |
vertexTraversal(org.apache.tinkerpop.gremlin.structure.Vertex v)
Obtain a vertex traversal instance that starts at the given node.
|
java.util.Iterator<org.apache.tinkerpop.gremlin.structure.Edge> |
vertexTraversalInE(org.apache.tinkerpop.gremlin.structure.Vertex v)
Obtain a vertex traversal instance that starts at the given node, for IN edges.
|
public void setCollectTargets(boolean state)
CallGraphWorker.collectTargets
flag.state
- true
to start collecting new targets, false
otherwise.public java.lang.String getIncludeSourceFor(Aast ast) throws PreprocessorException
null
.ast
- The AST for which the include source is needed.PreprocessorException
- An unknown or unexpected failure.public java.lang.String prepareFilename(java.lang.String filename)
filename
- Source file name.public boolean isCaseSensitive()
case-sensitive
configuration
parameter.true
if the OS filenames are case-sensitive.public org.apache.tinkerpop.gremlin.structure.Vertex ambiguousNode()
public void removeEdges(org.apache.tinkerpop.gremlin.structure.Vertex node, boolean dir, java.lang.String label, java.lang.String key, java.lang.Object value)
node
- A graph node.dir
- true
for out edges and false
for in edges.label
- The edge's label.key
- The property's key.value
- The property's value.public void removeEdges(org.apache.tinkerpop.gremlin.structure.Vertex node, boolean dir, java.lang.String key, java.lang.Object value)
node
- A graph node.dir
- true
for out edges and false
for in edges.key
- The property's key.value
- The property's value.public org.apache.tinkerpop.gremlin.structure.Vertex addTable(org.apache.tinkerpop.gremlin.structure.Vertex schema, Aast ast, java.lang.String schemaname) throws PreprocessorException
schema
- The root database schema vertex.ast
- The schema table AST.schemaname
- The table's full name.node
.PreprocessorException
- An unknown or unexpected failure.public java.lang.Object property(org.apache.tinkerpop.gremlin.structure.Element element, java.lang.String key)
element
- The vertex or edge on which to set the property.key
- The property name.null
if is not present at the node.public void property(org.apache.tinkerpop.gremlin.structure.Element element, java.lang.String key, java.lang.Object value)
element
- The vertex or edge on which to set the property.key
- The property name.value
- The value to set.public org.apache.tinkerpop.gremlin.structure.Vertex createFileResource(java.lang.String label, int type, java.lang.String filename)
label
- The label for the new vertex.type
- The "node-type" property for the new vertex.filename
- The OS-level filename of the resource.node
.public org.apache.tinkerpop.gremlin.structure.Vertex findOrCreateEvent(org.apache.tinkerpop.gremlin.structure.Vertex container, java.lang.String event)
container
- The container where the event is being listened.event
- The event name, kept at the event-name
vertex property.public org.apache.tinkerpop.gremlin.structure.Vertex createAstNode(org.apache.tinkerpop.gremlin.structure.Vertex cntr, Aast ast, int type, boolean entry) throws PreprocessorException
cntr
- The external resource (often a procedure file) that contains this node.ast
- The AST representing the entry point.type
- The "node-type" property for the new vertex.entry
- true
if this is an entry-point, false
for a
call-site. This will be stored in a property called "entry-point".node
.PreprocessorException
- An unknown or unexpected failure.public org.apache.tinkerpop.gremlin.structure.Edge findEdge(org.apache.tinkerpop.gremlin.structure.Vertex out, org.apache.tinkerpop.gremlin.structure.Vertex in, java.lang.String label, java.lang.String key, java.lang.Object value)
out
- The source node.in
- The target node.label
- The edge's label.key
- The property's key.value
- The property's value.null
if not found.public org.apache.tinkerpop.gremlin.structure.Edge findEdge(org.apache.tinkerpop.gremlin.structure.Vertex out, org.apache.tinkerpop.gremlin.structure.Vertex in, java.lang.String label)
out
- The source node.in
- The target node.label
- The edge's label.null
if not found.public org.apache.tinkerpop.gremlin.structure.Vertex createExternalNode(java.lang.String label, int type, int domain)
label
- The label for the new vertex.type
- The "node-type" property for the new vertex.domain
- The token type of the node's resource domain, will be stored as the
"resource-domain" property.node
.public org.apache.tinkerpop.gremlin.structure.Vertex findExternalNode(java.lang.String nodeKey, java.lang.Object nodeValue)
nodeKey
- The property name.nodeValue
- The property value.public org.apache.tinkerpop.gremlin.structure.Vertex createNode(java.lang.String label, long id, int type, int domain)
node
with the specified ID and type.label
- The label for the new vertex.id
- The node's unique identifier, will be stored as the "node-id" property.type
- The token type for the node, will be stored as the "node-type" property.domain
- The token type of the node's resource domain, will be stored as the
"resource-domain" property.node
.public org.apache.tinkerpop.gremlin.structure.Edge createEdge(org.apache.tinkerpop.gremlin.structure.Vertex out, org.apache.tinkerpop.gremlin.structure.Vertex in, java.lang.String label)
out
- The source node.in
- The target node.label
- The edge label.Edge
.public boolean parameterTypeMatch(java.lang.String expected, java.lang.String actual)
expected
- The expected data types.actual
- The actual data types.true
if the two match.public java.util.Set<java.lang.String> classHierarchy(java.lang.String clsName)
clsName
- The class name.public java.util.Iterator<org.apache.tinkerpop.gremlin.structure.Vertex> nodeIterator(org.apache.tinkerpop.gremlin.structure.Vertex node, java.lang.String key, java.lang.Object value)
node
- The graph node.key
- The property key.value
- The property value.public java.util.Iterator<org.apache.tinkerpop.gremlin.structure.Vertex> nodeIterator(org.apache.tinkerpop.gremlin.structure.Vertex node, java.lang.String label, java.lang.String key, java.lang.Object value, boolean out)
node
- The graph node.label
- The edge label.key
- The property key.value
- The property value.out
- The direction: out or in edges.public java.util.Iterator<org.apache.tinkerpop.gremlin.structure.Vertex> nodeIteratorV(org.apache.tinkerpop.gremlin.structure.Vertex node, java.lang.String key, java.lang.Object value)
node
- The graph node.key
- The property key.value
- The property value.public java.util.Iterator<org.apache.tinkerpop.gremlin.structure.Vertex> nodeIterator(java.lang.String key)
key
- The property key.public java.util.Iterator<org.apache.tinkerpop.gremlin.structure.Vertex> traversalIterator(org.apache.tinkerpop.gremlin.structure.Vertex root, boolean dir)
root
- The root node.dir
- The edge direction (true
for out and false
for in.public java.util.Iterator<org.apache.tinkerpop.gremlin.structure.Vertex> traversalIterator(org.apache.tinkerpop.gremlin.structure.Vertex root, java.lang.String label)
root
- The root node.label
- The labels for the edges which will be followed.public org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal<?,org.apache.tinkerpop.gremlin.structure.Vertex> vertexTraversal(org.apache.tinkerpop.gremlin.structure.Vertex v)
v
- The node at which to start the traversal.public java.util.Iterator<org.apache.tinkerpop.gremlin.structure.Edge> vertexTraversalInE(org.apache.tinkerpop.gremlin.structure.Vertex v)
v
- The node at which to start the traversal.public java.util.Iterator<org.apache.tinkerpop.gremlin.structure.Vertex> nodeIterator(java.lang.String key, java.lang.Object value)
key
- The property key.value
- The property value.public java.util.Iterator<org.apache.tinkerpop.gremlin.structure.Element> sortedResults(java.lang.Iterable<org.apache.tinkerpop.gremlin.structure.Element> elements, java.lang.Object[] props)
elements
- A query result.props
- The property names, each element a String
.public java.util.Iterator<org.apache.tinkerpop.gremlin.structure.Edge> edgeIterator(org.apache.tinkerpop.gremlin.structure.Vertex node, java.lang.String label)
node
- The node for which the outbound edges are needed.label
- The edge's label.public java.util.Iterator<org.apache.tinkerpop.gremlin.structure.Edge> edgeIterator(org.apache.tinkerpop.gremlin.structure.Vertex node, java.lang.String label, java.lang.String key, java.lang.Object value)
node
- The node for which the outbound edges are needed.label
- The edge's label.key
- Only edges with the having a property with this key.value
- Only edges with the having a property with this value.public java.util.Iterator<org.apache.tinkerpop.gremlin.structure.Edge> edgeInIterator(org.apache.tinkerpop.gremlin.structure.Vertex node, java.lang.String label)
node
- The node for which the inbound edges are needed.label
- The edge's label.public org.apache.tinkerpop.gremlin.structure.Vertex findNodeById(int nodeType, java.lang.Object id)
nodeType
- The node's type.id
- The node's ID.null
if it does not exist.public org.apache.tinkerpop.gremlin.structure.Vertex findAstNode(long id)
ProgressParserTokenTypes.AST_NODE
resource domain.id
- The node-id property value to match.null
.public org.apache.tinkerpop.gremlin.structure.Vertex findUniqueAdjacent(int type, java.lang.Object id, java.lang.String label, boolean dir)
type
- The "node-type" property.id
- The "node-id" property.label
- The label of the edge defining the relation between the two vertices.dir
- true
for out edges and false
for in edges.null
if it does not exist.public org.apache.tinkerpop.gremlin.structure.Vertex findAdjacent(org.apache.tinkerpop.gremlin.structure.Vertex node, int type, java.lang.String label, boolean dir)
node
- The current node.type
- The found "node-type" property.label
- The label of the edge defining the relation between the two vertices.dir
- true
for out edges and false
for in edges.null
if it does not exist.public org.apache.tinkerpop.gremlin.structure.Vertex findAdjacent(org.apache.tinkerpop.gremlin.structure.Vertex node, int type, java.lang.String label, java.lang.String prop, java.lang.Object val, boolean dir)
node
- The current node.type
- The found "node-type" property.label
- The label of the edge defining the relation between the two vertices.prop
- The property name.val
- The property value.dir
- true
for out edges and false
for in edges.null
if it does not exist.public void addTarget(org.apache.tinkerpop.gremlin.structure.Vertex node)
Only external-procedure
targets with no finished
or processing
annotations are added.
node
- The node to be added.public void commit()
public org.apache.tinkerpop.gremlin.structure.Vertex findUniqueNode(java.lang.String key, java.lang.Object val)
key
- The property key.val
- The property value.java.lang.RuntimeException
- If more than one node is found.public org.apache.tinkerpop.gremlin.structure.Vertex findParentAstVertex(org.apache.tinkerpop.gremlin.structure.Vertex node, int type)
node
- The node to find.type
- The parent's type.public org.apache.tinkerpop.gremlin.structure.Vertex findProcedureFile(org.apache.tinkerpop.gremlin.structure.Vertex node)
node
- The node to find.public void loadIncludeFiles()
public void createIncludeGraph(Aast ast) throws PreprocessorException
ast
- The external program AST.PreprocessorException
- An unknown or unexpected failure.public java.util.Map<CallGraphWorker.CallSiteHint,java.lang.String> getCallSiteHintTargets(int callSiteKey, int instance)
callSiteKey
- The key of this call-site.instance
- The instance number for this call-site.public java.util.List<java.lang.String> resolveExternalPrograms(java.lang.String name)
name
- The filename.public void println(java.lang.String text)
text
- Text to print.public boolean loadHints()
true
if there are hints for this file and the hints are loaded,
false
if no hints are available.public org.apache.tinkerpop.gremlin.structure.Vertex createIncludeFile(java.lang.String filename)
filename
- The name of the file resource.private PreprocessorHints loadPreprocessorHints(Aast ast) throws PreprocessorException
PreprocessorHints
instance.PreprocessorException
- An unknown or unexpected failure.private java.lang.String reverseString(java.lang.String s)
s
- The string to reverse.private void createIncludeGraph(long fileSourceId, org.apache.tinkerpop.gremlin.structure.Edge parentEdge, HintsTreeNode root, org.apache.tinkerpop.gremlin.structure.Vertex parent)
fileSourceId
- The ID of the ProgressParserTokenTypes.FILE_RESOURCE
vertex which
started this include sub-graph.parentEdge
- The parent edge on which this include graph was created. May be null
if the root
hints is on depth 0.root
- The root include node.parent
- The parent node in the graph DB, to which the root's children will be attached.private long nextExternalId(int type)
type
- The external node type.