Types of Import Files
The following file types can be imported to TIBCO Graph Database by using the import utility:
You can use the files generated by the export utility, or you can create the files independently, as described in the following section.
Each nodetype to be imported is organized into node and edge files. The lists of these files is stored in the configuration file, and provides you further options.
Node fileThe node file represents a collection of nodes of a given nodetype. It means if you have three node types to import, you will have three files. These are CSV files (extension ".csv"), with rows and columns. Each row represents a node and the first column contains the node ID. The node ID is unique across all the files that you import and can have any value (string or number). Subsequent columns contain attribute values. The order in which the node file contains the attribute descriptors is stored in the configuration file.
Edge file
The edge file represents a collection of edges which are outbound from a given nodetype. It is a CSV file and has $edges.csv appended to the file name. Each row in this file represents an edge and the first column contains an edge ID. The edge ID must be a number (internally, a long) and is unique across all the files that you import.
The second column contains an edgetype ID, which must have an int value. The edgetype ID can be one of the following:
- Correspond to the @importid field of an edgetype defined in the import configuration file, or
- A default, generic edgetype ID such as: 1024 for undirected, 1025 for directed, 1026 for bidirected.
The third column contains the node ID of the "from" node, and the fourth column contains the node ID of the "to" node. Subsequent columns contain attribute values. The order in which the edge file contains the attribute descriptors is also stored in the configuration file.
Configuration file
The import configuration file stores the node and edge file names, as well as the ordered lists of attributes within these files. The extension for this file is .conf. The configuration file can include all the sections of a database initialization configuration file and must have an [import] section. The sections of the file that you import follow the same format of that section in the initialization configuration file (For example, <tgdb_home>/bin/initdb.conf).
[edgetypes] - If the edgetype is used in the import, then the edgetype definition must include an @importid field that corresponds to its edgetype ID in the edge files.
For example,
<edgetypename> = @direction:<direction> @fromnode:<fromnode> @tonode:<tonode> @attrs:<attr1>,<attr2>,... @importid:<importid>
[import] - List each nodetype name followed by the following fields:
- @attrs field with the attribute descriptor list for the node file
- @edgeattrs field with the attribute descriptor list for the edge file
- @files field with the list of files to import for that nodetype
For example,
<nodetypename> = @attrs:<attr1>,<attr2>,... @edgeattrs:<attr3>,<attr4>,... @files:<nodefilename>.csv,<edgefilename>$edges.csv
The following options are also available to allow import:
- If the import starts during database initialization, specify the directory where all the files that you import are located:
dir = <path>
- Specify one of the following load options:
a) insert - Insert the new entity
b) upsert - Insert the new entities and update the existing one
If left unspecified, it takes insert as a default load option.
loadopts = insert|upsert
- Specify one of the following error options:
a) ignore - Ignore errors
b) stop - Stop import process on error
If you select the ignore option, any errors found will still be logged. If left unspecified, it takes stop as a default error option.
erroropts = ignore|stop
- Specify one of the following format for date, time, and timestamp attribute descriptors:
a) internal - a long value that is unique to the internal representation, produced by export
b) ymd - year-month-day
c) dmy - day-month-year
d) mdy - month-day-year
If left unspecified, it takes ymd as a default date time format.
dtformat = internal|ymd|dmy|mdy