public abstract class OraclePropertyGraphUtilsBase extends Object implements MesgConsts
ERR_ARG_CANNOT_BE_NULL, ERR_CODE_NOT_IN_LIST, ERR_DOP_CONSTRAINT, ERR_E_DS_MUSTBE_FILE_OR_IS, ERR_E_MAX_LINE_CONSTRAINT, ERR_EDGE_DIR_NOT_BOTH, ERR_GRAPH_NAME_CANT_BENULL, ERR_HIT_EXCEPTION, ERR_HIT_INTERRUPT, ERR_HIT_IO, ERR_HIT_OPGE, ERR_HIT_PARSEE, ERR_ID_CANNOT_BE_NULL, ERR_IDX_KEY_CANNOT_BE_NULL, ERR_IN_DS_EDGE_CANTBE_NULL, ERR_IN_DS_VERT_CANTBE_NULL, ERR_IN_E_FLAT_DOESNT_EXIST, ERR_IN_V_FLAT_DOESNT_EXIST, ERR_INVALID_NUM_FIELDS, ERR_INVALID_NUM_NOARG, ERR_INVALID_NUMBER, ERR_INVALID_VAL, ERR_KEY_CANNOT_BE_ID, ERR_KEY_CANNOT_BE_NULL, ERR_KEY_NOT_SET_TO, ERR_NO_ELEM_TO_BE_CONSUMED, ERR_NO_OP_SUPPORTED, ERR_NOT_IMPLEMENTED_YET, ERR_NOT_ORACLE_V_E, ERR_NUM_PART_CONSTRAINT, ERR_OFFSET_CONSTRAINT, ERR_OFFSET_E_MUST_BE_POS, ERR_OFFSET_V_MUST_BE_POS, ERR_PG_ALREADY_EXISTS, ERR_PG_NOT_EMPTY, ERR_SIZE_MUST_BE_POS, ERR_TIMEOUT_TAB_CREATION, ERR_TYPE_ID_NOT_RECO, ERR_UNSUPPORTED_VAL_TYP, ERR_USER_REQ_OP_CANCEL, ERR_V_DS_MUSTBE_FILE_OR_IS, ERR_V_MAX_LINE_CONSTRAINT, ERR_VALUE_CANNOT_BE_NULL, INFO_EMP_K_NO_P_VAL, INFO_NUL_K_NO_P_VAL
Constructor and Description |
---|
OraclePropertyGraphUtilsBase() |
Modifier and Type | Method and Description |
---|---|
static boolean |
compareFiles(String szSrcFile,
String szDstFile)
Compare the content of two files contents against each other
|
static void |
convertCSV2OPE(InputStream inCSV,
String eidColName,
long lOffsetEID,
String svidColName,
String dvidColName,
boolean hasEdgeLabelCol,
String elColName,
ColumnToAttrMapping[] ctams,
int dop,
char delimiterChar,
char quotationChar,
long lOffsetLines,
OutputStream opeOS,
DataConverterListener dcl)
Converts a property graph file for edges in CSV format into Oracle Flat
File format.
|
static void |
convertCSV2OPE(InputStream inCSV,
String eidColName,
long lOffsetEID,
String svidColName,
String dvidColName,
boolean hasEdgeLabelCol,
String elColName,
ColumnToAttrMapping[] ctams,
int dop,
long lOffsetLines,
OutputStream opeOS,
DataConverterListener dcl)
Converts a property graph file for edges in CSV format into Oracle Flat
File format.
|
static void |
convertCSV2OPV(InputStream inCSV,
String vidColName,
long lOffsetVID,
ColumnToAttrMapping[] ctams,
int dop,
char delimiterChar,
char quotationChar,
long lOffsetLines,
OutputStream opvOS,
DataConverterListener dcl)
Converts a property graph file for vertices in CSV format into Oracle Flat
File format using the specified delimiters.
|
static void |
convertCSV2OPV(InputStream inCSV,
String vidColName,
long lOffsetVID,
ColumnToAttrMapping[] ctams,
int dop,
long lOffsetLines,
OutputStream opvOS,
DataConverterListener dcl)
Converts a property graph file for vertices in CSV format into Oracle Flat
File format using the specified delimiters.
|
static void |
convertRDBMSTable2OPE(Connection conn,
String rdbmsTableName,
String eidColName,
long lEIDOffset,
String svidColName,
String dvidColName,
long lVIDOffset,
boolean bHasEdgeLabelCol,
String elColName,
ColumnToAttrMapping[] ctams,
int dop,
OutputStream opeOS,
DataConverterListener dcl)
This method converts given rdbms table to a ope file
|
static void |
convertRDBMSTable2OPV(Connection conn,
String rdbmsTableName,
String vidColName,
long lVIDOffset,
ColumnToAttrMapping[] ctams,
int dop,
OutputStream opvOS,
DataConverterListener dcl)
This method converts given rdbms table to a opv file
|
static byte[] |
escape(String s)
This method escapes a string in the following manner:
In one scan from left to right, a % is replaced with %25, a tab \t is replaced with %09,
a newline \n is replaced with %0A, and a comma is replaced with %2c.
|
static void |
exportFlatFiles(OraclePropertyGraphBase pg,
OutputStream osVertex,
OutputStream osEdge,
int dop,
boolean append)
This function exports a given property graph into two flat files: one
for vertices and the other for edges.
|
static void |
exportFlatFiles(OraclePropertyGraphBase pg,
String vertexFileName,
String edgeFileName,
boolean append)
This function exports a given property graph into two flat files: one
for vertices and the other for edges.
|
static void |
exportFlatFiles(OraclePropertyGraphBase pg,
String vertexFileName,
String edgeFileName,
int dop,
boolean append)
This function exports a given property graph into two flat files: one
for vertices and the other for edges.
|
static void |
exportGML(OraclePropertyGraphBase opg,
OutputStream os,
PrintStream psOut)
Exports all vertices/edges from the specified property graph into the output
stream in GML format.
|
static void |
exportGML(OraclePropertyGraphBase opg,
String gmlFileName,
PrintStream psOut)
Exports all vertices/edges from the specified property graph into the specified
file in GML format.
|
static void |
exportGraphML(OraclePropertyGraphBase opg,
OutputStream os,
PrintStream psOut)
Exports all vertices/edges from the specified property graph into the output
stream in GraphGML format.
|
static void |
exportGraphML(OraclePropertyGraphBase opg,
String graphMLFileName,
PrintStream psOut)
Exports all vertices/edges from the specified property graph into the specified
file in GraphGML format.
|
static void |
exportGraphSON(OraclePropertyGraphBase opg,
OutputStream os,
PrintStream psOut)
Exports all vertices/edges from the specified property graph into the output
stream in GraphSON format.
|
static void |
exportGraphSON(OraclePropertyGraphBase opg,
String graphSonFileName,
PrintStream psOut)
Exports all vertices/edges from the specified property graph into the specified
file in GraphSON format.
|
static InputStream |
handleGZipInputStream(InputStream in)
Handle a GZIPInputStream
|
static void |
importGML(OraclePropertyGraphBase opg,
InputStream is,
PrintStream psOut)
Imports all vertices/edges from the input stream in GML format into
the specified property graph.
|
static void |
importGML(OraclePropertyGraphBase opg,
String gmlFileName,
PrintStream psOut)
Imports all vertices/edges from the specified file in GML format into
the specified property graph.
|
static void |
importGraphML(OraclePropertyGraphBase opg,
InputStream is,
PrintStream psOut)
Imports all vertices/edges from the input stream in GraphGML format into
the specified property graph.
|
static void |
importGraphML(OraclePropertyGraphBase opg,
String graphMLFileName,
PrintStream psOut)
Imports all vertices/edges from the specified file in GraphGML format into
the specified property graph.
|
static void |
importGraphSON(OraclePropertyGraphBase opg,
InputStream is,
PrintStream psOut)
Imports all vertices/edges from the input stream in GraphSON format into
the specified property graph.
|
static void |
importGraphSON(OraclePropertyGraphBase opg,
String graphSonFileName,
PrintStream psOut)
Imports all vertices/edges from the specified file in GraphSON format into
the specified property graph.
|
static <E> List<E> |
listify(Iterable<E> it)
This method converts a given Iterable instance to a List object.
|
static void |
quietlyClose(BufferedReader br)
Quietly closes the specified BufferedReader.
|
static void |
quietlyClose(InputStream is)
Quietly closes the specified
InputStream . |
static void |
quietlyClose(OutputStream os)
Quietly closes the specified
OutputStream . |
static void |
quietlyCloseResultSet(ResultSet rs)
This method will close (in a best effort fashion) the provided result
set.
|
static void |
quietlyCloseResultSetAndStmt(ResultSet rs)
This method will close (in a best effort fashion) the provided result
set and its corresponding statement.
|
static void |
quietlyCloseResultSetAndStmt(ResultSet rs,
Statement stmt)
This method will close (in a best effort fashion) the provided result
set and its corresponding statement.
|
static void |
quietlyCloseStmt(Statement stmt) |
static void |
quietlyShutdown(OraclePropertyGraphBase opg)
Quietly shutdown a property graph.
|
static <E> long |
size(Iterable<E> it)
This method returns the number of elements in the given Iterable object.
|
static String |
unescape(String s)
This method unescapes a string in the following manner:
In one scan from left to right, a %2C is replaced with a comma ',', a %09 is replaced with a tab \t,
a %0A is replaced with a newline \n, and %25 is replaced with a percentage %.
|
static void |
writeValue(OutputStream os,
Object value,
byte[] baFieldDelimiter,
SimpleDateFormat sdf)
This helper function serializes an object into the given output stream.
|
public static final boolean compareFiles(String szSrcFile, String szDstFile) throws IOException
szSrcFile
- the name of the first file to compareszDstFile
- the name of the second file to compareIOException
public static void convertCSV2OPE(InputStream inCSV, String eidColName, long lOffsetEID, String svidColName, String dvidColName, boolean hasEdgeLabelCol, String elColName, ColumnToAttrMapping[] ctams, int dop, char delimiterChar, char quotationChar, long lOffsetLines, OutputStream opeOS, DataConverterListener dcl)
ColumnToAttrMapping
array is supplied with all the details of the column names and their type.
If the ColumnToAttrMapping
array supplied is null then the files must include a
header in the first line.inCSV
- an InputStream
object for the CSV fileeidColName
- the column name that will be used as EID. If NULL, then
the EID will be generated based on the line number. If the given
column name does not have a numeric value, the value will be hashed into
a long number for the ID.lOffsetEID
- the offset to the EID. Each EID will have a value of
(lOffsetEID + EID).svidColName
- the column name that will be used as SVID. If the given
column name does not have a numeric value, the value will be hashed into
a long number for the ID.dvidColName
- the column name that will be used as DVID. If the given
column name does not have a numeric value, the value will be hashed into
a long number for the ID.hasEdgeLabelCol
- if true, read from elColName and treat the values as
edge labels. If false, use elColName as a constant for all edge labelselColName
- the column name that will be used as edge labelctams
- an array of ColumnToAttrMapping objects. Each ColumnToAttrMapping
object defines a mapping from a column in CSV file to an attribute of
certain type in an OPE file. These mappings must be in the same order
as the values are presented in the CSV file. E.g. If a CSV file
includes a header for name,age,weight; the ctams array must include
these mappings in the same order.dop
- degree of parallelism used to optimize converting performance.delimiterChar
- the character used to delimit values in a CSV file, e.g. ','quotationChar
- the character used to delimit how to treat quotation
characters for values, e.g. '"'lOffsetLines
- in order to skip the first lines of the input fileopeOS
- the OutputStream
object where the OPE file will be writtendcl
- an instance of DataConverterListener that can be used to report
progress and control the conversion process when an error occurs.public static void convertCSV2OPE(InputStream inCSV, String eidColName, long lOffsetEID, String svidColName, String dvidColName, boolean hasEdgeLabelCol, String elColName, ColumnToAttrMapping[] ctams, int dop, long lOffsetLines, OutputStream opeOS, DataConverterListener dcl)
ColumnToAttrMapping
array is supplied with all the details of the column names and their type.
If the ColumnToAttrMapping
array supplied is null then the files must include a
header in the first line.inCSV
- an InputStream
object for the CSV fileeidColName
- the column name that will be used as EID. If NULL, then
the EID will be generated based on the line number. If the given
column name does not have a numeric value, the value will be hashed into
a long number for the ID.lOffsetEID
- the offset to the EID. Each EID will have a value of
(lOffsetEID + EID).svidColName
- the column name that will be used as SVID. If the given
column name does not have a numeric value, the value will be hashed into
a long number for the ID.dvidColName
- the column name that will be used as DVID. If the given
column name does not have a numeric value, the value will be hashed into
a long number for the ID.hasEdgeLabelCol
- if true, read from elColName and treat the values as
edge labels. If false, use elColName as a constant for all edge labelselColName
- the column name that will be used as edge labelctams
- an array of ColumnToAttrMapping objects. Each ColumnToAttrMapping
object defines a mapping from a column in CSV file to an attribute of
certain type in an OPE file. These mappings must be in the same order
as the values are presented in the CSV file. E.g. If a CSV file
includes a header for name,age,weight; the ctams array must include
these mappings in the same order.dop
- degree of parallelism used to optimize converting performance.lOffsetLines
- in order to skip the first lines of the input fileopeOS
- the OutputStream
object where the OPE file will be writtendcl
- an instance of DataConverterListener that can be used to report
progress and control the conversion process when an error occurs.public static void convertCSV2OPV(InputStream inCSV, String vidColName, long lOffsetVID, ColumnToAttrMapping[] ctams, int dop, char delimiterChar, char quotationChar, long lOffsetLines, OutputStream opvOS, DataConverterListener dcl)
ColumnToAttrMapping
array is supplied with all the details of the column names and their type.
If the ColumnToAttrMapping
array supplied is null then the files must include a
header in the first line.inCSV
- an InputStream
object for the CSV filevidColName
- the column name that will be used as VID. If NULL, then
the VID will be generated based on the line number. If the given
column name does not have a numeric value, the value will be hashed into
a long number for the ID.lOffsetVID
- the offset to the VID. Each VID will have a value of
(lOffsetVID + VID).ctams
- an array of ColumnToAttrMapping objects. Each ColumnToAttrMapping
object defines a mapping from a column in CSV file to an attribute of
certain type in an OPV file. These mappings must be in the same order
as the values are presented in the CSV file. E.g. If a CSV file
includes a header for name,age,weight; the ctams array must include
these mappings in the same order.dop
- degree of parallelism used to optimize converting performance.delimiterChar
- the character used to delimit values in a CSV file, e.g. ','quotationChar
- the character used to delimit how to treat quotation
characters for values, e.g. '"'lOffsetLines
- in order to skip the first lines of the input fileopvOS
- the OutputStream
object where the OPV file will be writtendcl
- an instance of DataConverterListener that can be used to report
progress and control the conversion process when an error occurs.public static void convertCSV2OPV(InputStream inCSV, String vidColName, long lOffsetVID, ColumnToAttrMapping[] ctams, int dop, long lOffsetLines, OutputStream opvOS, DataConverterListener dcl)
ColumnToAttrMapping
array is supplied with all the details of the column names and their type.
If the ColumnToAttrMapping
array supplied is null then the files must include a
header in the first line.inCSV
- an InputStream
object for the CSV filevidColName
- the column name that will be used as VID. If NULL, then
the VID will be generated based on the line number. If the given
column name does not have a numeric value, the value will be hashed into
a long number for the ID.lOffsetVID
- the offset to the VID. Each VID will have a value of
(lOffsetVID + VID).ctams
- an array of ColumnToAttrMapping objects. Each ColumnToAttrMapping
object defines a mapping from a column in CSV file to an attribute of
certain type in an OPV file. These mappings must be in the same order
as the values are presented in the CSV file. E.g. If a CSV file
includes a header for name,age,weight; the ctams array must include
these mappings in the same order.dop
- degree of parallelism used to optimize converting performance.lOffsetLines
- in order to skip the first lines of the input fileopvOS
- the OutputStream
object where the OPV file will be writtendcl
- an instance of DataConverterListener that can be used to report
progress and control the conversion process when an error occurs.public static void convertRDBMSTable2OPE(Connection conn, String rdbmsTableName, String eidColName, long lEIDOffset, String svidColName, String dvidColName, long lVIDOffset, boolean bHasEdgeLabelCol, String elColName, ColumnToAttrMapping[] ctams, int dop, OutputStream opeOS, DataConverterListener dcl)
conn
- an connection instance to Oracle relational databaserdbmsTableName
- the name of RDBMS table to be convertedeidColName
- the column in given RDBMS table to be treated as eid, can be NULL
when eidColName is not null and of type integer/long: use (column value + lEIDOffset) as eid
when eidColName is not null and not of type integer/long: use (hash(column value) + lEIDOffset) as eid
when eidColName is null: use (rownum + lEIDOffset) as eidlEIDOffset
- the offset to the eidsvidColName
- the column in given RDBMS table to be treated as svid, can not be NULL
when svidColName is of type integer/long: use (column value + lVIDOffset) as svid
when svidColName is not of type integer/long: use (hash(column value) + lVIDOffset) as sviddvidColName
- the column in given RDBMS table to be treated as dvid, can not be NULL
when eidColName is of type integer/long: use (column value + lVIDOffset) as dvid
when eidColName is not of type integer/long: use (hash(column value) + lVIDOffset) as dvidlVIDOffset
- the offset to svid and dvidbHasEdgeLabelCol
- a boolean flag represents if the given rdbms table has a column for edge labels
if true, use (value of column elColName) as edge label
if false, use elColName as a constant for all edge labelselColName
- ctams
- an array of ColumnToAttrMapping objects; each ColumnToAttrMapping object defines a mapping from a column in rdbms table to an attribute of certain type in opedop
- degree of parallelismopeOS
- ope output stream to be written todcl
- an instance of DataConverterListener that can be used to report progress and control the conversion process when an error occurrs.public static void convertRDBMSTable2OPV(Connection conn, String rdbmsTableName, String vidColName, long lVIDOffset, ColumnToAttrMapping[] ctams, int dop, OutputStream opvOS, DataConverterListener dcl)
conn
- an connection instance to Oracle relational databaserdbmsTableName
- the name of RDBMS table to be convertedvidColName
- the column in given RDBMS table to be treated as vid
when vidColName is not null and of type integer/long: use (column value + lVIDOffset) as vid
when vidColName is not null and not of type integer/long: use (hash(column value) + lVIDOffset) as vid
when vidColName is null: use (rownum + lVIDOffset) as vidlVIDOffset
- the offset to the vidctams
- an array of ColumnToAttrMapping objects; each ColumnToAttrMapping object defines a mapping from a column in rdbms table to an attribute of certain type in opvdop
- degree of parallelismopvOS
- opv output stream to be written todcl
- an instance of DataConverterListener that can be used to report progress and control the conversion process when an error occurrs.public static final byte[] escape(String s)
s
- the string to be escapedpublic static void exportFlatFiles(OraclePropertyGraphBase pg, OutputStream osVertex, OutputStream osEdge, int dop, boolean append) throws IOException, FileNotFoundException
pg
- the property graph that will be exported into flat filesosVertex
- an OutputStream
object for the vertex flat fileosEdge
- an OutputStream
object for the edge flat filedop
- the degree of parallelism used when writing the data into the
flat files. This will use multiple threads to optimize writing performance.append
- if false, overwrite the existing flat files removing all
existing data.IOException
FileNotFoundException
public static final void exportFlatFiles(OraclePropertyGraphBase pg, String vertexFileName, String edgeFileName, boolean append) throws IOException, FileNotFoundException
pg
- the property graph that will be exported into flat filesvertexFileName
- the name of the vertex flat file e.g. graph.opvedgeFileName
- the name of the edge flat file e.g. graph.opeappend
- if false, overwrite the existing flat files removing all
existing data.IOException
FileNotFoundException
public static final void exportFlatFiles(OraclePropertyGraphBase pg, String vertexFileName, String edgeFileName, int dop, boolean append) throws IOException, FileNotFoundException
pg
- the property graph that will be exported into flat filesvertexFileName
- the name of the vertex flat file e.g. graph.opvedgeFileName
- the name of the edge flat file e.g. graph.opedop
- the degree of parallelism used when writing the data into the
flat files. This will use multiple threads to optimize writing performance.append
- if false, overwrite the existing flat files removing all
existing data.IOException
FileNotFoundException
public static final void exportGML(OraclePropertyGraphBase opg, OutputStream os, PrintStream psOut) throws IOException
opg
- the property graph to be exported.os
- the OutputStream
where the property graph data will be exportedpsOut
- IOException
public static final void exportGML(OraclePropertyGraphBase opg, String gmlFileName, PrintStream psOut) throws IOException
opg
- the property graph to be exported.gmlFileName
- the name of the file where the data should be writtenpsOut
- IOException
public static final void exportGraphML(OraclePropertyGraphBase opg, OutputStream os, PrintStream psOut) throws IOException
opg
- the property graph to be exported.os
- the OutputStream
where the property graph data will be exportedpsOut
- IOException
public static final void exportGraphML(OraclePropertyGraphBase opg, String graphMLFileName, PrintStream psOut) throws IOException
opg
- the property graph to be exported.graphMLFileName
- the name of the file where the data should be writtenIOException
public static final void exportGraphSON(OraclePropertyGraphBase opg, OutputStream os, PrintStream psOut) throws IOException
opg
- the property graph to be exported.os
- the OutputStream
where the property graph data will be exportedIOException
public static final void exportGraphSON(OraclePropertyGraphBase opg, String graphSonFileName, PrintStream psOut) throws IOException
opg
- the property graph to be exported.graphSonFileName
- the name of the file where the data should be writtenIOException
public static final InputStream handleGZipInputStream(InputStream in) throws IOException
IOException
public static final void importGML(OraclePropertyGraphBase opg, InputStream is, PrintStream psOut) throws IOException
opg
- the property graph to be exported.is
- the InputStream
where the property graph data will be importedIOException
public static final void importGML(OraclePropertyGraphBase opg, String gmlFileName, PrintStream psOut) throws IOException
opg
- the property graph to be exported.gmlFileName
- the file name where the property graph data will be importedIOException
public static final void importGraphML(OraclePropertyGraphBase opg, InputStream is, PrintStream psOut) throws IOException
opg
- the property graph to be exported.is
- the InputStream
where the property graph data will be importedIOException
public static final void importGraphML(OraclePropertyGraphBase opg, String graphMLFileName, PrintStream psOut) throws IOException
opg
- the property graph to be exported.graphMLFileName
- the file name where the property graph data will be importedIOException
public static final void importGraphSON(OraclePropertyGraphBase opg, InputStream is, PrintStream psOut) throws IOException
opg
- the property graph to be exported.is
- the InputStream
where the property graph data will be importedIOException
public static final void importGraphSON(OraclePropertyGraphBase opg, String graphSonFileName, PrintStream psOut) throws IOException
opg
- the property graph to be exported.graphSonFileName
- the file name where the property graph data will be importedIOException
public static final <E> List<E> listify(Iterable<E> it)
it
- an Iterable instance. It can be NULL.public static void quietlyClose(BufferedReader br)
br
- the BufferedReader to close.public static final void quietlyClose(InputStream is)
InputStream
.is
- the InputStream
to close.public static final void quietlyClose(OutputStream os)
OutputStream
.os
- the OutputStream
to close.public static void quietlyCloseResultSet(ResultSet rs)
public static void quietlyCloseResultSetAndStmt(ResultSet rs)
public static void quietlyCloseResultSetAndStmt(ResultSet rs, Statement stmt)
public static void quietlyCloseStmt(Statement stmt)
public static final void quietlyShutdown(OraclePropertyGraphBase opg)
opg
- the property graph to be shutdown.public static final <E> long size(Iterable<E> it)
public static final String unescape(String s)
s
- the string to be unescaped.public static final void writeValue(OutputStream os, Object value, byte[] baFieldDelimiter, SimpleDateFormat sdf) throws IOException
os
- an OutputStream
objectvalue
- the value object to serialize.baFieldDelimiter
- the byte array representation of a fieldDelimiter
to use when processing values in a flat file.sdf
- a SimpleDateFormat
to use when parsing a Date value object.IOException
Copyright © 2016 Oracle and/or its affiliates. All Rights Reserved.