summaryrefslogtreecommitdiffstats
path: root/java/src/rasj/RasStorageLayout.java
blob: ab1feae426c80950215f598a4b5a3ccea9317076 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
package rasj;

/*
* This file is part of rasdaman community.
*
* Rasdaman community is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Rasdaman community is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with rasdaman community.  If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann /
rasdaman GmbH.
*
* For more information please see <http://www.rasdaman.org>
* or contact Peter Baumann via <baumann@rasdaman.com>.
*/
/** ***********************************************************
 * <pre>
 *
 * PURPOSE: 
 * This class is used to express the storage options for MDD objects.
 * In the current version, either the tile-size (for example 256000 bytes) or the 
 * tiling-domain (for example "[0:127,0:511]") can be specified. If 
 * neither is done, the default tile-size will be 128 kBytes.
 *
 * @version $Revision: 1.10 $
 *
 *
 *
 * COMMENTS:
 *
 * </pre>
 *********************************************************** */


public class RasStorageLayout
   
{
    static final String rcsid = "@(#)Package rasj.odmg, class RasStorageLayout: $Header: /home/rasdev/CVS-repository/rasdaman/java/rasj/RasStorageLayout.java,v 1.10 2003/12/10 21:04:23 rasdev Exp $";

    /**
     * Default tile size in kBytes. This value is currently set
     * to 128000 and is used if the user has not specified
     * a tile size explicitly.
     **/
    static final int DEFAULT_TILE_SIZE = 128000;

    /**
     * the spatial domain of the current storageLayout
     **/
    private RasMInterval spatialDomain;

    /**
     * the current tile size in bytes
     **/
    private int tileSize;
   
    /**
     * Default constructor.
     **/
    public RasStorageLayout()
    {
	spatialDomain = null;
	tileSize = DEFAULT_TILE_SIZE;
    }   

    /**
     * Copy constructor taking another storage layout object as a parameter.
     * @param stl the sorage layout object to be copied
     **/
    public RasStorageLayout(RasStorageLayout stl)
    {
	spatialDomain = stl.getSpatialDomain();
	tileSize = stl.getTileSize();
    }

    /**
     * Returns the current tiling-domain of this storage layout object.
     * @return the tiling-domain of this storage layout object
     **/
    public final RasMInterval getSpatialDomain()
    {
	return spatialDomain;
    }

    /**
     * Sets the tile-size (in bytes) and resets the tiling-domain to null.
     * @param size the tile-size (in bytes)
     **/
    public void setTileSize(int size)
    {
	tileSize = size;
	spatialDomain = null;
    }

    /**
     * Returns the current tile-size (in bytes).
     * @return the tile-size
     **/
    public final int getTileSize()
    {
	return tileSize;
    }

    /**
     * Sets the tiling-domain for this storage layout object and resets the tile-size
     * to null.
     * @param domain the tiling-domain
     **/
    public void setTileDomain(String domain) 
	throws RasResultIsNoIntervalException, RasStreamInputOverflowException, RasIndexOutOfBoundsException
    {
	spatialDomain = new RasMInterval(domain);
	tileSize = 0;
    }

    /**
     * This method tests if the current storageLayout object is compatible to a given domain.
     * @param domain the domain to be compared 
     * @return true if the tiling-domain of this storage layout object is either null or 
     * has the same number of dimensions as the given domain, otherwise false 
     **/
    public boolean isCompatible(RasMInterval domain)
    {
	if(spatialDomain == null)
	    return true;
        else
	    return (domain.dimension() == spatialDomain.dimension());

    }

    /**
     * Returns a string representation of this class.
     **/
    public String toString()
    {
	if(spatialDomain != null)
	    return "\nTileDomain: " + spatialDomain + "\n";
        else
	    return "\nTileSize: " + tileSize + "\n";

    }
    
    
}