com.sparsity.sparksee.io
Class NodeTypeLoader

java.lang.Object
  extended by com.sparsity.sparksee.io.TypeLoader
      extended by com.sparsity.sparksee.io.NodeTypeLoader

public class NodeTypeLoader
extends TypeLoader

NodeTypeLoader class.

Specific TypeLoader implementation for node types.

Check out the 'Data import' section in the SPARKSEE User Manual for more details on this.

Author:
Sparsity Technologies http://www.sparsity-technologies.com

Constructor Summary
NodeTypeLoader()
          Creates a new instance.
NodeTypeLoader(RowReader rowReader, Graph graph, int type, AttributeList attrs, Int32List attrsPos)
          Creates a new instance.
 
Method Summary
 void register(TypeLoaderListener tel)
          Registers a new listener.
 void run()
          See the TypeLoader class Run method.
 void runNPhases(int partitions)
          See the TypeLoader class RunNPhases method.
 void runTwoPhases()
          See the TypeLoader class RunTwoPhases method.
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NodeTypeLoader

public NodeTypeLoader(RowReader rowReader,
                      Graph graph,
                      int type,
                      AttributeList attrs,
                      Int32List attrsPos)
Creates a new instance.

Parameters:
rowReader - [in] Input RowReader.
graph - [in] Graph.
type - [in] Type identifier.
attrs - [in] Attribute identifiers to be loaded.
attrsPos - [in] Attribute positions (column index >=0).

NodeTypeLoader

public NodeTypeLoader()
Creates a new instance.

Method Detail

setFrequency

public void setFrequency(int freq)
Sets the frequency of listener notification.

Overrides:
setFrequency in class TypeLoader
Parameters:
freq - [in] Frequency in number of rows managed to notify progress to all listeners

setLogOff

public void setLogOff()
Truns off all the error reporting.

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.

Overrides:
setLogOff in class TypeLoader

setLogError

public void setLogError(java.lang.String path)
                 throws java.io.IOException
Sets a log error file.

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.

Overrides:
setLogError in class TypeLoader
Parameters:
path - [in] The path to the error log file.
Throws:
java.io.IOException - If bad things happen opening the file.

setType

public void setType(int type)
Sets the type to be loaded.

Overrides:
setType in class TypeLoader
Parameters:
type - [in] Type identifier.

runTwoPhases

public void runTwoPhases()
                  throws java.io.IOException,
                         java.lang.RuntimeException
See the TypeLoader class RunTwoPhases method.

Overrides:
runTwoPhases in class TypeLoader
Throws:
java.io.IOException - null
java.lang.RuntimeException - null

setRowReader

public void setRowReader(RowReader rr)
Sets the input data source.

Overrides:
setRowReader in class TypeLoader
Parameters:
rr - [in] Input RowReader.

setAttributePositions

public void setAttributePositions(Int32List attrsPos)
Sets the list of attribute positions.

Overrides:
setAttributePositions in class TypeLoader
Parameters:
attrsPos - [in] Attribute positions (column index >=0).

register

public void register(TypeLoaderListener tel)
Registers a new listener.

Overrides:
register in class TypeLoader
Parameters:
tel - TypeLoaderListener to be registered.

setLocale

public void setLocale(java.lang.String localeStr)
Sets the locale that will be used to read the data.

It should match the locale used in the rowreader.

Overrides:
setLocale in class TypeLoader
Parameters:
localeStr - [in] The locale string for the read data. See CSVReader.

run

public void run()
         throws java.io.IOException,
                java.lang.RuntimeException
See the TypeLoader class Run method.

Overrides:
run in class TypeLoader
Throws:
java.io.IOException - null
java.lang.RuntimeException - null

setGraph

public void setGraph(Graph graph)
Sets the graph where the data will be loaded.

Overrides:
setGraph in class TypeLoader
Parameters:
graph - [in] Graph.

runNPhases

public void runNPhases(int partitions)
                throws java.io.IOException,
                       java.lang.RuntimeException
See the TypeLoader class RunNPhases method.

Overrides:
runNPhases in class TypeLoader
Parameters:
partitions - null
Throws:
java.io.IOException - null
java.lang.RuntimeException - null

setTimestampFormat

public void setTimestampFormat(java.lang.String timestampFormat)
Sets a specific timestamp format.

Overrides:
setTimestampFormat in class TypeLoader
Parameters:
timestampFormat - [in] A string with the timestamp format definition.

setAttributes

public void setAttributes(AttributeList attrs)
Sets the list of Attributes.

Overrides:
setAttributes in class TypeLoader
Parameters:
attrs - [in] Attribute identifiers to be loaded