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 int
private boolean
private String
private String
private boolean
private String
private GremlinRecipies
private String
private String
private int
private int
private boolean
private int
private boolean
private boolean
private boolean
private String
private static Logger
Logging .private static String[]
private static String
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Close graph.protected String
fitsDir()
The directory for FITS files.getSimpleFields
(GenericRecord record, List<String> keeps, String[] avoids) GetSchema.Field
s corresponding to simple types and having non-null
values.getSimpleValues
(GenericRecord record, List<String> fields) Register part ofGenericRecord
in HBase.protected String
hbaseUrl()
The data HBase table url.static void
Import Avro files or directory.protected int
n()
Give number of created alerts/pcas.protected void
now()
Set newDate
.void
Process Avro alert file or directory with files (recursive).processAlert
(GenericRecord record) Process Avro alert.private void
processCutout
(GenericRecord record, Vertex mother, String objectId, String jd) Process Avro cutout.void
processDir
(String dirFN, String fileExt) Process directory with Avro alert files (recursive).void
processFile
(File file) Process Avro alert file .private Vertex
processGenericRecord
(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.void
processRecord
(GenericRecord record) ProcessGenericRecord
of the requested type.void
Register ImportVertex
.protected boolean
skip()
Tell, whether import shpuld be skipped.private Vertex
vertex
(GenericRecord record, String label, String property, String strategy) Create or drop aVertex
according to chosen strategy.protected void
Write 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
ProcessGenericRecord
of the requested type.- Parameters:
record
- TheGenericRecord
to 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
- TheGenericRecord
to 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 ifnull
objectId
- The objectId of the containing source.- Returns:
- The created
Vertex
.
-
processCutout
Process Avro cutout.- Parameters:
record
- TheGenericRecord
to process.mother
- TheVertex
to attach to.jd
- The jd of the corresponding candidate.
-
getSimpleValues
Register part ofGenericRecord
in HBase.- Parameters:
record
- TheGenericRecord
to be registered in HBase.fields
- The fields to be mapped.
-
getSimpleFields
GetSchema.Field
s corresponding to simple types and having non-null
values.- Parameters:
record
- TheGenericRecord
to use.keeps
- TheGenericRecord
to 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 aVertex
according to chosen strategy.- Parameters:
record
- The fullGenericRecord
.label
- TheVertex
label.property
- The name ofVertex
property. If null strategy is ignored andVertex
is created.strategy
- The creation strategy: drop, replace, reuse, skip, create. If anything else, the global strategy b is used.- Returns:
- The created
Vertex
or 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:ModifyingGremlinClient
Close graph.- Specified by:
close
in interfaceModifyingGremlinClient
- Overrides:
close
in classJanusClient
-
now
Set newDate
.
-