Search in sources :

Example 1 with InvalidConfigurationException

use of org.apache.carbondata.core.exception.InvalidConfigurationException in project carbondata by apache.

the class CarbonUtil method validateRangeOfSegmentList.

public static boolean validateRangeOfSegmentList(String segmentId) throws InvalidConfigurationException {
    String[] values = segmentId.split(",");
    try {
        if (values.length == 0) {
            throw new InvalidConfigurationException("carbon.input.segments.<database_name>.<table_name> value can't be empty.");
        }
        for (String value : values) {
            if (!value.equalsIgnoreCase("*")) {
                Segment segment = Segment.toSegment(value, null);
                float aFloatValue = Float.parseFloat(segment.getSegmentNo());
                if (aFloatValue < 0 || aFloatValue > Float.MAX_VALUE) {
                    throw new InvalidConfigurationException("carbon.input.segments.<database_name>.<table_name> value range should be greater " + "than 0 and less than " + Float.MAX_VALUE);
                }
            }
        }
    } catch (NumberFormatException nfe) {
        throw new InvalidConfigurationException("carbon.input.segments.<database_name>.<table_name> value range is not valid");
    }
    return true;
}
Also used : Segment(org.apache.carbondata.core.index.Segment) InvalidConfigurationException(org.apache.carbondata.core.exception.InvalidConfigurationException)

Example 2 with InvalidConfigurationException

use of org.apache.carbondata.core.exception.InvalidConfigurationException in project carbondata by apache.

the class SessionParams method validateKeyValue.

/**
 * validate the key value to be set using set command
 * @param key
 * @param value
 * @return
 * @throws InvalidConfigurationException
 */
private boolean validateKeyValue(String key, String value) throws InvalidConfigurationException {
    boolean isValid = false;
    switch(key) {
        case ENABLE_SI_LOOKUP_PARTIALSTRING:
        case ENABLE_UNSAFE_SORT:
        case ENABLE_OFFHEAP_SORT:
        case CARBON_CUSTOM_BLOCK_DISTRIBUTION:
        case CARBON_OPTIONS_BAD_RECORDS_LOGGER_ENABLE:
        case CARBON_OPTIONS_IS_EMPTY_DATA_BAD_RECORD:
        case ENABLE_VECTOR_READER:
        case ENABLE_UNSAFE_IN_QUERY_EXECUTION:
        case ENABLE_AUTO_LOAD_MERGE:
        case CARBON_PUSH_ROW_FILTERS_FOR_VECTOR:
        case CARBON_LOAD_DATEFORMAT_SETLENIENT_ENABLE:
        case CARBON_LOAD_SI_REPAIR:
        case CARBON_ENABLE_INDEX_SERVER:
        case CARBON_QUERY_STAGE_INPUT:
        case CARBON_ENABLE_MV:
        case CARBON_COARSE_GRAIN_SECONDARY_INDEX:
            isValid = CarbonUtil.validateBoolean(value);
            if (!isValid) {
                throw new InvalidConfigurationException("Invalid value " + value + " for key " + key);
            }
            break;
        case CARBON_OPTIONS_BAD_RECORDS_ACTION:
            try {
                LoggerAction.valueOf(value.toUpperCase());
                isValid = true;
            } catch (IllegalArgumentException iae) {
                throw new InvalidConfigurationException("The key " + key + " can have only either FORCE or IGNORE or REDIRECT or FAIL.");
            }
            break;
        case CARBON_OPTIONS_SORT_SCOPE:
            isValid = CarbonUtil.isValidSortOption(value);
            if (!isValid) {
                throw new InvalidConfigurationException("The sort scope " + key + " can have only either NO_SORT, LOCAL_SORT or GLOBAL_SORT.");
            }
            break;
        case CARBON_OPTIONS_GLOBAL_SORT_PARTITIONS:
        case NUM_CORES_LOADING:
        case CARBON_SI_REPAIR_LIMIT:
        case NUM_CORES_COMPACTING:
        case BLOCKLET_SIZE_IN_MB:
        case CARBON_MAJOR_COMPACTION_SIZE:
        case CARBON_MINOR_COMPACTION_SIZE:
            isValid = CarbonUtil.validateValidIntType(value);
            if (!isValid) {
                throw new InvalidConfigurationException("The configured value for key " + key + " must be valid integer.");
            }
            break;
        case CARBON_OPTIONS_BAD_RECORD_PATH:
            isValid = CarbonUtil.isValidBadStorePath(value);
            if (!isValid) {
                throw new InvalidConfigurationException("Invalid bad records location.");
            }
            break;
        // no validation needed while set for CARBON_OPTIONS_SERIALIZATION_NULL_FORMAT
        case CARBON_OPTIONS_DATEFORMAT:
        case CARBON_OPTIONS_TIMESTAMPFORMAT:
        case CARBON_OPTIONS_SERIALIZATION_NULL_FORMAT:
            isValid = true;
            break;
        case COMPACTION_SEGMENT_LEVEL_THRESHOLD:
            int[] values = CarbonProperties.getInstance().getIntArray(value);
            if (values.length != 2) {
                throw new InvalidConfigurationException("Invalid COMPACTION_SEGMENT_LEVEL_THRESHOLD: " + value);
            }
            isValid = true;
            break;
        default:
            if (key.startsWith(CARBON_ENABLE_INDEX_SERVER) && key.split("\\.").length == 6) {
                isValid = true;
            } else if (key.startsWith(CARBON_SI_REPAIR_LIMIT)) {
                isValid = CarbonUtil.validateValidIntType(value);
                if (!isValid) {
                    throw new InvalidConfigurationException("Invalid CARBON_SI_REPAIR_LIMIT");
                }
            } else if (key.startsWith(CARBON_LOAD_SI_REPAIR) && key.split("\\.").length == 6) {
                isValid = true;
            } else if (key.startsWith(CarbonCommonConstants.CARBON_INPUT_SEGMENTS)) {
                isValid = CarbonUtil.validateRangeOfSegmentList(value);
                if (!isValid) {
                    throw new InvalidConfigurationException("Invalid CARBON_INPUT_SEGMENT_IDs");
                }
            } else if (key.startsWith(CarbonCommonConstants.CARBON_INDEX_VISIBLE)) {
                isValid = true;
            } else if (key.startsWith(CarbonCommonConstants.CARBON_LOAD_INDEXES_PARALLEL) || (key.startsWith(CARBON_COARSE_GRAIN_SECONDARY_INDEX) && key.split("\\.").length == 7)) {
                // validate the value field when property key is with database name and table name.
                // Like, carbon.coarse.grain.secondary.index.<dbname>.<tablename>
                isValid = CarbonUtil.validateBoolean(value);
                if (!isValid) {
                    throw new InvalidConfigurationException("Invalid value " + value + " for key " + key);
                }
            } else if (key.startsWith(CarbonLoadOptionConstants.CARBON_TABLE_LOAD_SORT_SCOPE)) {
                isValid = CarbonUtil.isValidSortOption(value);
                if (!isValid) {
                    throw new InvalidConfigurationException("The sort scope " + key + " can have only either NO_SORT, LOCAL_SORT or GLOBAL_SORT.");
                }
            } else if (key.equalsIgnoreCase(CARBON_REORDER_FILTER)) {
                isValid = true;
            } else if (key.startsWith(CARBON_MAP_ORDER_PUSHDOWN)) {
                isValid = true;
            } else {
                throw new InvalidConfigurationException("The key " + key + " not supported for dynamic configuration.");
            }
    }
    return isValid;
}
Also used : InvalidConfigurationException(org.apache.carbondata.core.exception.InvalidConfigurationException)

