/** * Validate compound key. * * @param tableInfo * the table info */ private void validateCompoundKey(TableInfo tableInfo) { if (tableInfo.getType() != null && tableInfo.getType().equals(Type.SUPER_COLUMN_FAMILY.name())) { throw new SchemaGenerationException( "Composite/Compound columns are not yet supported over Super column family by Cassandra", "cassandra", databaseName); } }
/** * Checks if is counter column type. * * @param tableInfo * the table info * @param defaultValidationClass * the default validation class * @return true, if is counter column type */ private boolean isCounterColumnType(TableInfo tableInfo, String defaultValidationClass) { return (csmd != null && csmd.isCounterColumn(databaseName, tableInfo.getTableName())) || (defaultValidationClass != null && (defaultValidationClass.equalsIgnoreCase(CounterColumnType.class.getSimpleName()) || defaultValidationClass .equalsIgnoreCase(CounterColumnType.class.getName())) || (tableInfo.getType() .equals(CounterColumnType.class.getSimpleName()))); } }
/** * Checks if is cql3 enabled. * * @param tableInfo * the table info * @return true, if is cql3 enabled */ private boolean isCql3Enabled(TableInfo tableInfo) { Properties cfProperties = getColumnFamilyProperties(tableInfo); String defaultValidationClass = cfProperties != null ? cfProperties .getProperty(CassandraConstants.DEFAULT_VALIDATION_CLASS) : null; // For normal columns boolean isCounterColumnType = isCounterColumnType(tableInfo, defaultValidationClass); return containsCompositeKey(tableInfo) || containsCollectionColumns(tableInfo) || ((cql_version != null && cql_version.equals(CassandraConstants.CQL_VERSION_3_0)) && (containsEmbeddedColumns(tableInfo) || containsElementCollectionColumns(tableInfo))) && !isCounterColumnType || ((cql_version != null && cql_version.equals(CassandraConstants.CQL_VERSION_3_0)) && !tableInfo .getType().equals(Type.SUPER_COLUMN_FAMILY.name())); }
/** * @param tableInfo * @return CfDef object */ private CfDef getTableMetadata(TableInfo tableInfo) { CfDef cfDef = new CfDef(); cfDef.setKeyspace(databaseName); cfDef.setName(tableInfo.getTableName()); cfDef.setKey_validation_class(CassandraValidationClassMapper.getValidationClass(tableInfo.getTableIdType(), isCql3Enabled(tableInfo))); Schema schema = CassandraPropertyReader.csmd.getSchema(databaseName); tables = schema != null ? schema.getTables() : null; Properties cfProperties = getColumnFamilyProperties(tableInfo); String defaultValidationClass = null; if (tableInfo.getType() != null && tableInfo.getType().equals(Type.SUPER_COLUMN_FAMILY.name())) { getSuperColumnFamilyMetadata(tableInfo, cfDef, defaultValidationClass); } else if (tableInfo.getType() != null) { getColumnFamilyMetadata(tableInfo, cfDef, cfProperties); } setColumnFamilyProperties(cfDef, cfProperties, null); return cfDef; }
&& cfDef.getColumn_type().equals(ColumnFamilyType.getInstanceOf(tableInfo.getType()).name()))
for (TableInfo tableInfo : tableInfos) if (isCql3Enabled(tableInfo) && !tableInfo.getType().equals(Type.SUPER_COLUMN_FAMILY.name()))
Assert.assertEquals("column family", tableInfo.getType());
/** * * @param tableInfo */ private void validateCompoundKey(TableInfo tableInfo) { if (tableInfo.getType() != null && tableInfo.getType().equals(Type.SUPER_COLUMN_FAMILY.name())) { throw new SchemaGenerationException( "Composite/Compound columns are not yet supported over Super column family by Cassandra", "cassandra", databaseName); } }
/** * * @param tableInfo * @return */ private boolean isCql3Enabled(TableInfo tableInfo) { return containsCompositeKey(tableInfo) || ((cql_version != null && cql_version.equals(CassandraConstants.CQL_VERSION_3_0)) && !tableInfo .getType().equals(Type.SUPER_COLUMN_FAMILY.name())); }
/** * Checks if is counter column type. * * @param tableInfo * the table info * @param defaultValidationClass * the default validation class * @return true, if is counter column type */ private boolean isCounterColumnType(TableInfo tableInfo, String defaultValidationClass) { return (csmd != null && csmd.isCounterColumn(databaseName, tableInfo.getTableName())) || (defaultValidationClass != null && (defaultValidationClass.equalsIgnoreCase(CounterColumnType.class.getSimpleName()) || defaultValidationClass .equalsIgnoreCase(CounterColumnType.class.getName())) || (tableInfo.getType() .equals(CounterColumnType.class.getSimpleName()))); } }
/** * @param tableInfo * @return CfDef object */ private CfDef getTableMetadata(TableInfo tableInfo) { CfDef cfDef = new CfDef(); cfDef.setKeyspace(databaseName); cfDef.setName(tableInfo.getTableName()); cfDef.setKey_validation_class(CassandraValidationClassMapper.getValidationClass(tableInfo.getTableIdType(), isCql3Enabled(tableInfo))); Schema schema = CassandraPropertyReader.csmd.getSchema(databaseName); tables = schema != null ? schema.getTables() : null; Properties cFProperties = getColumnFamilyProperties(tableInfo); String defaultValidationClass = null; if (tableInfo.getType() != null && tableInfo.getType().equals(Type.SUPER_COLUMN_FAMILY.name())) { getSuperColumnFamilyMetadata(tableInfo, cfDef, defaultValidationClass); } else if (tableInfo.getType() != null) { getColumnFamilyMetadata(tableInfo, cfDef, cFProperties); } setColumnFamilyProperties(cfDef, cFProperties, null); return cfDef; }
private void onValidateTable(KsDef ksDef, TableInfo tableInfo) throws Exception { boolean tablefound = false; for (CfDef cfDef : ksDef.getCf_defs()) { if (cfDef.getName().equals(tableInfo.getTableName()) && (cfDef.getColumn_type().equals(ColumnFamilyType.getInstanceOf(tableInfo.getType()).name()))) { if (cfDef.getColumn_type().equals(ColumnFamilyType.Standard.name())) { for (ColumnInfo columnInfo : tableInfo.getColumnMetadatas()) { onValidateColumn(tableInfo, cfDef, columnInfo); } tablefound = true; break; } else if (cfDef.getColumn_type().equals(ColumnFamilyType.Super.name())) { tablefound = true; } } } if (!tablefound) { throw new SchemaGenerationException("Column family " + tableInfo.getTableName() + " does not exist in keyspace " + databaseName + "", "Cassandra", databaseName, tableInfo.getTableName()); } }
&& cfDef.getColumn_type().equals(ColumnFamilyType.getInstanceOf(tableInfo.getType()).name()))