public class NFBuildGraph extends NFGraph
NFBuildGraph is used to create a new graph. This representation of the graph data is not especially memory-efficient,
and is intended to exist only for a short time while the NFGraph is being populated.
Once the graph is completely populated, it is expected that this NFBuildGraph will be exchanged for a memory-efficient,
read-only NFCompressedGraph via the compress() method.
See NFGraph for an example of code which creates and populates an NFBuildGraph
graphSpec, modelHolder| Constructor and Description |
|---|
NFBuildGraph(NFGraphSpec graphSpec) |
| Modifier and Type | Method and Description |
|---|---|
void |
addConnection(com.netflix.nfgraph.build.NFBuildGraphNode fromNode,
NFPropertySpec propertySpec,
int connectionModelIndex,
com.netflix.nfgraph.build.NFBuildGraphNode toNode)
Add a connection to this graph.
|
void |
addConnection(java.lang.String nodeType,
int fromOrdinal,
java.lang.String viaProperty,
int toOrdinal)
Add a connection to this graph.
|
void |
addConnection(java.lang.String connectionModel,
java.lang.String nodeType,
int fromOrdinal,
java.lang.String viaPropertyName,
int toOrdinal)
Add a connection to this graph.
|
int |
addConnectionModel(java.lang.String connectionModel)
Add a connection model, identified by the parameter
connectionModel to this graph. |
NFCompressedGraph |
compress()
Return a
NFCompressedGraph containing all connections which have been added to this NFBuildGraph. |
protected int |
getConnection(int connectionModelIndex,
java.lang.String nodeType,
int ordinal,
java.lang.String propertyName) |
protected OrdinalIterator |
getConnectionIterator(int connectionModelIndex,
java.lang.String nodeType,
int ordinal,
java.lang.String propertyName) |
protected OrdinalSet |
getConnectionSet(int connectionModelIndex,
java.lang.String nodeType,
int ordinal,
java.lang.String propertyName) |
com.netflix.nfgraph.build.NFBuildGraphNodeList |
getNodes(java.lang.String nodeType)
Returns the list of
NFBuildGraphNodes associated with the specified
nodeType. |
com.netflix.nfgraph.build.NFBuildGraphNode |
getOrCreateNode(com.netflix.nfgraph.build.NFBuildGraphNodeList nodes,
NFNodeSpec nodeSpec,
int ordinal)
Creates an
NFBuildGraphNode for nodeSpec and ordinal
and adds it to nodes. |
NFPropertySpec |
getPropertySpec(java.lang.String nodeType,
java.lang.String propertyName)
Returns the
NFPropertySpec associated with the supplied node type and property name. |
getConnection, getConnection, getConnectionIterator, getConnectionIterator, getConnectionSet, getConnectionSetpublic NFBuildGraph(NFGraphSpec graphSpec)
protected int getConnection(int connectionModelIndex,
java.lang.String nodeType,
int ordinal,
java.lang.String propertyName)
getConnection in class NFGraphprotected OrdinalIterator getConnectionIterator(int connectionModelIndex, java.lang.String nodeType, int ordinal, java.lang.String propertyName)
getConnectionIterator in class NFGraphprotected OrdinalSet getConnectionSet(int connectionModelIndex, java.lang.String nodeType, int ordinal, java.lang.String propertyName)
getConnectionSet in class NFGraphpublic void addConnection(java.lang.String nodeType,
int fromOrdinal,
java.lang.String viaProperty,
int toOrdinal)
nodeType and fromOrdinal.
The connection will be via the specified viaProperty in the NFNodeSpec for the given nodeType.
The connection will be to the node identified by the given toOrdinal. The type of the to node is implied by the viaProperty.public void addConnection(java.lang.String connectionModel,
java.lang.String nodeType,
int fromOrdinal,
java.lang.String viaPropertyName,
int toOrdinal)
nodeType and fromOrdinal. The connection will be via the specified viaProperty in the NFNodeSpec for
the given nodeType. The connection will be to the node identified by the given toOrdinal. The type of the to node is implied
by the viaProperty.public com.netflix.nfgraph.build.NFBuildGraphNodeList getNodes(java.lang.String nodeType)
NFBuildGraphNodes associated with the specified
nodeType.public com.netflix.nfgraph.build.NFBuildGraphNode getOrCreateNode(com.netflix.nfgraph.build.NFBuildGraphNodeList nodes,
NFNodeSpec nodeSpec,
int ordinal)
NFBuildGraphNode for nodeSpec and ordinal
and adds it to nodes. If such a node exists in nodes, then that node is returned.public void addConnection(com.netflix.nfgraph.build.NFBuildGraphNode fromNode,
NFPropertySpec propertySpec,
int connectionModelIndex,
com.netflix.nfgraph.build.NFBuildGraphNode toNode)
addConnection(String connectionModel, String nodeType, int fromOrdinal, String viaPropertyName, int toOrdinal)
as it avoids multiple lookups for fromNode, propertySpec, connectionModelIndex
and toNode.public int addConnectionModel(java.lang.String connectionModel)
connectionModel to this graph.Building the graph may be much more efficient if each connection model is added to the graph with this method prior to adding any connections.
This operation is not necessary, but may make building the graph more efficient.
Returns the "model index" used to identify the connection model internally. Passing this to
the various addConnection() may offer a performance boost while building the graph.
public NFPropertySpec getPropertySpec(java.lang.String nodeType, java.lang.String propertyName)
NFPropertySpec associated with the supplied node type and property name.public NFCompressedGraph compress()
NFCompressedGraph containing all connections which have been added to this NFBuildGraph.