public class OGraphBatchInsert extends Object
This batch insert procedure is made of four phases, that have to be executed in the correct order:
Typical usage:
//phase 1: begin
batch.begin();
//phase 2: create edges
Map<String, Object> edgeProps = new HashMap<String, Object>
edgeProps.put("foo", "bar");
batch.createEdge(0L, 1L, edgeProps);
batch.createVertex(2L);
batch.createEdge(3L, 4L, null);
...
//phase 3: set properties on vertices, THIS CAN BE DONE ONLY AFTER EDGE AND VERTEX CREATION
Map<String, Object> vertexProps = new HashMap<String, Object>
vertexProps.put("foo", "bar");
batch.setVertexProperties(0L, vertexProps)
...
//phase 4: end
batch.end();
OGraphBatchInsert batch = new OGraphBatchInsert("plocal:your/db", "admin", "admin");
There is no need to create vertices before connecting them:
batch.createVertex(0L);
batch.createVertex(1L);
batch.createEdge(0L, 1L, props);
is equivalent to (but less performing than)
batch.createEdge(0L, 1L, props);
batch.createVertex(Long) is needed only if you want to create unconnected vertices
Constructor and Description |
---|
OGraphBatchInsert(String iDbURL)
Creates a new batch insert procedure by using admin user.
|
OGraphBatchInsert(String iDbURL,
String iUserName,
String iPassword)
Creates a new batch insert procedure.
|
Modifier and Type | Method and Description |
---|---|
void |
begin()
Creates the database (if it does not exist) and initializes batch operations.
|
void |
createEdge(Long from,
Long to,
Map<String,Object> properties)
Creates a new edge between two vertices.
|
void |
createVertex(Long v)
Creates a new vertex
|
void |
end()
Flushes data to db and closes the db.
|
int |
getAverageEdgeNumberPerNode() |
int |
getBonsaiThreshold() |
String |
getEdgeClass() |
int |
getEstimatedEntries()
Returns the estimated number of entries.
|
String |
getIdPropertyName() |
int |
getParallel() |
String |
getVertexClass() |
void |
setAverageEdgeNumberPerNode(int averageEdgeNumberPerNode)
configures the average number of edges per node (for optimization).
|
void |
setBonsaiThreshold(int bonsaiThreshold)
Sets the threshold for passing from emdedded RidBag to SBTreeBonsai implementation, in number
of edges (low level optimization).
|
void |
setEdgeClass(String edgeClass) |
void |
setEstimatedEntries(int estimatedEntries)
Sets the estimated number of entries, 0 for auto-resize (default).
|
void |
setIdPropertyName(String idPropertyName) |
void |
setParallel(int parallel)
sets the number of parallel threads to be used for batch insert
|
void |
setVertexClass(String vertexClass) |
void |
setVertexProperties(Long id,
Map<String,Object> properties) |
public OGraphBatchInsert(String iDbURL)
iDbURL
- db connection URL (plocal:/your/db/path)public OGraphBatchInsert(String iDbURL, String iUserName, String iPassword)
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)public void begin()
public void end()
public void createVertex(Long v)
v
- the vertex IDpublic void createEdge(Long from, Long to, Map<String,Object> properties)
from
- id of the vertex that is starting point of the edgeto
- id of the vertex that is end point of the edgepublic int getAverageEdgeNumberPerNode()
public void setAverageEdgeNumberPerNode(int averageEdgeNumberPerNode)
averageEdgeNumberPerNode
- public String getIdPropertyName()
public void setIdPropertyName(String idPropertyName)
idPropertyName
- the property name where ids are written on verticespublic String getEdgeClass()
public void setEdgeClass(String edgeClass)
edgeClass
- the edge class namepublic String getVertexClass()
public void setVertexClass(String vertexClass)
vertexClass
- the vertex class namepublic int getBonsaiThreshold()
public void setBonsaiThreshold(int bonsaiThreshold)
See OGlobalConfiguration.RID_BAG_EMBEDDED_TO_SBTREEBONSAI_THRESHOLD}
public int getEstimatedEntries()
public void setEstimatedEntries(int estimatedEntries)
public int getParallel()
public void setParallel(int parallel)
parallel
- number of threads (default 4)Copyright © 2009–2020 OrientDB. All rights reserved.