gora-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [gora] jhnmora000 commented on a change in pull request #156: GORA 411 - Add exists(key) to DataStore interface
Date Thu, 02 May 2019 06:02:03 GMT
jhnmora000 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_r280295627
 
 

 ##########
 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:
   I tried to use a similar approach to one used in the Cassandra backend (based on this [post](https://stackoverflow.com/a/34475402)),
but what you suggest seems more intuitive, I will try it.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message