/** * On set key validation. * * @param cfDef * the cf def * @param cfProperties * the cf properties * @param builder * the builder */ private void onSetKeyValidation(CfDef cfDef, Properties cfProperties, StringBuilder builder) { String keyValidationClass = cfProperties.getProperty(CassandraConstants.KEY_VALIDATION_CLASS); if (keyValidationClass != null) { if (builder != null) { // nothing available. } else { cfDef.setKey_validation_class(keyValidationClass); } } }
/** * Gets the inverted index cf. * * @param tableInfo * the table info * @return the inverted index cf * @throws InvalidRequestException * the invalid request exception * @throws SchemaDisagreementException * the schema disagreement exception * @throws TException * the t exception */ private CfDef getInvertedIndexCF(TableInfo tableInfo) throws InvalidRequestException, SchemaDisagreementException, TException { boolean indexTableRequired = CassandraPropertyReader.csmd.isInvertedIndexingEnabled(databaseName) && !tableInfo.getEmbeddedColumnMetadatas().isEmpty(); if (indexTableRequired) { CfDef cfDef = new CfDef(); cfDef.setKeyspace(databaseName); cfDef.setColumn_type("Super"); cfDef.setName(tableInfo.getTableName() + Constants.INDEX_TABLE_SUFFIX); cfDef.setKey_validation_class(UTF8Type.class.getSimpleName()); return cfDef; } return null; }
/** * Provides a basic column family definition. This is a subset of #getCfDef, and does not * include compression options, but also does not require raw metadata to be passed in. * * Warning to developers: you must update CKVS.isMatchingCf if you update this method */ static CfDef getStandardCfDef(String keyspace, String internalTableName) { CfDef cf = new CfDef(keyspace, internalTableName); cf.setComparator_type("CompositeType(BytesType,LongType)"); cf.setCompaction_strategy(CassandraConstants.LEVELED_COMPACTION_STRATEGY); cf.setCompression_options(Maps.<String, String>newHashMap()); cf.setGc_grace_seconds(CassandraConstants.DEFAULT_GC_GRACE_SECONDS); // explicitly set fields to default values cf.setCaching("KEYS_ONLY"); cf.setDclocal_read_repair_chance(0.1); cf.setTriggers(ImmutableList.of()); cf.setCells_per_row_to_cache("0"); cf.setMin_index_interval(128); cf.setMax_index_interval(2048); cf.setComment(""); cf.setColumn_metadata(ImmutableList.of()); cf.setMin_compaction_threshold(4); cf.setMax_compaction_threshold(32); cf.setKey_validation_class("org.apache.cassandra.db.marshal.BytesType"); cf.setCompaction_strategy_options(ImmutableMap.of()); cf.setDefault_validation_class("org.apache.cassandra.db.marshal.BytesType"); return cf; }
user_Def.setComparator_type("UTF8Type"); user_Def.setDefault_validation_class("UTF8Type"); user_Def.setKey_validation_class("UTF8Type"); ColumnDef columnDef = new ColumnDef(ByteBuffer.wrap("birth_date".getBytes()), "Int32Type"); columnDef.index_type = IndexType.KEYS;
cfDef.setKey_validation_class("UTF8Type"); cfDef.setDefault_validation_class("UTF8Type"); cfDef.setComparator_type("UTF8Type"); cfDef.setKey_validation_class("UTF8Type"); ColumnDef columnDef = new ColumnDef(ByteBuffer.wrap("first_name".getBytes()), "UTF8Type"); columnDef.index_type = IndexType.KEYS;
/** * Sets the up. * * @throws Exception * the exception */ @Before public void setUp() throws Exception { CassandraCli.cassandraSetUp(); CassandraCli.createKeySpace("KunderaExamples"); Cassandra.Client client = CassandraCli.getClient(); client.set_keyspace("KunderaExamples"); CfDef cf_def = new CfDef(); cf_def.keyspace = "KunderaExamples"; cf_def.name = "users"; cf_def.setKey_validation_class("UTF8Type"); ColumnDef columnDef2 = new ColumnDef(ByteBuffer.wrap("full_name".getBytes()), "UTF8Type"); columnDef2.index_type = IndexType.KEYS; cf_def.addToColumn_metadata(columnDef2); ColumnDef columnDef3 = new ColumnDef(ByteBuffer.wrap("birth_date".getBytes()), "Int32Type"); columnDef3.index_type = IndexType.KEYS; cf_def.addToColumn_metadata(columnDef3); ColumnDef columnDef4 = new ColumnDef(ByteBuffer.wrap("state".getBytes()), "UTF8Type"); columnDef4.index_type = IndexType.KEYS; cf_def.addToColumn_metadata(columnDef4); client.system_add_column_family(cf_def); }
/** * @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; }
cf_def.keyspace = "UUIDCassandra"; cf_def.name = "uuidsample"; cf_def.setKey_validation_class("UUIDType"); ColumnDef columnDef2 = new ColumnDef(ByteBuffer.wrap("name".getBytes()), "UTF8Type"); columnDef2.index_type = IndexType.KEYS;
cfDef.name = "StudentShortPrimitive"; cfDef.keyspace = keyspace; cfDef.setKey_validation_class("Int32Type"); cfDef.setComparator_type("UTF8Type"); ColumnDef name = new ColumnDef(ByteBuffer.wrap("NAME".getBytes()), "UTF8Type");
professionalCfDef.keyspace = _KEYSPACE; professionalCfDef.setComparator_type("UTF8Type"); professionalCfDef.setKey_validation_class("UTF8Type");
user_Def.setComparator_type("UTF8Type"); user_Def.setDefault_validation_class("UTF8Type"); user_Def.setKey_validation_class("UTF8Type"); ColumnDef columnDef = new ColumnDef(ByteBuffer.wrap("PERSON_ID".getBytes()), "UTF8Type"); columnDef.index_type = IndexType.KEYS;
cfDef.name = "StudentLongPrimitive"; cfDef.keyspace = keyspace; cfDef.setKey_validation_class("LongType"); cfDef.setComparator_type("UTF8Type"); ColumnDef name = new ColumnDef(ByteBuffer.wrap("NAME".getBytes()), "UTF8Type");
cfDef.name = "StudentBooleanPrimitive"; cfDef.keyspace = keyspace; cfDef.setKey_validation_class("BooleanType"); cfDef.setComparator_type("UTF8Type"); ColumnDef name = new ColumnDef(ByteBuffer.wrap("NAME".getBytes()), "UTF8Type");
cfDef.name = "StudentInt"; cfDef.keyspace = keyspace; cfDef.setKey_validation_class("Int32Type"); cfDef.setComparator_type("UTF8Type"); ColumnDef name = new ColumnDef(ByteBuffer.wrap("NAME".getBytes()), "UTF8Type");
cfDef.name = "StudentString"; cfDef.keyspace = keyspace; cfDef.setKey_validation_class("UTF8Type"); cfDef.setComparator_type("UTF8Type"); ColumnDef name = new ColumnDef(ByteBuffer.wrap("NAME".getBytes()), "UTF8Type");
cfDef.name = "StudentBytePrimitive"; cfDef.keyspace = keyspace; cfDef.setKey_validation_class("Int32Type"); cfDef.setComparator_type("UTF8Type"); ColumnDef name = new ColumnDef(ByteBuffer.wrap("NAME".getBytes()), "UTF8Type");
cfDef.name = "StudentBooleanWrapper"; cfDef.keyspace = keyspace; cfDef.setKey_validation_class("BooleanType"); cfDef.setComparator_type("UTF8Type"); ColumnDef name = new ColumnDef(ByteBuffer.wrap("NAME".getBytes()), "UTF8Type");
cfDef.name = "StudentInteger"; cfDef.keyspace = keyspace; cfDef.setKey_validation_class("Int32Type"); cfDef.setComparator_type("UTF8Type"); ColumnDef name = new ColumnDef(ByteBuffer.wrap("NAME".getBytes()), "UTF8Type");
cfDef.name = "StudentShortWrapper"; cfDef.keyspace = keyspace; cfDef.setKey_validation_class("Int32Type"); cfDef.setComparator_type("UTF8Type"); ColumnDef name = new ColumnDef(ByteBuffer.wrap("NAME".getBytes()), "UTF8Type");
d.setKey_cache_save_period_in_seconds(keyCacheSavePeriodInSeconds); if(false || keyValidationClass != null) { d.setKey_validation_class(keyValidationClass + keyValidationAlias); } else { d.setKey_validation_class(keyValidationClass);