use of org.apache.carbondata.common.exceptions.sql.MalformedIndexCommandException in project carbondata by apache.
the class CarbonTable method getIndexedColumns.
/**
* Get all index columns specified by IndexSchema
*/
public List<CarbonColumn> getIndexedColumns(String[] columns) throws MalformedIndexCommandException {
List<CarbonColumn> indexColumn = new ArrayList<>(columns.length);
for (String column : columns) {
CarbonColumn carbonColumn = getColumnByName(column.trim().toLowerCase());
if (carbonColumn == null) {
throw new MalformedIndexCommandException(String.format("column '%s' does not exist in table. Please check create index statement.", column));
}
if (carbonColumn.getColName().isEmpty()) {
throw new MalformedIndexCommandException(CarbonCommonConstants.INDEX_COLUMNS + " contains invalid column name");
}
indexColumn.add(carbonColumn);
}
return indexColumn;
}
use of org.apache.carbondata.common.exceptions.sql.MalformedIndexCommandException in project carbondata by apache.
the class IndexRegistry method getIndexFactoryByShortName.
public static IndexFactory<? extends Index> getIndexFactoryByShortName(CarbonTable table, IndexSchema indexSchema) throws MalformedIndexCommandException {
String providerName = indexSchema.getProviderName();
try {
registerIndex(IndexType.get(providerName).getClassName(), IndexType.get(providerName).getIndexProviderName());
} catch (UnsupportedOperationException ex) {
throw new MalformedIndexCommandException("Index '" + providerName + "' not found", ex);
}
IndexFactory<? extends Index> indexFactory;
String className = getIndexClassName(providerName.toLowerCase());
if (className != null) {
try {
indexFactory = (IndexFactory<? extends Index>) Class.forName(className).getConstructors()[0].newInstance(table, indexSchema);
} catch (ClassNotFoundException ex) {
throw new MalformedIndexCommandException("Index '" + providerName + "' not found", ex);
} catch (InvocationTargetException ex) {
throw new MalformedIndexCommandException(ex.getTargetException().getMessage());
} catch (InstantiationException | IllegalAccessException | IllegalArgumentException ex) {
throw new MetadataProcessException("failed to create Index '" + providerName + "': " + ex.getMessage(), ex);
}
} else {
throw new MalformedIndexCommandException("Index '" + providerName + "' not found");
}
return indexFactory;
}
use of org.apache.carbondata.common.exceptions.sql.MalformedIndexCommandException in project carbondata by apache.
the class BloomCoarseGrainIndexFactory method validateAndGetBloomFilterSize.
/**
* validate Lucene Index BLOOM_SIZE
* 1. BLOOM_SIZE property is optional, 32000 * 20 will be the default size.
* 2. BLOOM_SIZE should be an integer that greater than 0
*/
private int validateAndGetBloomFilterSize(IndexSchema dmSchema) throws MalformedIndexCommandException {
String bloomFilterSizeStr = dmSchema.getProperties().get(BLOOM_SIZE);
if (StringUtils.isBlank(bloomFilterSizeStr)) {
LOGGER.warn(String.format("Bloom filter size is not configured for index %s, use default value %d", indexName, DEFAULT_BLOOM_FILTER_SIZE));
return DEFAULT_BLOOM_FILTER_SIZE;
}
int bloomFilterSize;
try {
bloomFilterSize = Integer.parseInt(bloomFilterSizeStr);
} catch (NumberFormatException e) {
throw new MalformedIndexCommandException(String.format("Invalid value of bloom filter size '%s', it should be an integer", bloomFilterSizeStr));
}
// todo: reconsider the boundaries of bloom filter size
if (bloomFilterSize <= 0) {
throw new MalformedIndexCommandException(String.format("Invalid value of bloom filter size '%s', it should be greater than 0", bloomFilterSizeStr));
}
return bloomFilterSize;
}
use of org.apache.carbondata.common.exceptions.sql.MalformedIndexCommandException in project carbondata by apache.
the class BloomCoarseGrainIndexFactory method validateAndGetBloomFilterFpp.
/**
* validate bloom Index BLOOM_FPP
* 1. BLOOM_FPP property is optional, 0.00001 will be the default value.
* 2. BLOOM_FPP should be (0, 1)
*/
private double validateAndGetBloomFilterFpp(IndexSchema dmSchema) throws MalformedIndexCommandException {
String bloomFilterFppStr = dmSchema.getProperties().get(BLOOM_FPP);
if (StringUtils.isBlank(bloomFilterFppStr)) {
LOGGER.warn(String.format("Bloom filter FPP is not configured for index %s, use default value %f", indexName, DEFAULT_BLOOM_FILTER_FPP));
return DEFAULT_BLOOM_FILTER_FPP;
}
double bloomFilterFpp;
try {
bloomFilterFpp = Double.parseDouble(bloomFilterFppStr);
} catch (NumberFormatException e) {
throw new MalformedIndexCommandException(String.format("Invalid value of bloom filter fpp '%s', it should be an numeric", bloomFilterFppStr));
}
if (bloomFilterFpp < 0 || bloomFilterFpp - 1 >= 0) {
throw new MalformedIndexCommandException(String.format("Invalid value of bloom filter fpp '%s', it should be in range 0~1", bloomFilterFppStr));
}
return bloomFilterFpp;
}
Aggregations