Skip to content

Compile Time Config

DuyHai DOAN edited this page Jun 9, 2018 · 3 revisions

When using Achilles you should be aware of the fact that the framework is invoked at compile time and at runtime.

At compile time Achilles will parse your source code to generate additional source code. To configure Achilles at compile time, you can use the @CompileTimeConfig annotation on a class or an interface

The interface/class can (and should) be empty. What interests us here is the attributes set on the annotation

    @CompileTimeConfig(cassandraVersion = CassandraVersion.CASSANDRA_3_0_X, 
                        columnMappingStrategy = ColumnMappingStrategy.IMPLICIT,
                        namingStrategy = NamingStrategy.SNAKE_CASE,
                        insertStrategy = InsertStrategy.ALL_FIELDS,
                        projectName = "Project1" 
    public interface AchillesCompileTimeConfig {
    
    }

What you can specify as configuration at compile time are:

  • the cassandra version. Default = CassandraVersion.CASSANDRA_3_0_X
  • the column mapping strategy. Default = ColumnMappingStrategy.EXPLICIT
  • the naming strategy. Default = NamingStrategy.LOWER_CASE
  • the insert strategy. Default = InsertStrategy.ALL_FIELDS
  • the project name. Default = ""

Please refer to the appropriate section for each of those parameters.

Specifying the Cassandra version will help Achilles unlock and generate new features that are only supported by this version and after.

For example, materialized views are not available before CassandraVersion.CASSANDRA_3_0_X

Below is the Cassandra version feature matrix:

Cassandra version Supported features Related JIRA(s)
2.1.X All existing features N/A
2.2.X
  • JSON Syntax
  • User Defined Functions
  • User Defined Aggregates
  • CASSANDRA-7970
  • CASSANDRA-7395, CASSANDRA-7526, CASSANDRA-7562, CASSANDRA-7740, CASSANDRA-7781, CASSANDRA-7929, CASSANDRA-7924, CASSANDRA-7812, CASSANDRA-8063, CASSANDRA-7813, CASSANDRA-7708
  • CASSANDRA-8053
3.0.X
  • Materialized Views
  • Support for IN restrictions on any partition key component or clustering key as well as support for EQ and IN multicolumn restrictions has been added to UPDATE and DELETE statement
  • Support for single-column and multi-column slice restrictions (>, >=, <= and <) has been added to DELETE statements
  • CASSANDRA-6477
3.1 Nothing N/A
3.2 Add support for type casting in selection clause CASSANDRA-10310
3.6
  • Allow per-partition LIMIT clause in CQL
  • Support for non-frozen user-defined types, updating individual fields of user-defined types
  • CASSANDRA-7017
  • CASSANDRA-7423
3.7
  • Full support for stable SASI index
  • CASSANDRA-10661
  • CASSANDRA-11130
  • CASSANDRA-11136
  • CASSANDRA-11159
  • CASSANDRA-11169
  • CASSANDRA-11183
  • CASSANDRA-11434
DSE 4.8.X
  • Full support for DSE Search
N/A
DSE 5.0.X
  • Full support for DSE Search
N/A

And below is the impact of each new feature on Achilles-generated code:

Cassandra Feature Achilles generated code
JSON Syntax
  • manager.crud().insertJson(String json)
  • manager.dsl().....where().xxx().Eq_FromJSON()
  • manager.dsl().select().allColumnsAsJSON_FromBaseTable().....where()......getJSON()
  • manager.dsl().update().....xxx().Set_FromJSON()
  • manager.dsl().update().....if_xxx().Eq_FromJSON()
  • manager.dsl().delete().....if_xxx().Eq_FromJSON()
User Defined Function/User Defined Aggregates
  • @FunctionRegistry is allowed
  • info.archinnov.achilles.generated.function.FunctionsRegistry generated class
Materialized Views
  • @MaterializedView is allowed
Support for IN restrictions on clustering columns for UPDATE/DELETE
  • manager.dsl().update()...where()....xxx().IN(...)
  • manager.dsl().delete()...where()....xxx().IN(...)
Support for multi-column slice restrictions (>, >=, <= and <) for DELETE
  • manager.dsl().delete()...where()....xxx().Gt(...)
  • manager.dsl().delete()...where()....xxx().Gt_And_Lt(...)
Support for type casting in selection clause
  • manager.dsl().select().function(SystemFunctions.castAsxxx()...)
Support for PER PARTITION LIMIT
  • manager.dsl().select()....perPartitionLimit(xxx)
Support for non-frozen user-defined types, updating individual fields of user-defined types
Remark: collections inside non-frozen UDT MUST be set as frozen
  • manager.dsl().update().fromBaseTable().userUDT().firstname.Set(...)
  • manager.dsl().update().fromBaseTable().userUDT().lastname.Set(...)
Support for SASI index/DSE Search (on text/ascii columns): SASI:
  • manager.indexed().select()..where().indexed_firstname().StartWith(String prefix)
  • manager.indexed().select()..where().indexed_firstname().EndWith(String suffix)
  • manager.indexed().select()..where().indexed_firstname().Contain(String substring)
DSE Search:
  • manager.indexed().select()..where().search_on_firstname().StartWith(String prefix)
  • manager.indexed().select()..where().search_on_firstname().EndWith(String suffix)
  • manager.indexed().select()..where().search_on_firstname().Contain(String substring)
  • manager.indexed().select()..where().search_on_firstname().rawPredicate(String rawSolrPredicate)
  • manager.indexed().select()..where().rawSolrQuery(String rawSolrQueryString)

Last but not least, the projectName() attribute is crucial for those who are using Achilles for multiple projects.

For more details see Multi-Project support

Home

Clone this wiki locally