You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@gora.apache.org by GitBox <gi...@apache.org> on 2021/05/07 17:55:44 UTC

[GitHub] [gora] mgov88 opened a new pull request #235: [GORA-663] Add datastore for Neo4j

mgov88 opened a new pull request #235:
URL: https://github.com/apache/gora/pull/235


   This pull request contains the implementation of the Neo4j Datastore for Apache Gora
   
   Please let me know if you have feedback.
   
   Intern: Gaby Ortiz
   Project: Add datastore for Neo4j
   Outreachy: 2020 Winter
   
   


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



[GitHub] [gora] kamaci commented on a change in pull request #235: [GORA-663] Add datastore for Neo4j

Posted by GitBox <gi...@apache.org>.
kamaci commented on a change in pull request #235:
URL: https://github.com/apache/gora/pull/235#discussion_r628414884



##########
File path: gora-neo4j/src/main/java/org/apache/gora/neo4j/query/Neo4jResult.java
##########
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.gora.neo4j.query;
+
+import java.io.IOException;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import org.apache.gora.neo4j.store.Neo4jStore;
+import org.apache.gora.persistency.impl.PersistentBase;
+import org.apache.gora.query.Query;
+import org.apache.gora.query.impl.ResultBase;
+import org.apache.gora.store.DataStore;
+
+/**
+ * Neo4jResult specific implementation of the
+ * {@link org.apache.gora.query.Result} interface.
+ */
+public class Neo4jResult<K, T extends PersistentBase> extends ResultBase<K, T> {
+
+  private int size = -1;
+  private Iterator<Map.Entry<K, T>> iterator;
+
+  public Neo4jResult(DataStore<K, T> dataStore, Query<K, T> query, ResultSet resultSet) throws SQLException, IOException {
+    super(dataStore, query);
+    Map<K, T> data = new LinkedHashMap();
+    this.size = 0;
+    while (resultSet.next()) {
+      this.size++;
+      K keyTemp = ((Neo4jStore<K, T>) getDataStore()).extractKey(resultSet);
+      T persistentTemp = ((Neo4jStore<K, T>) getDataStore()).newInstance(resultSet, getQuery().getFields());
+      data.put(keyTemp, persistentTemp);
+    }
+    this.iterator = data.entrySet().iterator();
+  }
+
+  @Override
+  protected boolean nextInner() throws IOException {
+    if (!iterator.hasNext()) {
+      return false;
+    }
+    Map.Entry<K, T> next = iterator.next();
+    key = next.getKey();
+    persistent = next.getValue();
+    return persistent != null;
+  }
+
+  @Override
+  public float getProgress() throws IOException, InterruptedException {
+    if (iterator == null) {
+      return 0;
+    } else if (size == 0) {

Review comment:
       There is no need to write `else` since you have a return for a clean code. You can rewrite it like that:
   
   ```
   if (iterator == null) {
         return 0;
   }
   
   if (size == 0) {
     return 1;
   }
   
   return offset / (float) size;
   ```




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



[GitHub] [gora] lewismc commented on pull request #235: [GORA-663] Add datastore for Neo4j

Posted by GitBox <gi...@apache.org>.
lewismc commented on pull request #235:
URL: https://github.com/apache/gora/pull/235#issuecomment-834657532


   This is another huge pull request @mgov88 congratulations getting the code to this stage. I am running the CI on the build to see what it tells us. 


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



[GitHub] [gora] lewismc closed pull request #235: [GORA-663] Add datastore for Neo4j

Posted by GitBox <gi...@apache.org>.
lewismc closed pull request #235:
URL: https://github.com/apache/gora/pull/235


   


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