Package cds.moc

Class Moc1D

All Implemented Interfaces:
Cloneable, Comparable<Moc>, Iterable<MocCell>
Direct Known Subclasses:
SMoc, TMoc

public abstract class Moc1D extends Moc
The Moc1D class implements the methods specific to one-dimensional MOCs (e.g. SPACE or TIME).
  • Field Details

    • range

      protected Range range
    • mocOrder

      protected int mocOrder
    • sys

      protected String sys
    • biggestOrder

      protected int biggestOrder
  • Constructor Details

    • Moc1D

      protected Moc1D()
      Generic Moc 1D creator
    • Moc1D

      protected Moc1D(int mocOrder)
      Generic Moc 1D creator
      Parameters:
      mocOrder - Moc Order (-1 => not defined)
    • Moc1D

      protected Moc1D(String s) throws Exception
      Generic Moc 1D generator from ASCII Moc String
      Parameters:
      s - ASCII Moc (regular ASCII or JSON)
      Throws:
      Exception
    • Moc1D

      protected Moc1D(InputStream in) throws Exception
      Generic Moc 1D generator from input stream
      Parameters:
      in - input stream
      Throws:
      Exception
    • Moc1D

      protected Moc1D(Moc1D moc) throws Exception
      Generic Moc 1D generator from another Moc 1D
      Parameters:
      moc - moc to be dumped
      Throws:
      Exception
  • Method Details

    • toDebug

      public String toDebug()
      Specified by:
      toDebug in class Moc
    • lowAscii

      protected String lowAscii(int n)
      Display the n first ranges at the max order
    • clear

      public void clear()
      Clear the MOC - data only (not the properties, nor the mocOrder)
      Overrides:
      clear in class Moc
    • clone1

      protected void clone1(Moc moc) throws CloneNotSupportedException
      Deep copy. The source is this, the target is the Moc in parameter
      Overrides:
      clone1 in class Moc
      Throws:
      CloneNotSupportedException
    • reduction

      public boolean reduction(long maxSize) throws Exception
      Degrades the resolution(s) of the MOC until the RAM size of the MOC is reduced under the specified maximum (expressed in bytes).
      Specified by:
      reduction in class Moc
      Returns:
      true if there is a effective degradation
      Throws:
      Exception
    • maxOrder

      public abstract int maxOrder()
      Return the deepest possible order (ex: 29 for SMoc, 61 for TMoc)
    • shiftOrder

      public abstract int shiftOrder()
      Return the number of bit shifting between two consecutive orders (ex: 2 for SMoc, 1 for TMoc)
    • cDim

      public abstract char cDim()
      Return the Moc signature character (ex: 's' for SMoc, 't' for TMoc)
    • maxVal

      public abstract long maxVal()
      Return the number of values at the deepest order (ex: 2x2^29x2^29 for SMoc, 2^61 for TMoc)
    • sys

      public abstract String sys()
      Return the default reference system
    • computeHierarchy

      protected void computeHierarchy()
      Recalculates the metrics associated with the MOC hierarchical view: the number of hierarchical cells, the deepest order used...
      Specified by:
      computeHierarchy in class Moc
    • getNbValues

      public long getNbValues()
      Return the number of used cells at the Moc order: (ex: s2/1 3/5-6 => 6
    • setRangeList

      public void setRangeList(Range range)
      Set the list of ranges - Warning: no copy
      Specified by:
      setRangeList in class Moc
    • isEmpty

      public boolean isEmpty()
      Return true if the Moc is empty (no coverage)
      Specified by:
      isEmpty in class Moc
    • isFull

      public boolean isFull()
      Return true if the Moc is full (full coverage)
      Specified by:
      isFull in class Moc
    • getCoverage

      public double getCoverage()
      Return the coverage pourcentage of the Moc
      Specified by:
      getCoverage in class Moc
    • getNbRanges

      public int getNbRanges()
      Return the number of ranges
      Specified by:
      getNbRanges in class Moc
    • getMem

      public long getMem()
      Return approximatively the amount of memory used for storing this MOC in RAM (in bytes)
      Specified by:
      getMem in class Moc
    • isCompatible

      public boolean isCompatible(Moc moc)
      Return true if the moc is compatible for operation (same class and sys)
      Specified by:
      isCompatible in class Moc
    • operation

      protected Moc1D operation(Moc moc, int op) throws Exception
      Generic operations: 0-union, 1-intersection, 2-subtraction
      Specified by:
      operation in class Moc
      Throws:
      Exception
    • complement

      public Moc1D complement() throws Exception
      Return the complement
      Specified by:
      complement in class Moc
      Throws:
      Exception
    • equals

      public boolean equals(Object o)
      Return true in case of equality (only check data - no properties, nor MocOrder)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • isIncluding

      public boolean isIncluding(int order, long val)
    • isIntersecting

      public boolean isIntersecting(int order, long val)
    • setMocOrder

      public void setMocOrder(int mocOrder) throws Exception
      Set Moc order. Will impact the precision (and the number) of the values. -1 for internal reset
      Throws:
      Exception
    • getMocOrder

      public int getMocOrder()
      Return the Moc order. Either specically set by setOrder(). If not definied, return the biggest used order during the addition, And if not defined return the hierarchycal deespest order
    • setSys

      public void setSys(String sys)
      Set alternative reference System.
      Parameters:
      sys - alternative reference frame keyword (not standardized in IVOA document)
    • getSys

      public String getSys()
      Get the reference system. See setSys()
    • setMinOrder

      public void setMinOrder(int minOrder) throws Exception
      Set min Moc min Order. The hierarchical view will be start at this order. 0 by default
      Throws:
      Exception
    • getMinOrder

      public int getMinOrder()
      get min Moc min Order. The hierarchical view will be start at this order. 0 by default
    • add

      public void add(int order, long val) throws Exception
      Add one cell to the Moc.
      Parameters:
      order - Order of the cell
      val - Value of the cell
      Throws:
      Exception
    • add

      public void add(int order, long firstVal, long lastVal) throws Exception
      Add a list of consecutive Moc cells.
      Parameters:
      order - Order of the cells
      firstVal - First value
      lastVal - Last value (included)
      Throws:
      Exception
    • getStart

      public long getStart(int order, long val)
      Returns the value of the beginning of the interval expressed at the maximum order
    • getEnd

      public long getEnd(int order, long val)
      Returns the value of the end of the interval (excluded) expressed at the maximum order
    • bufferOn

      public void bufferOn()
      Activation of the buffererization. Significantly speeds up random multiple additions.
    • bufferOn

      public void bufferOn(int size)
      Activation of the buffererization. Significantly speeds up random multiple additions Required additionnal memory for the buffer (see bufferOff()) Note: Any read access or operation on the MOC will automatically be preceded by a flush() if necessary.
      Parameters:
      size - : size of the buffer (required even value)
    • bufferOff

      public void bufferOff()
      Stops the buffering and frees the memory required for it.
    • flush

      public void flush()
      Inserts in the MOC all the elements being inserted in the buffer. The buffering remains active for future insertions (unlike bufferOff())
      Specified by:
      flush in class Moc
    • bufferSize

      public int bufferSize()
      buffer size, not yet proceed
      Overrides:
      bufferSize in class Moc
    • add

      public void add(long[] valList, int size)
      Fast addition of a list of ranges expressed at the maximum order (2 consecutive longq per range): start..end (end excluded). These ranges do not need to be sorted, nor to be disjoint.
      Parameters:
      valList - list of range index
      size - Number of values (= 2x number of ranges)
    • add

      public void add(Moc moc) throws Exception
      Add directly a Moc
      Throws:
      Exception
    • seeRangeList

      public Range seeRangeList()
      Acces to the list of ranges (no copy)
      Specified by:
      seeRangeList in class Moc
    • cellIterator

      public Iterator<MocCell> cellIterator(boolean flagRange)
      Provide an Iterator on the MOC cell List (hierarchical view)
      Specified by:
      cellIterator in class Moc
      Parameters:
      flagRange - true for getting range rather than all individual values
      Returns:
      mocCell => dim,order,startVal,endVal
    • valIterator

      public Iterator<Long> valIterator()
      Return an Iterator providing the list of values at the Moc order. => values provided in ascending order
    • addToken

      protected void addToken(String token) throws Exception
      Internal usage: Add one token element according to the format "[s|t]order/npix[-npixn]". If the order is not mentioned, use the last used order (currentOrder) Note: Also support JSON non standard IVOA syntax
      Specified by:
      addToken in class Moc
      Parameters:
      token - one token (ex: s18/23-45)
      Throws:
      Exception
    • readSpecificDataUniq

      protected void readSpecificDataUniq(InputStream in, int naxis1, int naxis2, int nbyte) throws Exception
      Readers
      Throws:
      Exception
    • createMocByUniqUnsorted

      protected void createMocByUniqUnsorted(int nval, int nbyte, byte[] t, boolean protoTMoc) throws Exception
      Throws:
      Exception
    • createMocByUniq

      protected void createMocByUniq(int nval, int nbyte, byte[] t) throws Exception
      Throws:
      Exception
    • readSpecificDataRange

      protected void readSpecificDataRange(InputStream in, int naxis1, int naxis2, int nbyte) throws Exception
      Throws:
      Exception
    • readSpecificDataRange

      public void readSpecificDataRange(int nval, byte[] t, int mode) throws Exception
      Specified by:
      readSpecificDataRange in class Moc
      Throws:
      Exception
    • writeSpecificDataRange

      public int writeSpecificDataRange(OutputStream out, int mode) throws Exception
      Write Moc1D data in Ranges
      Specified by:
      writeSpecificDataRange in class Moc
      Parameters:
      out - output stream
      mode - RAW or COMP_SINGLETON
      Returns:
      number of bytes written
      Throws:
      Exception
    • writeASCII

      public void writeASCII(OutputStream out) throws Exception
      Write MOC to an output stream IN ASCII encoded format
      Specified by:
      writeASCII in class Moc
      Parameters:
      out - output stream
      Throws:
      Exception
    • writeJSON

      public void writeJSON(OutputStream out) throws Exception
      Write MOC to an output stream IN JSON encoded format
      Specified by:
      writeJSON in class Moc
      Parameters:
      out - output stream
      Throws:
      Exception
    • writeJSON

      protected int writeJSON(OutputStream out, boolean flagNL) throws Exception
      Write HEALPix MOC to an output stream IN JSON encoded format
      Parameters:
      out - output stream
      Throws:
      Exception