Search in sources :

Example 1 with StructuredTableInstantiationException

use of io.cdap.cdap.spi.data.StructuredTableInstantiationException in project cdap by caskdata.

the class NoSqlStructuredTableContext method getTable.

@Override
public StructuredTable getTable(StructuredTableId tableId) throws StructuredTableInstantiationException, TableNotFoundException {
    try {
        StructuredTableSchema schema = tableAdmin.getSchema(tableId);
        Map<String, String> arguments = new HashMap<>();
        if (schema.getIndexes().isEmpty()) {
            // No indexes on the table
            arguments.put(IndexedTable.INDEX_COLUMNS_CONF_KEY, "");
            arguments.put(IndexedTable.DYNAMIC_INDEXING_PREFIX, "");
        } else {
            arguments.put(IndexedTable.INDEX_COLUMNS_CONF_KEY, Joiner.on(",").join(schema.getIndexes()));
            arguments.put(IndexedTable.DYNAMIC_INDEXING_PREFIX, tableId.getName());
        }
        StructuredTable table = new NoSqlStructuredTable(datasetContext.getDataset(NoSqlStructuredTableAdmin.ENTITY_TABLE_NAME, arguments), schema);
        return new MetricStructuredTable(tableId, table, metricsCollector, emitTimeMetrics);
    } catch (DatasetInstantiationException e) {
        throw new StructuredTableInstantiationException(tableId, String.format("Error instantiating table %s", tableId), e);
    }
}
Also used : StructuredTableSchema(io.cdap.cdap.spi.data.table.StructuredTableSchema) StructuredTableInstantiationException(io.cdap.cdap.spi.data.StructuredTableInstantiationException) HashMap(java.util.HashMap) MetricStructuredTable(io.cdap.cdap.spi.data.common.MetricStructuredTable) StructuredTable(io.cdap.cdap.spi.data.StructuredTable) DatasetInstantiationException(io.cdap.cdap.api.data.DatasetInstantiationException) MetricStructuredTable(io.cdap.cdap.spi.data.common.MetricStructuredTable)

Aggregations

DatasetInstantiationException (io.cdap.cdap.api.data.DatasetInstantiationException)1 StructuredTable (io.cdap.cdap.spi.data.StructuredTable)1 StructuredTableInstantiationException (io.cdap.cdap.spi.data.StructuredTableInstantiationException)1 MetricStructuredTable (io.cdap.cdap.spi.data.common.MetricStructuredTable)1 StructuredTableSchema (io.cdap.cdap.spi.data.table.StructuredTableSchema)1 HashMap (java.util.HashMap)1