Example 3 with InvalidConfigurationException

use of org.apache.carbondata.core.exception.InvalidConfigurationException in project carbondata by apache.

the class MapredCarbonInputFormat method getRecordReader.

@Override
public RecordReader<Void, ArrayWritable> getRecordReader(InputSplit inputSplit, JobConf jobConf, Reporter reporter) throws IOException {
    String path = null;
    if (inputSplit instanceof CarbonHiveInputSplit) {
        path = ((CarbonHiveInputSplit) inputSplit).getPath().toString();
    }
    QueryModel queryModel;
    try {
        jobConf.set(DATABASE_NAME, "_dummyDb_" + UUID.randomUUID().toString());
        jobConf.set(TABLE_NAME, "_dummyTable_" + UUID.randomUUID().toString());
        queryModel = getQueryModel(jobConf, path);
    } catch (InvalidConfigurationException | SQLException e) {
        LOGGER.error("Failed to create record reader: " + e.getMessage(), e);
        return null;
    }
    CarbonReadSupport<ArrayWritable> readSupport = new WritableReadSupport<>();
    return new CarbonHiveRecordReader(queryModel, readSupport, inputSplit, jobConf);
}
Also used : ArrayWritable(org.apache.hadoop.io.ArrayWritable) SQLException(java.sql.SQLException) QueryModel(org.apache.carbondata.core.scan.model.QueryModel) InvalidConfigurationException(org.apache.carbondata.core.exception.InvalidConfigurationException)

Aggregations

InvalidConfigurationException (org.apache.carbondata.core.exception.InvalidConfigurationException)3 SQLException (java.sql.SQLException)1 Segment (org.apache.carbondata.core.index.Segment)1 QueryModel (org.apache.carbondata.core.scan.model.QueryModel)1 ArrayWritable (org.apache.hadoop.io.ArrayWritable)1