Search in sources :

Example 16 with DBSIndexType

use of org.jkiss.dbeaver.model.struct.rdb.DBSIndexType in project dbeaver by serge-rider.

the class IndexCache method fetchObject.

@Nullable
@Override
protected GenericTableIndex fetchObject(JDBCSession session, GenericStructContainer owner, GenericTable parent, String indexName, JDBCResultSet dbResult) throws SQLException, DBException {
    boolean isNonUnique = GenericUtils.safeGetBoolean(indexObject, dbResult, JDBCConstants.NON_UNIQUE);
    String indexQualifier = GenericUtils.safeGetStringTrimmed(indexObject, dbResult, JDBCConstants.INDEX_QUALIFIER);
    long cardinality = GenericUtils.safeGetLong(indexObject, dbResult, JDBCConstants.INDEX_CARDINALITY);
    int indexTypeNum = GenericUtils.safeGetInt(indexObject, dbResult, JDBCConstants.TYPE);
    DBSIndexType indexType;
    switch(indexTypeNum) {
        case DatabaseMetaData.tableIndexStatistic:
            // Table index statistic. Not a real index.
            log.debug("Skip statistics index '" + indexName + "' in '" + DBUtils.getObjectFullName(parent, DBPEvaluationContext.DDL) + "'");
            return null;
        // indexType = DBSIndexType.STATISTIC; break;
        case DatabaseMetaData.tableIndexClustered:
            indexType = DBSIndexType.CLUSTERED;
            break;
        case DatabaseMetaData.tableIndexHashed:
            indexType = DBSIndexType.HASHED;
            break;
        case DatabaseMetaData.tableIndexOther:
            indexType = DBSIndexType.OTHER;
            break;
        default:
            indexType = DBSIndexType.UNKNOWN;
            break;
    }
    if (CommonUtils.isEmpty(indexName)) {
        // [JDBC] Some drivers return empty index names
        indexName = parent.getName().toUpperCase(Locale.ENGLISH) + "_INDEX";
    }
    return owner.getDataSource().getMetaModel().createIndexImpl(parent, isNonUnique, indexQualifier, cardinality, indexName, indexType, true);
}
Also used : DBSIndexType(org.jkiss.dbeaver.model.struct.rdb.DBSIndexType) Nullable(org.jkiss.code.Nullable)

Aggregations

DBSIndexType (org.jkiss.dbeaver.model.struct.rdb.DBSIndexType)16 Nullable (org.jkiss.code.Nullable)4 GenericTableIndexColumn (org.jkiss.dbeaver.ext.generic.model.GenericTableIndexColumn)4 SQLDatabasePersistAction (org.jkiss.dbeaver.model.impl.edit.SQLDatabasePersistAction)4 DBSEntityAttribute (org.jkiss.dbeaver.model.struct.DBSEntityAttribute)4 EditIndexPage (org.jkiss.dbeaver.ui.editors.object.struct.EditIndexPage)4 ArrayList (java.util.ArrayList)2 CCombo (org.eclipse.swt.custom.CCombo)2 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2 GridData (org.eclipse.swt.layout.GridData)2 DBException (org.jkiss.dbeaver.DBException)2 ExasolTableColumn (org.jkiss.dbeaver.ext.exasol.model.ExasolTableColumn)2 ExasolTableIndexColumn (org.jkiss.dbeaver.ext.exasol.model.ExasolTableIndexColumn)2 GenericTableBase (org.jkiss.dbeaver.ext.generic.model.GenericTableBase)2 GenericTableIndex (org.jkiss.dbeaver.ext.generic.model.GenericTableIndex)2 HiveIndex (org.jkiss.dbeaver.ext.hive.model.HiveIndex)2