Class AvroImporter
java.lang.Object
com.Lomikel.Januser.JanusClient
com.astrolabsoftware.FinkBrowser.Avro.AvroImporter
- All Implemented Interfaces:
ModifyingGremlinClient
- Direct Known Subclasses:
HDFSAvroImporter
AvroImporter imports Avro files into JanusGraph.- Author:
- J.Hrivnac
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate intprivate booleanprivate Stringprivate Stringprivate booleanprivate Stringprivate GremlinRecipiesprivate Stringprivate Stringprivate intprivate intprivate booleanprivate intprivate booleanprivate booleanprivate booleanprivate Stringprivate static LoggerLogging .private static String[]private static String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Close graph.protected StringfitsDir()The directory for FITS files.getSimpleFields(GenericRecord record, List<String> keeps, String[] avoids) GetSchema.Fields corresponding to simple types and having non-nullvalues.getSimpleValues(GenericRecord record, List<String> fields) Register part ofGenericRecordin HBase.protected StringhbaseUrl()The data HBase table url.static voidImport Avro files or directory.protected intn()Give number of created alerts/pcas.protected voidnow()Set newDate.voidProcess Avro alert file or directory with files (recursive).processAlert(GenericRecord record) Process Avro alert.private voidprocessCutout(GenericRecord record, Vertex mother, String objectId, String jd) Process Avro cutout.voidprocessDir(String dirFN, String fileExt) Process directory with Avro alert files (recursive).voidprocessFile(File file) Process Avro alert file .private VertexprocessGenericRecord(GenericRecord record, String name, String idName, boolean tryDirection, Vertex mother, String edgeName, List<String> fields, String objectId) Process AvroGenericRecord.processPCA(GenericRecord record) Process Avro PCA.voidprocessRecord(GenericRecord record) ProcessGenericRecordof the requested type.voidRegister ImportVertex.protected booleanskip()Tell, whether import shpuld be skipped.private Vertexvertex(GenericRecord record, String label, String property, String strategy) Create or drop aVertexaccording to chosen strategy.protected voidWrite FITS file.Methods inherited from class com.Lomikel.Januser.JanusClient
commit, g, open, open, reopen, timer, timerStart
-
Field Details
-
COLUMNS_ALERT
-
COLUMNS_CANDIDATE
-
_gr
-
_jd
-
_reportLimit
-
_commitLimit
-
_fitsDir
-
_hbaseUrl
-
_dataType
-
_create
-
_reuse
-
_replace
-
_drop
-
_skip
-
_n
-
_nPrvCandidates
-
_date
-
_top
-
_topFn
-
PCAS
-
VERSION
-
log
Logging .
-
-
Constructor Details
-
AvroImporter
public AvroImporter(String properties, int reportLimit, int commitLimit, String strategy, String fitsDir, String hbaseUrl, String dataType) Create with JanusGraph properties file.- Parameters:
properties- The file with the complete Janusgraph properties.reportLimit- The number of events to use for progress report (-1 means no report untill the end).commitLimit- The number of events to commit in one step (-1 means commit only at the end).strategy- The creation strategy. drop,replace,getOrCreate.fitsDir- The directory for FITS files. If null or empty, FITS are included in the Graph. Ignored if HBase url set.hbaseUrl- The url for HBase table with full data as ip:port:table:schema. May be null or empty.dataType- The data type, alert|pca. If null, then considering as alert.
-
-
Method Details
-
main
Import Avro files or directory.- Parameters:
args- [0] The Janusgraph properties file.args- [1] The Avro file or directory with Avro files.args- [2] The directory for FITS files. If null or empty, FITS are included in the Graph. Ignored if HBase url set.args- [3] The url for HBase table with full data as ip:port:table:schema. May be null or empty.args- [4] The number of events to use for progress report (-1 means no report untill the end).args- [5] The number of events to commit in one step (-1 means commit only at the end).args- [6] The creation strategy. create,drop,replace,skip.args- [7] The data type, alert|pca. If null, then considering as alert.- Throws:
LomikelException- If anything goes wrong.IOException
-
processDir
Process directory with Avro alert files (recursive).- Parameters:
dirFN- The dirname of directiory with data file.fileExt- The file extention.- Throws:
IOException- If problem with file reading.
-
process
Process Avro alert file or directory with files (recursive).- Parameters:
fn- The filename of the data file or directory with files.- Throws:
IOException- If problem with file reading.LomikelException- If anything wrong.
-
register
Register ImportVertex.- Parameters:
fn- The filename of the data file or directory with files.
-
processFile
Process Avro alert file .- Parameters:
file- The data file.- Throws:
IOException- If problem with file reading.
-
processRecord
ProcessGenericRecordof the requested type.- Parameters:
record- TheGenericRecordto be rocessed.
-
processAlert
Process Avro alert.- Parameters:
record- The full alertGenericRecord.- Returns:
- The created
Vertex.
-
processPCA
Process Avro PCA. Only create PCAs for already existing sources. Do not verify if the PCA already exists (so multiple PCAs fvor one source may be created.- Parameters:
record- The full PCAGenericRecord.- Returns:
- The created
Vertex.
-
processGenericRecord
private Vertex processGenericRecord(GenericRecord record, String name, String idName, boolean tryDirection, Vertex mother, String edgeName, List<String> fields, String objectId) Process AvroGenericRecord.- Parameters:
record- TheGenericRecordto process.name- The name of newVertex.idName- The name of the unique identifying field.tryDirection- Whether try created Direction property from ra,dec fields.mother- The motherVertex.edgerName- The name of the edge to the motherVertex.fields- The list of fields to fill. All fields are filled ifnullobjectId- The objectId of the containing source.- Returns:
- The created
Vertex.
-
processCutout
Process Avro cutout.- Parameters:
record- TheGenericRecordto process.mother- TheVertexto attach to.jd- The jd of the corresponding candidate.
-
getSimpleValues
Register part ofGenericRecordin HBase.- Parameters:
record- TheGenericRecordto be registered in HBase.fields- The fields to be mapped.
-
getSimpleFields
GetSchema.Fields corresponding to simple types and having non-nullvalues.- Parameters:
record- TheGenericRecordto use.keeps- TheGenericRecordto report. Report all if null.avoids- The array of fields names not to report. Cannot cancel keeps argument.- Returns:
- The list of coressponding fields.
-
vertex
Create or drop aVertexaccording to chosen strategy.- Parameters:
record- The fullGenericRecord.label- TheVertexlabel.property- The name ofVertexproperty. If null strategy is ignored andVertexis created.strategy- The creation strategy: drop, replace, reuse, skip, create. If anything else, the global strategy b is used.- Returns:
- The created
Vertexor null.
-
writeFits
Write FITS file.- Parameters:
fn- The FITS file name.data- The FITS file content.
-
fitsDir
The directory for FITS files.- Returns:
- The FITS file directory.
-
hbaseUrl
The data HBase table url.- Returns:
- The data HBase table url.
-
n
Give number of created alerts/pcas.- Returns:
- The number of created alerts/pcas.
-
skip
Tell, whether import shpuld be skipped.- Returns:
- Whether import shpuld be skipped.
-
close
Description copied from interface:ModifyingGremlinClientClose graph.- Specified by:
closein interfaceModifyingGremlinClient- Overrides:
closein classJanusClient
-
now
Set newDate.
-