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_r279667058
 
 

 ##########
 File path: 
gora-ignite/src/main/java/org/apache/gora/ignite/store/IgniteStore.java
 ##########
 @@ -176,6 +176,27 @@ public boolean schemaExists() throws GoraException {
     }
   }
 
+  @Override
+  public boolean exists(K key) throws GoraException {
+    Object[] keyl = null;
+    if (igniteMapping.getPrimaryKey().size() == 1) {
+      keyl = new Object[]{key};
+    } else {
+      //Composite key pending
+    }
+    String selectQuery = 
IgniteSQLBuilder.createSelectQueryExists(igniteMapping);
+    try (PreparedStatement stmt = connection.prepareStatement(selectQuery)) {
+      IgniteSQLBuilder.fillSelectQuery(stmt, igniteMapping, keyl);
+      ResultSet rs = stmt.executeQuery();
+      rs.next();
+      int resp = rs.getInt(1);
 
 Review comment:
   Isn't it enough to check whether ResultSet is empty or not to check whether 
that key exist or not? What is the purpose of adding below statement? 
   ```
   int resp = rs.getInt(1);
   ```
   @carlosrmng Do you have anything to add here?

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