Class OGraphBatchInsertBasic
java.lang.Object
com.orientechnologies.orient.graph.batch.OGraphBatchInsertBasic
this is and API for fast batch import of simple graphs, starting from an empty (or non existing)
DB. This class allows import of graphs with
- no properties on edges
- no properties on vertices
- Long values for vertex ids
Typical usage:
OGraphBatchInsertSimple batch = new OGraphBatchInsertSimple("plocal:your/db", "admin", "admin");
batch.begin();
batch.createEdge(0L, 1L);
batch.createEdge(0L, 2L);
...
batch.end();
There is no need to create vertices before connecting them:
batch.createVertex(0L);
batch.createVertex(1L);
batch.createEdge(0L, 1L);
is equivalent to (but less performing than)
batch.createEdge(0L, 1L);
batch.createVertex() is needed only if you want to create unconnected vertices.
- Since:
- 2.0 M3
- Author:
- Luigi Dell'Aquila (l.dellaquila-(at)-orientdb.com) (l.dellaquila-at-orientdb.com)
-
Constructor Summary
ConstructorsConstructorDescriptionOGraphBatchInsertBasic(String iDbURL) Creates a new batch insert procedure by using admin user.OGraphBatchInsertBasic(String iDbURL, String iUserName, String iPassword) Creates a new batch insert procedure. -
Method Summary
Modifier and TypeMethodDescriptionvoidbegin()Creates the database (if it does not exist) and initializes batch operations.voidcreateEdge(Long from, Long to) Creates a new edge between two vertices.voidcreateVertex(Long v) Creates a new vertexvoidend()Flushes data to db and closes the db.intintintReturns the estimated number of entries.intvoidsetAverageEdgeNumberPerNode(int averageEdgeNumberPerNode) configures the average number of edges per node (for optimization).voidsetBonsaiThreshold(int bonsaiThreshold) Sets the threshold for passing from emdedded RidBag to SBTreeBonsai implementation, in number of edges (low level optimization).voidsetEdgeClass(String edgeClass) voidsetEstimatedEntries(int estimatedEntries) Sets the estimated number of entries, 0 for auto-resize (default).voidsetIdPropertyName(String idPropertyName) voidsetParallel(int parallel) sets the number of parallel threads to be used for batch insertvoidsetVertexClass(String vertexClass)
-
Constructor Details
-
OGraphBatchInsertBasic
Creates a new batch insert procedure by using admin user. It's intended to be used only for a single batch cycle (begin, create..., end)- Parameters:
iDbURL- db connection URL (plocal:/your/db/path)
-
OGraphBatchInsertBasic
Creates a new batch insert procedure. It's intended to be used only for a single batch cycle (begin, create..., end)- Parameters:
iDbURL- db connection URL (plocal:/your/db/path)iUserName- db user name (use admin for new db)iPassword- db password (use admin for new db)
-
-
Method Details
-
begin
public void begin()Creates the database (if it does not exist) and initializes batch operations. Call this once, before starting to create vertices and edges. -
end
public void end()Flushes data to db and closes the db. Call this once, after vertices and edges creation. -
createVertex
Creates a new vertex- Parameters:
v- the vertex ID
-
createEdge
Creates a new edge between two vertices. If vertices do not exist, they will be created- Parameters:
from- id of the vertex that is starting point of the edgeto- id of the vertex that is end point of the edge
-
getAverageEdgeNumberPerNode
public int getAverageEdgeNumberPerNode()- Returns:
- the configured average number of edges per node (optimization parameter, not calculated)
-
setAverageEdgeNumberPerNode
public void setAverageEdgeNumberPerNode(int averageEdgeNumberPerNode) configures the average number of edges per node (for optimization). Use it before calling begin()- Parameters:
averageEdgeNumberPerNode-
-
getIdPropertyName
- Returns:
- the property name where ids are written on vertices
-
setIdPropertyName
- Parameters:
idPropertyName- the property name where ids are written on vertices
-
getEdgeClass
- Returns:
- the edge class name (E by default)
-
setEdgeClass
- Parameters:
edgeClass- the edge class name
-
getVertexClass
- Returns:
- the vertex class name (V by default)
-
setVertexClass
- Parameters:
vertexClass- the vertex class name
-
getBonsaiThreshold
public int getBonsaiThreshold()- Returns:
- the threshold for passing from emdedded RidBag to SBTreeBonsai (low level optimization).
-
setBonsaiThreshold
public void setBonsaiThreshold(int bonsaiThreshold) Sets the threshold for passing from emdedded RidBag to SBTreeBonsai implementation, in number of edges (low level optimization). High values speed up writes but slow down reads later. Set -1 (default) to use default database configuration.See OGlobalConfiguration.RID_BAG_EMBEDDED_TO_SBTREEBONSAI_THRESHOLD}
-
getEstimatedEntries
public int getEstimatedEntries()Returns the estimated number of entries. 0 for auto-resize. -
setEstimatedEntries
public void setEstimatedEntries(int estimatedEntries) Sets the estimated number of entries, 0 for auto-resize (default). This pre-allocate in memory structure avoiding resizing of them at run-time. -
getParallel
public int getParallel()- Returns:
- number of parallel threads used for batch import
-
setParallel
public void setParallel(int parallel) sets the number of parallel threads to be used for batch insert- Parameters:
parallel- number of threads (default 4)
-