djkevincr commented on a change in pull request #186: [GORA-527] Implement a 
data store for redis
URL: https://github.com/apache/gora/pull/186#discussion_r316496181
 
 

 ##########
 File path: 
gora-redis/src/main/java/org/apache/gora/redis/query/RedisResult.java
 ##########
 @@ -0,0 +1,111 @@
+/**
+ * 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.redis.query;
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.Iterator;
+import org.apache.gora.persistency.impl.PersistentBase;
+import org.apache.gora.query.Query;
+import org.apache.gora.query.impl.ResultBase;
+import org.apache.gora.redis.store.RedisStore;
+import org.apache.gora.store.DataStore;
+
+/**
+ * Redis specific implementation of the {@link org.apache.gora.query.Result}
+ * interface.
+ */
+public class RedisResult<K, T extends PersistentBase> extends ResultBase<K, T> 
{
+
+  private Iterator<String> range;
+  private final int size;
+
+  /**
+   * Gets the data store used
+   *
+   * @return
+   */
+  @Override
+  public RedisStore<K, T> getDataStore() {
+    return (RedisStore<K, T>) super.getDataStore();
+  }
+
+  /**
+   * @param dataStore
+   * @param query
+   * @param rg
+   */
+  public RedisResult(DataStore<K, T> dataStore, Query<K, T> query, 
Collection<String> rg) {//, Scanner scanner) {
+    super(dataStore, query);
+    this.size = rg.size();
+    this.range = rg.iterator();
+  }
+
+  /**
+   * Gets the items reading progress
+   *
+   * @return
+   * @throws java.io.IOException
+   */
+  @Override
+  public float getProgress() throws IOException {
+    if (this.limit != -1) {
+      return (float) this.offset / (float) this.limit;
+    } else {
+      return 0;
+    }
+  }
+
+  @Override
+  public void close() throws IOException {
+  }
+
+  /**
+   * Gets the next item
+   *
+   * @return
+   * @throws java.io.IOException
+   */
+  @Override
+  protected boolean nextInner() throws IOException {
+    if (range == null) {
+      return false;
+    }
+    boolean next = range.hasNext();
+    if (next) {
+      String nextkey = range.next();
+      key = (K) nextkey;
 
 Review comment:
   @cuent So if I my understanding is correct. We currently do not have support 
for keys other than String right? Clearly the below type cast will end up in 
exception if K == java.lang.Long
   ```
   String nextkey = range.next();
   key = (K) nextkey;
   ```
   And on the other hand I don't see any usage/import for ScoredSortedList in 
current code.
   
   This is perfectly fine, I just wanted to clear all the doubts on where are 
we now. Please document all the limitations. Please document these and open 
tickets clearly mentioned cases where we further improved with details like 
above.

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