[ https://issues.apache.org/jira/browse/GORA-535?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16587247#comment-16587247 ]
ASF GitHub Bot commented on GORA-535: ------------------------------------- Github user djkevincr commented on a diff in the pull request: https://github.com/apache/gora/pull/134#discussion_r211546949 --- Diff: gora-ignite/src/main/java/org/apache/gora/ignite/query/IgniteResult.java --- @@ -0,0 +1,93 @@ +/* + * 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.ignite.query; + +import java.io.IOException; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import org.apache.gora.ignite.store.IgniteStore; +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; + +/** + * IgniteResult specific implementation of the + * {@link org.apache.gora.query.Result} interface. + */ +public class IgniteResult<K, T extends PersistentBase> extends ResultBase<K, T> { + + private ResultSet resultSet; + private int size; + + public IgniteResult(DataStore<K, T> dataStore, Query<K, T> query) { + super(dataStore, query); + } + + @Override + protected boolean nextInner() throws IOException { + try { + if (!resultSet.next()) { + return false; + } + key = ((IgniteStore<K, T>) getDataStore()).extractKey(resultSet); + persistent = ((IgniteStore<K, T>) getDataStore()).newInstance(resultSet, getQuery().getFields()); + return persistent != null; + } catch (SQLException ex) { + throw new IOException(ex); + } + } + + @Override + public float getProgress() throws IOException, InterruptedException { + if (resultSet == null) { + return 0; + } else if (size == 0) { + return 1; + } else { + return offset / (float) size; + } + } + + @Override + public int size() { + return size; + } + + @Override + public void close() throws IOException { + if (resultSet != null) { + try { + resultSet.close(); + } catch (SQLException ex) { + throw new IOException(ex); + } + } + } + + public void setResultSet(ResultSet resultSet) throws SQLException { --- End diff -- Please write a overloaded constructor for IgniteResult(DataStore<K, T> dataStore, Query<K, T> query, ResultSet resultSet) then you can get rid of this public method, resultSet is passed as constructor argument. You can also move the size initialization logic to constructor itself. I don't this we need expose this public method/api, WDYT? This behavior/method is not exposed from ResultBase, added as public method for IgniteResult. That means this method is not visible for the people who use base class ResultBase methods in their code, you have already extended required base class methods according to Ignite store needs. > Add a data store for Apache Ignite > ----------------------------------- > > Key: GORA-535 > URL: https://issues.apache.org/jira/browse/GORA-535 > Project: Apache Gora > Issue Type: New Feature > Reporter: Nishadi Kirielle > Priority: Major > Labels: gsoc2018 > > Currently, Gora has support for persisting objects to various database models > such as Apache Hbase, Apache Cassandra and much more. [1] This project aims > to extend its capability to provide support for Apache Ignite database. > Apache Ignite is a distributed database, caching and processing platform.[2] > [1]. [http://gora.apache.org/] > [2] . [https://ignite.apache.org/] > -- This message was sent by Atlassian JIRA (v7.6.3#76005)