Map<CQLQueryType, Map<String, PreparedStatement>> clusteredCounterPSMap = new HashMap<>();
Map<String, PreparedStatement> incrStatementPerCounter = new HashMap<>();
Map<String, PreparedStatement> decrStatementPerCounter = new HashMap<>();
Map<String, PreparedStatement> selectStatementPerCounter = new HashMap<>();
final PropertyMetaStatementGenerator statementGenerator = idMeta.forStatementGeneration();
for (PropertyMeta counterMeta : meta.getAllCounterMetas()) {
final String propertyName = counterMeta.getPropertyName();
final String cql3ColumnName = counterMeta.getCQL3ColumnName();
final boolean staticColumn = counterMeta.structure().isStaticColumn();
RegularStatement incrementStatement = prepareWhereClauseForCounterUpdate(statementGenerator, update(keyspaceName,tableName).with(incr(cql3ColumnName, bindMarker(cql3ColumnName))), staticColumn, noOptions());
RegularStatement decrementStatement = prepareWhereClauseForCounterUpdate(statementGenerator, update(keyspaceName,tableName).with(decr(cql3ColumnName, bindMarker(cql3ColumnName))), staticColumn, noOptions());
RegularStatement selectStatement = statementGenerator.generateWhereClauseForSelect(Optional.fromNullable(counterMeta), select(cql3ColumnName).from(keyspaceName,tableName));
incrStatementPerCounter.put(propertyName, session.prepare(incrementStatement));
decrStatementPerCounter.put(propertyName, session.prepare(decrementStatement));
selectStatementPerCounter.put(propertyName, session.prepare(selectStatement));
}
clusteredCounterPSMap.put(INCR, incrStatementPerCounter);
clusteredCounterPSMap.put(DECR, decrStatementPerCounter);
RegularStatement selectStatement = statementGenerator.generateWhereClauseForSelect(Optional.<PropertyMeta>absent(), select().from(keyspaceName,tableName));
selectStatementPerCounter.put(SELECT_ALL.name(), session.prepare(selectStatement));
clusteredCounterPSMap.put(SELECT, selectStatementPerCounter);
RegularStatement deleteStatement = statementGenerator.generateWhereClauseForDelete(false, delete().from(keyspaceName,tableName));
clusteredCounterPSMap.put(DELETE, of(DELETE_ALL.name(), session.prepare(deleteStatement)));
return clusteredCounterPSMap;
}