Changeset b6a2369


Ignore:
Timestamp:
Aug 31, 2017 3:44:55 PM (3 weeks ago)
Author:
www-data <www-data@…>
Branches:
master
Children:
eefd714
Parents:
1905f2d
git-author:
Bang Pham Huu <b.phamhuu@…> (08/31/17 12:35:13)
git-committer:
www-data <www-data@…> (08/31/17 15:44:55)
Message:

ticket:1029 - WCST_Import uses more meaningful type names when creating cell/array/set instead of random name

Summary:
WCST_Import creates cell/array/set of rasdaman collection with random name.
This makes it very hard to manage from user's perspective. It will change to use the collection name as prefix and add _Cell/Array_Set accordingly.
Example: CREATE TYPE test_irr_cube_2_Cell AS ( band0 float ,band1 float )

CREATE TYPE test_irr_cube_2_Array AS test_irr_cube_2_Cell MDARRAY [dim0,dim1,dim2]
CREATE TYPE test_irr_cube_2_Set AS SET (test_irr_cube_2_Array )

Test Plan: Run test system

Reviewers: dmisev

Differential Revision: http://codereview.rasdaman.org/D461

Location:
applications/petascope
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • applications/petascope/petascope_core/src/main/java/petascope/util/ras/TypeRegistry.java

    r901a413 rb6a2369  
    8787        String output = "";
    8888        int count = 0;
    89         for (String i : bandBaseTypes) {
    90             output += getRandomTypeName() + " " + i + " ";
     89        for (String bandBaseType : bandBaseTypes) {
     90            output += ("band" + count) + " " + bandBaseType + " ";
    9191            if (count < bandBaseTypes.size() - 1) {
    9292                output += ",";
     
    134134    }
    135135
    136     public String createNewType(Integer numberOfDimensions, List<String> bandBaseTypes, List<NilValue> nullValues) throws PetascopeException {
     136    public String createNewType(String collectionName, Integer numberOfDimensions, List<String> bandBaseTypes, List<NilValue> nullValues) throws PetascopeException {
    137137        log.info("Creating new type.");
    138         String marrayName = getRandomTypeName();
    139         String setName = getRandomTypeName();
     138        String cellName = collectionName + "_Cell";
     139        String marrayName = collectionName + "_Array";
     140        String setName = collectionName + "_Set";
     141       
    140142        if (bandBaseTypes.size() == 1) {
    141143            //simple types
     
    147149        } else {
    148150            //struct types
    149             String structName = getRandomTypeName();
    150             String queryStruct = QUERY_CREATE_STRUCT_TYPE.replace("$structTypeName", structName)
     151            String queryStruct = QUERY_CREATE_STRUCT_TYPE.replace("$structTypeName", cellName)
    151152                                 .replace("$structStructure", generateStructStructure(bandBaseTypes));
    152153            //create the struct type
     
    154155            //marray type
    155156            String queryMarray = QUERY_CREATE_MARRAY_TYPE.replace("$typeName", marrayName)
    156                                  .replace("$typeStructure", structName)
     157                                 .replace("$typeStructure", cellName)
    157158                                 .replace("$dimensions", expandDimensions(numberOfDimensions));
    158159            //create it
     
    184185        return mddType;
    185186    }
    186 
    187     /**
    188      * Generates a random alphabetic string
    189      *
    190      * @return
    191      */
    192     private static String getRandomTypeName() {
    193         return RandomStringUtils.randomAlphabetic(GENERATED_TYPE_NAME_LENGTH);
    194     }
    195 
     187   
    196188    /**
    197189     * Collects the types from rasdl and inserts them into an internal registry
  • applications/petascope/petascope_core/src/main/java/petascope/util/ras/TypeResolverUtil.java

    r901a413 rb6a2369  
    4242     * Guesses the rasdaman collection type from a file.
    4343     *
     44     * @param collectionName
    4445     * @param filePath path to the file
    4546     * @param dimension
     
    4849     * @throws IOException
    4950     */
    50     public static String guessCollectionTypeFromFile(String filePath, int dimension, List<NilValue> nullValues) throws IOException, PetascopeException {
     51    public static String guessCollectionTypeFromFile(String collectionName, String filePath, int dimension, List<NilValue> nullValues) throws IOException, PetascopeException {
    5152        Pair<Integer, ArrayList<String>> dimTypes = Gdalinfo.getDimensionAndTypes(filePath);
    5253       
    53         return guessCollectionType(dimension, dimTypes.snd, nullValues);
     54        return guessCollectionType(collectionName, dimension, dimTypes.snd, nullValues);
    5455    }
    5556
     
    5859     * band type char.
    5960     *
     61     * @param collectionName     name of creating collection (coverage Id)
    6062     * @param numberOfBands      how many band the dataset has
    6163     * @param numberOfDimensions how many dimensions the dataset has
     
    6466     * @return pair containing the collection type and cell type (e.g. <"GreySet", "c">)
    6567     */
    66     public static Pair<String, String> guessCollectionType(Integer numberOfBands, Integer numberOfDimensions, List<NilValue> nullValues, String pixelDataType) throws PetascopeException {
     68    public static Pair<String, String> guessCollectionType(String collectionName, Integer numberOfBands, Integer numberOfDimensions, List<NilValue> nullValues, String pixelDataType) throws PetascopeException {
    6769        if (pixelDataType == null) {
    6870            pixelDataType = GDT_Float32;
     
    7678            bandTypes.add(pixelDataType);
    7779        }
    78         return Pair.of(guessCollectionType(numberOfDimensions, bandTypes, nullValues), RAS_TYPES_TO_ABBREVIATION.get(GDAL_TYPES_TO_RAS_TYPES.get(pixelDataType)));
     80        return Pair.of(guessCollectionType(collectionName, numberOfDimensions, bandTypes, nullValues), RAS_TYPES_TO_ABBREVIATION.get(GDAL_TYPES_TO_RAS_TYPES.get(pixelDataType)));
    7981    }
    8082
     
    100102     * @return
    101103     */
    102     private static String guessCollectionType(Integer numberOfDimensions, ArrayList<String> gdalBandTypes, List<NilValue> nullValues) throws PetascopeException {
     104    private static String guessCollectionType(String collectionName, Integer numberOfDimensions, ArrayList<String> gdalBandTypes, List<NilValue> nullValues) throws PetascopeException {
    103105        String result = "";
    104106
     
    153155        }
    154156        //nothing has been found, so the type must be created
    155         result = typeRegistry.createNewType(numberOfDimensions, translateTypes(gdalBandTypes), nullValues);
     157        result = typeRegistry.createNewType(collectionName, numberOfDimensions, translateTypes(gdalBandTypes), nullValues);
    156158        return result;
    157159    }
  • applications/petascope/petascope_main/src/main/java/petascope/wcst/handlers/InsertCoverageHandler.java

    r901a413 rb6a2369  
    184184                long start = System.currentTimeMillis();
    185185                Pair<String, String> collectionType
    186                         = TypeResolverUtil.guessCollectionType(numberOfBands, numberOfDimensions, nullValues, pixelDataType);
     186                        = TypeResolverUtil.guessCollectionType(collectionName, numberOfBands, numberOfDimensions, nullValues, pixelDataType);
    187187                rasCollectionType = collectionType.fst;
    188188                long end = System.currentTimeMillis();
     
    228228                //pass it to gdal to get the collection type
    229229                if (pixelDataType != null) {
    230                     rasCollectionType = TypeResolverUtil.guessCollectionType(numberOfBands, numberOfDimensions, nullValues, pixelDataType).fst;
     230                    rasCollectionType = TypeResolverUtil.guessCollectionType(collectionName, numberOfBands, numberOfDimensions, nullValues, pixelDataType).fst;
    231231                } else {
    232232                    //read it from file
    233                     rasCollectionType = TypeResolverUtil.guessCollectionTypeFromFile(tmpFile.getAbsolutePath(), numberOfDimensions, nullValues);
     233                    rasCollectionType = TypeResolverUtil.guessCollectionTypeFromFile(collectionName, tmpFile.getAbsolutePath(), numberOfDimensions, nullValues);
    234234                }
    235235                //insert it into rasdaman
  • applications/petascope/petascope_main/src/main/java/petascope/wcst/handlers/UpdateCoverageHandler.java

    r41fb734 rb6a2369  
    636636    private String getReplacementValuesFromTupleList(Coverage coverage, Element rangeSet, String pixelDataType) throws PetascopeException {
    637637        Element dataBlock = GMLParserService.parseDataBlock(rangeSet);
    638         Pair<String, String> collectionType = TypeResolverUtil.guessCollectionType(coverage.getNumberOfBands(), coverage.getNumberOfDimensions(),
     638        String collectionName = coverage.getCoverageId().replace("-", "_");
     639        Pair<String, String> collectionType = TypeResolverUtil.guessCollectionType(collectionName, coverage.getNumberOfBands(), coverage.getNumberOfDimensions(),
    639640                coverage.getAllUniqueNullValues(), pixelDataType);
    640641
Note: See TracChangeset for help on using the changeset viewer.