djkevincr commented on a change in pull request #156: GORA 411 - Add exists(key) to DataStore interface URL: https://github.com/apache/gora/pull/156#discussion_r271654155
########## File path: gora-cassandra/src/main/java/org/apache/gora/cassandra/serializers/CassandraQueryFactory.java ########## @@ -313,6 +313,24 @@ static String getSelectObjectWithFieldsQuery(CassandraMapping mapping, String[] String[] columnNames = getColumnNames(mapping, keyFields); return processKeys(columnNames, select); } + + /** + * This method returns CQL Select query to check if a key exists. + * This method is used for Avro Serialization + * refer: http://docs.datastax.com/en/cql/3.3/cql/cql_reference/cqlSelect.html + * + * @param mapping Cassandra Mapping {@link CassandraMapping} + * @param keyFields key fields + * @return CQL Query + */ + static String getCheckExistsQuery(CassandraMapping mapping, List<String> keyFields) { + Select select = QueryBuilder.select().countAll().from(mapping.getKeySpace().getName(), mapping.getCoreName()); + if (Boolean.parseBoolean(mapping.getProperty("allowFiltering"))) { Review comment: +1 to document this. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services