lewismc 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_r270284347
 
 

 ##########
 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:
   We need some example showing this or maybe for documentation somewhere to 
reflect this otherwise no-one is going to know it exists.

----------------------------------------------------------------
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

Reply via email to