Package cds.moc
Class Moc1D
java.lang.Object
cds.moc.Moc
cds.moc.Moc1D
- All Implemented Interfaces:
Cloneable
,Comparable<Moc>
,Iterable<MocCell>
The Moc1D class implements the methods specific to one-dimensional MOCs (e.g. SPACE or TIME).
-
Field Summary
FieldsFields inherited from class cds.moc.Moc
ASCII, cacheDeepestOrder, cacheHashCode, cacheNbCells, comment, COMPRESS_SINGLETON, CR, FITS, JSON, LOGIC_MAX, LOGIC_MIN, MASK_COMP, MAXSIZE, MAXWORD, property, RAW, unites, UNMASK_COMP, VERSION
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Moc1D()
Generic Moc 1D creatorprotected
Moc1D
(int mocOrder) Generic Moc 1D creatorprotected
Generic Moc 1D generator from another Moc 1Dprotected
Moc1D
(InputStream in) Generic Moc 1D generator from input streamprotected
Generic Moc 1D generator from ASCII Moc String -
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(int order, long val) Add one cell to the Moc.void
add
(int order, long firstVal, long lastVal) Add a list of consecutive Moc cells.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).void
Add directly a Mocprotected void
Internal usage: Add one token element according to the format "[s|t]order/npix[-npixn]".void
Stops the buffering and frees the memory required for it.void
bufferOn()
Activation of the buffererization.void
bufferOn
(int size) Activation of the buffererization.int
buffer size, not yet proceedabstract char
cDim()
Return the Moc signature character (ex: 's' for SMoc, 't' for TMoc)cellIterator
(boolean flagRange) Provide an Iterator on the MOC cell List (hierarchical view)void
clear()
Clear the MOC - data only (not the properties, nor the mocOrder)protected void
Deep copy.Return the complementprotected void
Recalculates the metrics associated with the MOC hierarchical view: the number of hierarchical cells, the deepest order used...protected void
createMocByUniq
(int nval, int nbyte, byte[] t) protected void
createMocByUniqUnsorted
(int nval, int nbyte, byte[] t, boolean protoTMoc) boolean
Return true in case of equality (only check data - no properties, nor MocOrder)void
flush()
Inserts in the MOC all the elements being inserted in the buffer.double
Return the coverage pourcentage of the Moclong
getEnd
(int order, long val) Returns the value of the end of the interval (excluded) expressed at the maximum orderlong
getMem()
Return approximatively the amount of memory used for storing this MOC in RAM (in bytes)int
get min Moc min Order.int
Return the Moc order.int
Return the number of rangeslong
Return the number of used cells at the Moc order: (ex: s2/1 3/5-6 => 6long
getStart
(int order, long val) Returns the value of the beginning of the interval expressed at the maximum ordergetSys()
Get the reference system.int
hashCode()
boolean
isCompatible
(Moc moc) Return true if the moc is compatible for operation (same class and sys)boolean
isEmpty()
Return true if the Moc is empty (no coverage)boolean
isFull()
Return true if the Moc is full (full coverage)boolean
isIncluding
(int order, long val) boolean
isIntersecting
(int order, long val) protected String
lowAscii
(int n) Display the n first ranges at the max orderabstract int
maxOrder()
Return the deepest possible order (ex: 29 for SMoc, 61 for TMoc)abstract long
maxVal()
Return the number of values at the deepest order (ex: 2x2^29x2^29 for SMoc, 2^61 for TMoc)protected Moc1D
Generic operations: 0-union, 1-intersection, 2-subtractionvoid
readSpecificDataRange
(int nval, byte[] t, int mode) protected void
readSpecificDataRange
(InputStream in, int naxis1, int naxis2, int nbyte) protected void
readSpecificDataUniq
(InputStream in, int naxis1, int naxis2, int nbyte) Readersboolean
reduction
(long maxSize) Degrades the resolution(s) of the MOC until the RAM size of the MOC is reduced under the specified maximum (expressed in bytes).Acces to the list of ranges (no copy)void
setMinOrder
(int minOrder) Set min Moc min Order.void
setMocOrder
(int mocOrder) Set Moc order.void
setRangeList
(Range range) Set the list of ranges - Warning: no copyvoid
Set alternative reference System.abstract int
Return the number of bit shifting between two consecutive orders (ex: 2 for SMoc, 1 for TMoc)abstract String
sys()
Return the default reference systemtoDebug()
Return an Iterator providing the list of values at the Moc order.void
writeASCII
(OutputStream out) Write MOC to an output stream IN ASCII encoded formatvoid
writeJSON
(OutputStream out) Write MOC to an output stream IN JSON encoded formatprotected int
writeJSON
(OutputStream out, boolean flagNL) Write HEALPix MOC to an output stream IN JSON encoded formatint
writeSpecificDataRange
(OutputStream out, int mode) Write Moc1D data in RangesMethods inherited from class cds.moc.Moc
accretion, add, clone, codeComp, compareTo, compressRange, createMoc, createMoc, decodeComp, difference, dup, getBourrage, getComment, getDeepestOrder, getFitsLine, getFitsLine, getMocOrder4op, getMocOrderLogic, getNbCells, getNbCoding, getProperty, getPropertyKeys, getSpaceMoc, getSpaceOrder, getSpaceSys, getSpaceTimeMoc, getTimeMoc, getTimeOrder, getTimeSys, getUnitDisk, getUnitDisk, hpix2uniq, intersection, isCodedComp, isIncluding, isIntersecting, isSpace, isTime, iterator, json2ASCII, log2, pow2, read, read, read, readASCII, readFITS, readFully, readFully, readJSON, readLong, readSpecificData, resetCache, setMocOrderLogic, setProperty, setProperty, setSpaceOrder, setSpaceSys, setTimeOrder, setTimeSys, sizeOfCoding, subtraction, toASCII, toJSON, toString, uncompressRange, uncompressRange, union, uniq2hpix, uniq2hpix, write, write, write, write, writeASCII, writeASCII, writeASCIIFlush, writeData, writeFITS, writeFITS, writeJSON, writeSpecificData, writeSpecificFitsProp, writeVal
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
range
-
mocOrder
protected int mocOrder -
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
Generic Moc 1D generator from ASCII Moc String- Parameters:
s
- ASCII Moc (regular ASCII or JSON)- Throws:
Exception
-
Moc1D
Generic Moc 1D generator from input stream- Parameters:
in
- input stream- Throws:
Exception
-
Moc1D
Generic Moc 1D generator from another Moc 1D- Parameters:
moc
- moc to be dumped- Throws:
Exception
-
-
Method Details
-
toDebug
-
lowAscii
Display the n first ranges at the max order -
clear
public void clear()Clear the MOC - data only (not the properties, nor the mocOrder) -
clone1
Deep copy. The source is this, the target is the Moc in parameter- Overrides:
clone1
in classMoc
- Throws:
CloneNotSupportedException
-
reduction
Degrades the resolution(s) of the MOC until the RAM size of the MOC is reduced under the specified maximum (expressed in bytes). -
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
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 classMoc
-
getNbValues
public long getNbValues()Return the number of used cells at the Moc order: (ex: s2/1 3/5-6 => 6 -
setRangeList
Set the list of ranges - Warning: no copy- Specified by:
setRangeList
in classMoc
-
isEmpty
public boolean isEmpty()Return true if the Moc is empty (no coverage) -
isFull
public boolean isFull()Return true if the Moc is full (full coverage) -
getCoverage
public double getCoverage()Return the coverage pourcentage of the Moc- Specified by:
getCoverage
in classMoc
-
getNbRanges
public int getNbRanges()Return the number of ranges- Specified by:
getNbRanges
in classMoc
-
getMem
public long getMem()Return approximatively the amount of memory used for storing this MOC in RAM (in bytes) -
isCompatible
Return true if the moc is compatible for operation (same class and sys)- Specified by:
isCompatible
in classMoc
-
operation
Generic operations: 0-union, 1-intersection, 2-subtraction -
complement
Return the complement- Specified by:
complement
in classMoc
- Throws:
Exception
-
equals
Return true in case of equality (only check data - no properties, nor MocOrder) -
hashCode
public int hashCode() -
isIncluding
public boolean isIncluding(int order, long val) -
isIntersecting
public boolean isIntersecting(int order, long val) -
setMocOrder
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
Set alternative reference System.- Parameters:
sys
- alternative reference frame keyword (not standardized in IVOA document)
-
getSys
Get the reference system. See setSys() -
setMinOrder
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
Add one cell to the Moc.- Parameters:
order
- Order of the cellval
- Value of the cell- Throws:
Exception
-
add
Add a list of consecutive Moc cells.- Parameters:
order
- Order of the cellsfirstVal
- First valuelastVal
- 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()) -
bufferSize
public int bufferSize()buffer size, not yet proceed- Overrides:
bufferSize
in classMoc
-
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 indexsize
- Number of values (= 2x number of ranges)
-
add
Add directly a Moc- Throws:
Exception
-
seeRangeList
Acces to the list of ranges (no copy)- Specified by:
seeRangeList
in classMoc
-
cellIterator
Provide an Iterator on the MOC cell List (hierarchical view)- Specified by:
cellIterator
in classMoc
- Parameters:
flagRange
- true for getting range rather than all individual values- Returns:
- mocCell => dim,order,startVal,endVal
-
valIterator
Return an Iterator providing the list of values at the Moc order. => values provided in ascending order -
addToken
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 -
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
- Throws:
Exception
-
readSpecificDataRange
protected void readSpecificDataRange(InputStream in, int naxis1, int naxis2, int nbyte) throws Exception - Throws:
Exception
-
readSpecificDataRange
- Specified by:
readSpecificDataRange
in classMoc
- Throws:
Exception
-
writeSpecificDataRange
Write Moc1D data in Ranges- Specified by:
writeSpecificDataRange
in classMoc
- Parameters:
out
- output streammode
- RAW or COMP_SINGLETON- Returns:
- number of bytes written
- Throws:
Exception
-
writeASCII
Write MOC to an output stream IN ASCII encoded format- Specified by:
writeASCII
in classMoc
- Parameters:
out
- output stream- Throws:
Exception
-
writeJSON
Write MOC to an output stream IN JSON encoded format -
writeJSON
Write HEALPix MOC to an output stream IN JSON encoded format- Parameters:
out
- output stream- Throws:
Exception
-