Class BinaryDataProvider

java.lang.Object
gaiasky.data.group.AbstractStarGroupDataProvider
gaiasky.data.group.BinaryDataProvider
All Implemented Interfaces:
IParticleGroupDataProvider, IStarGroupDataProvider

public class BinaryDataProvider
extends AbstractStarGroupDataProvider
Reads arrays of star beans from binary files, usually to go in an octree. The header of the format depends on the version.
  • Versions 0 and 1:
    • int: number of stars
  • Version 2+:
    • int: negative integer token to differentiate from versions 0/1 (-1)
    • int: format version number
    • int: number of stars
  • Field Details

    • DEFAULT_OUTPUT_VERSION

      public static int DEFAULT_OUTPUT_VERSION
      The default output format version to use for writing
    • MIN_OUTPUT_VERSION

      public static int MIN_OUTPUT_VERSION
    • MAX_OUTPUT_VERSION

      public static int MAX_OUTPUT_VERSION
  • Constructor Details

    • BinaryDataProvider

      public BinaryDataProvider()
  • Method Details

    • loadData

      public java.util.List<IParticleRecord> loadData​(java.lang.String file, double factor)
      Description copied from interface: IStarGroupDataProvider
      Loads the data applying a factor.
      Parameters:
      file - The file to load
      factor - Factor to apply to the positions
      Returns:
      Array of particle beans
    • loadData

      public java.util.List<IParticleRecord> loadData​(java.io.InputStream is, double factor)
      Description copied from interface: IStarGroupDataProvider
      Loads the data applying a factor.
      Parameters:
      is - Input stream to load the data from
      factor - Factor to apply to the positions
      Returns:
      Array of particle beans
    • writeData

      public void writeData​(java.util.List<IParticleRecord> data, java.io.OutputStream out)
    • writeData

      public void writeData​(java.util.List<IParticleRecord> data, java.io.OutputStream out, int version)
    • readData

      public java.util.List<IParticleRecord> readData​(java.io.InputStream in, double factor)
    • loadDataMapped

      public java.util.List<IParticleRecord> loadDataMapped​(java.lang.String file, double factor)
      Description copied from interface: IStarGroupDataProvider
      Loads the data applying a factor using a memory mapped file for improved speed.
      Parameters:
      file - The file to load
      factor - Factor to apply to the positions
      Returns:
      Array of particle beans
    • loadDataMapped

      public java.util.List<IParticleRecord> loadDataMapped​(java.lang.String file, double factor, int versionHint)
      Loads data mapped with a version hint.
      Parameters:
      file - The file to load
      factor - Distance factor, if any
      versionHint - Data version number, in case of version 0 or 1, since these formats were not annotated. If version >=2, the version number is read from the file header
      Returns:
    • setOutputFormatVersion

      public void setOutputFormatVersion​(int version)
      Description copied from interface: IStarGroupDataProvider
      Set the preferred output format version, if applicable
      Specified by:
      setOutputFormatVersion in interface IStarGroupDataProvider
      Overrides:
      setOutputFormatVersion in class AbstractStarGroupDataProvider
      Parameters:
      version - The version number