Class BinaryPointDataProvider
java.lang.Object
gaiasky.data.group.BinaryPointDataProvider
- All Implemented Interfaces:
BinaryIO, IParticleGroupDataProvider
Loads and writes binary data into particle groups (
ParticleType.PARTICLE_EXT).
The format is:
- int (4 bytes) -- number of records
- byte (1 byte [0|1]) -- particle record type: true - PARTICLE_EXT, false - PARTICLE
- for each record:
- long (8 bytes) -- id
- short (2 bytes) -- nameLength
- char (2 bytes) * nameLength -- name characters
- double (8 bytes) -- alpha [deg]
- double (8 bytes) -- delta [deg]
- double (8 bytes) -- distance [pc]
- if type == PARTICLE_EXT
- float (4 bytes) -- mu alpha
- float (4 bytes) -- mu delta
- float (4 bytes) -- radial velocity
- float (4 bytes) -- vx
- float (4 bytes) -- vy
- float (4 bytes) -- vz
- float (4 bytes) -- apparent magnitude
- float (4 bytes) -- absolute magnitude
- float (4 bytes) -- packed color
- float (4 bytes) -- size
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionloadData(InputStream is, double factor, Runnable preCallback, BiConsumer<Long, Long> updateCallback, Runnable postCallback) Loads the data applying a factor.loadData(String file, double factor, Runnable preCallback, BiConsumer<Long, Long> updateCallback, Runnable postCallback) Loads the data applying a factor.loadData(String file, Runnable preCallback, BiConsumer<Long, Long> updateCallback, Runnable postCallback) Loads the data as it is.loadDataMapped(String file, double factor, Runnable preCallback, BiConsumer<Long, Long> updateCallback, Runnable postCallback) Loads the data applying a factor using a memory mapped file for improved speed.readData(InputStream in, double factor) readParticleRecord(IDataReader in, double factor) readParticleRecord(DataInputStream in, double factor) Read a star from the input stream.readParticleRecord(MappedByteBuffer mem, double factor) Read a star from the mapped buffer.voidsetDatasetOptions(DatasetOptions datasetOptions) voidsetFileNumberCap(int cap) Sets a cap on the number of files to load.voidsetProviderParams(Map<String, Object> params) Set provider parameters as a map.voidsetStarNumberCap(int cap) Sets the maximum number of stars to be processed per file.voidsetTransformMatrix(Matrix4D matrix) Sets a transform matrix to apply to all data points.voidwriteData(List<IParticleRecord> data, OutputStream out, boolean extra) voidWrite the star bean to the output stream.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface IParticleGroupDataProvider
isUniformEpochModifier and TypeMethodDescriptiondefault booleanDo all particles in the group have the same epoch?
-
Field Details
-
logger
-
list
-
-
Constructor Details
-
BinaryPointDataProvider
public BinaryPointDataProvider()
-
-
Method Details
-
setDatasetOptions
-
loadData
public List<IParticleRecord> loadData(String file, Runnable preCallback, BiConsumer<Long, Long> updateCallback, Runnable postCallback) Description copied from interface:IParticleGroupDataProviderLoads the data as it is.- Specified by:
loadDatain interfaceIParticleGroupDataProvider- Parameters:
file- The file to load.preCallback- Callback to run before loading starts.updateCallback- Callback to run during loading, for every object. Contains the current object number and the total number.postCallback- Callback to run after loading is done.- Returns:
- The array of particle records.
-
loadData
public List<IParticleRecord> loadData(String file, double factor, Runnable preCallback, BiConsumer<Long, Long> updateCallback, Runnable postCallback) Description copied from interface:IParticleGroupDataProviderLoads the data applying a factor.- Specified by:
loadDatain interfaceIParticleGroupDataProvider- Parameters:
file- The file to load.factor- Factor to apply to the positions.preCallback- Callback to run before loading starts.updateCallback- Callback to run during loading, for every object. Contains the current object number and the total number.postCallback- Callback to run after loading is done.- Returns:
- The array of particle records.
-
loadData
public List<IParticleRecord> loadData(InputStream is, double factor, Runnable preCallback, BiConsumer<Long, Long> updateCallback, Runnable postCallback) Description copied from interface:IParticleGroupDataProviderLoads the data applying a factor.- Specified by:
loadDatain interfaceIParticleGroupDataProvider- Parameters:
is- Input stream to load the data from.factor- Factor to apply to the positions.preCallback- Callback to run before loading starts.updateCallback- Callback to run during loading, for every object. Contains the current object number and the total number.postCallback- Callback to run after loading is done.- Returns:
- The array of particle records.
-
readData
-
loadDataMapped
public List<IParticleRecord> loadDataMapped(String file, double factor, Runnable preCallback, BiConsumer<Long, Long> updateCallback, Runnable postCallback) Description copied from interface:IParticleGroupDataProviderLoads the data applying a factor using a memory mapped file for improved speed.- Specified by:
loadDataMappedin interfaceIParticleGroupDataProvider- Parameters:
file- The file to load.factor- Factor to apply to the positions.preCallback- Callback to run before loading starts.updateCallback- Callback to run during loading, for every object. Contains the current object number and the total number.postCallback- Callback to run after loading is done.- Returns:
- The array of particle records.
-
setFileNumberCap
public void setFileNumberCap(int cap) Description copied from interface:IParticleGroupDataProviderSets a cap on the number of files to load. Set to negative for unlimited.- Specified by:
setFileNumberCapin interfaceIParticleGroupDataProvider- Parameters:
cap- The file cap number.
-
setStarNumberCap
public void setStarNumberCap(int cap) Description copied from interface:IParticleGroupDataProviderSets the maximum number of stars to be processed per file. Set to negative for unlimited.- Specified by:
setStarNumberCapin interfaceIParticleGroupDataProvider- Parameters:
cap- The star cap number.
-
setProviderParams
Description copied from interface:IParticleGroupDataProviderSet provider parameters as a map.- Specified by:
setProviderParamsin interfaceIParticleGroupDataProvider- Parameters:
params- The parameters map.
-
setTransformMatrix
Description copied from interface:IParticleGroupDataProviderSets a transform matrix to apply to all data points.- Specified by:
setTransformMatrixin interfaceIParticleGroupDataProvider- Parameters:
matrix- The transform matrix.
-
readParticleRecord
Description copied from interface:BinaryIORead a star from the mapped buffer.- Specified by:
readParticleRecordin interfaceBinaryIO- Parameters:
mem- Mapped memory buffer to read from.factor- Scale factor to apply to the positions.- Returns:
- The star.
- Throws:
IOException
-
readParticleRecord
Description copied from interface:BinaryIORead a star from the input stream.- Specified by:
readParticleRecordin interfaceBinaryIO- Parameters:
in- Input stream.factor- Scale factor to apply to the positions.- Returns:
- The star.
- Throws:
IOException- If the read fails.
-
readParticleRecord
- Throws:
IOException
-
writeData
-
writeParticleRecord
Description copied from interface:BinaryIOWrite the star bean to the output stream.- Specified by:
writeParticleRecordin interfaceBinaryIO- Parameters:
sb- The star bean.out- The output stream.- Throws:
IOException- If the write operation fails.
-