public class TypeLoader
extends java.lang.Object
Base class to load a node or edge type from a graph using a RowReader.
TypeLoaderListener can be registered to receive information about the progress of the load process by means of TypeLoaderEvent. The default frequency of notification to listeners is 100000.
Check out the 'Data import' section in the SPARKSEE User Manual for more details on this.
Modifier and Type | Method and Description |
---|---|
void |
register(TypeLoaderListener tel)
Registers a new listener.
|
void |
run()
Run the loader.
|
void |
runNPhases(int partitions)
Run the loader for N phases loading.
|
void |
runTwoPhases()
Run the loader for two phases loading.
|
void |
setAttributePositions(Int32List attrsPos)
Sets the list of attribute positions.
|
void |
setAttributes(AttributeList attrs)
Sets the list of Attributes.
|
void |
setFrequency(int freq)
Sets the frequency of listener notification.
|
void |
setGraph(Graph graph)
Sets the graph where the data will be loaded.
|
void |
setLocale(java.lang.String localeStr)
Sets the locale that will be used to read the data.
|
void |
setLogError(java.lang.String path)
Sets a log error file.
|
void |
setLogOff()
Truns off all the error reporting.
|
void |
setRowReader(RowReader rr)
Sets the input data source.
|
void |
setTimestampFormat(java.lang.String timestampFormat)
Sets a specific timestamp format.
|
void |
setType(int type)
Sets the type to be loaded.
|
public void run() throws java.lang.RuntimeException, java.io.IOException
java.lang.RuntimeException
- nulljava.io.IOException
- nullpublic void runTwoPhases() throws java.lang.RuntimeException, java.io.IOException
Firstly load all objects (and create them if necessary) and secondly loads all the attributes.
Working on this mode it is necessary to build a temporary file.
java.lang.RuntimeException
- nulljava.io.IOException
- nullpublic void setLogError(java.lang.String path) throws java.io.IOException
By default errors are thrown as a exception and the load process ends. If a log file is set, errors are logged there and the load process does not stop.
path
- [in] The path to the error log file.java.io.IOException
- If bad things happen opening the file.public void setType(int type)
type
- [in] Type identifier.public void setLocale(java.lang.String localeStr)
It should match the locale used in the rowreader.
localeStr
- [in] The locale string for the read data. See CSVReader.public void setTimestampFormat(java.lang.String timestampFormat)
timestampFormat
- [in] A string with the timestamp format definition.public void setAttributes(AttributeList attrs)
attrs
- [in] Attribute identifiers to be loadedpublic void register(TypeLoaderListener tel)
tel
- TypeLoaderListener to be registered.public void setFrequency(int freq)
freq
- [in] Frequency in number of rows managed to notify progress to all listenerspublic void setRowReader(RowReader rr)
rr
- [in] Input RowReader.public void setAttributePositions(Int32List attrsPos)
attrsPos[in] Attribute positions (column index >=0).
attrsPos
- [in] Attribute positions (column index >=0).public void runNPhases(int partitions) throws java.lang.RuntimeException, java.io.IOException
Firstly load all objects (and create them if necessary) and secondly loads all the attributes. But in this case, attributes are loaded one by one. This way, if there are three attributes, then 4 traverses are necessary.
Working on this mode it is necessary to build a temporary file.
partitions
- [in] Number of horizontal partitions to perform the load.java.lang.RuntimeException
- nulljava.io.IOException
- nullpublic void setGraph(Graph graph)
graph
- [in] Graph.public void setLogOff()
The log file will not be created and no exceptions for invalid data will be thrown. If you just want to turn off the logs, but abort at the first error what you should do is not call this method and not set a logError file.