IndexMaintainerHelper { public static String getCQLStatementForWhereClauses(String CQL, Index index) { String key = index.getDatabaseName() + ":" + index.getTableName() + ":" + index.getName(); String whereClause; String iTableToUpdate = Utils.calculateITableName(index); Cache whereCache = CacheFactory.getCache("iTableWhere"); Element e = whereCache.get(key); if (e == null || e.getObjectValue() == null) { e = new Element(key, getWhereClauseHelper(index)); whereCache.put(e); } else { logger.trace("Pulling WHERE statement info from Cache: " + e.getObjectValue().toString()); } whereClause = (String) e.getObjectValue(); return String.format(CQL, iTableToUpdate, whereClause); } private  IndexMaintainerHelper(); static List<BoundStatement> generateDocumentCreateIndexEntriesStatements(Session session, Document entity, BucketLocator bucketLocator); static BoundStatement generateDocumentCreateIndexEntryStatement(Session session, Index index, Document entity, BucketLocator bucketLocator); static List<BoundStatement> generateDocumentUpdateIndexEntriesStatements(Session session, Document entity, BucketLocator bucketLocator); static List<BoundStatement> generateDocumentDeleteIndexEntriesStatements(Session session, Document entity, BucketLocator bucketLocator); static List<Index> getIndexForDocument(Session session, Document entity); static boolean hasIndexedFieldChanged(BSONObject oldObject, Index index, Document entity); static BSONObject getOldObjectForUpdate(Session session, Document entity); static String getCQLStatementForInsert(Index index); static String generateCQLStatementForInsert(Index index); static String getCQLStatementForWhereClauses(String CQL, Index index); static String generateCQLStatementForWhereClauses(String CQL, Index index); static final String ITABLE_INSERT_CQL; static final String ITABLE_UPDATE_CQL; static final String ITABLE_DELETE_CQL; }
@Test public void testGenerateCQLStatementForUpdate2() { System.out.println("generateCQLStatementForUpdate"); String expResult = "UPDATE mydb_mytable_myindexwithonefield SET object = ?, updated_at = ? WHERE bucket = ? AND id = ? AND myindexedfield = ?;"; String result = IndexMaintainerHelper.getCQLStatementForWhereClauses(IndexMaintainerHelper.ITABLE_UPDATE_CQL, index1); assertEquals(expResult, result); expResult = "UPDATE mydb_mytable_myindexwithtwofields SET object = ?, updated_at = ? WHERE bucket = ? AND id = ? AND myindexedfield1 = ? AND myindexedfield2 = ?;"; result = IndexMaintainerHelper.getCQLStatementForWhereClauses(IndexMaintainerHelper.ITABLE_UPDATE_CQL, index2); assertEquals(expResult, result); }