Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-389 7439b5b7d -> 7583bbc58


#IGNITE-389 - Changing API


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/7583bbc5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/7583bbc5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/7583bbc5

Branch: refs/heads/ignite-389
Commit: 7583bbc58ed144ffcd675e33e1003fce66ac36d2
Parents: 7439b5b
Author: Alexey Goncharuk <agoncha...@gridgain.com>
Authored: Fri May 22 19:19:10 2015 -0700
Committer: Alexey Goncharuk <agoncha...@gridgain.com>
Committed: Fri May 22 19:19:10 2015 -0700

----------------------------------------------------------------------
 .../apache/ignite/spark/IgniteAbstractRDD.scala | 38 -------------------
 .../org/apache/ignite/spark/IgniteRDD.scala     | 12 +++++-
 .../spark/examples/IgniteProcessExample.scala   |  4 ++
 .../ignite/spark/impl/IgniteAbstractRDD.scala   | 39 ++++++++++++++++++++
 .../apache/ignite/spark/impl/IgniteSqlRDD.scala |  2 +-
 5 files changed, 54 insertions(+), 41 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7583bbc5/modules/spark/src/main/scala/org/apache/ignite/spark/IgniteAbstractRDD.scala
----------------------------------------------------------------------
diff --git 
a/modules/spark/src/main/scala/org/apache/ignite/spark/IgniteAbstractRDD.scala 
b/modules/spark/src/main/scala/org/apache/ignite/spark/IgniteAbstractRDD.scala
deleted file mode 100644
index 63232be..0000000
--- 
a/modules/spark/src/main/scala/org/apache/ignite/spark/IgniteAbstractRDD.scala
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * 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.ignite.spark
-
-import org.apache.ignite.IgniteCache
-import org.apache.ignite.configuration.CacheConfiguration
-import org.apache.spark.rdd.RDD
-
-import scala.reflect.ClassTag
-
-abstract class IgniteAbstractRDD[R:ClassTag, K, V] (
-    ic: IgniteContext[K, V],
-    cacheName: String,
-    cacheCfg: CacheConfiguration[K, V]
-) extends RDD[R] (ic.sparkContext, deps = Nil) {
-    protected def ensureCache(): IgniteCache[K, V] = {
-        // Make sure to deploy the cache
-        if (cacheCfg != null)
-            ic.ignite().getOrCreateCache(cacheCfg)
-        else
-            ic.ignite().getOrCreateCache(cacheName)
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7583bbc5/modules/spark/src/main/scala/org/apache/ignite/spark/IgniteRDD.scala
----------------------------------------------------------------------
diff --git 
a/modules/spark/src/main/scala/org/apache/ignite/spark/IgniteRDD.scala 
b/modules/spark/src/main/scala/org/apache/ignite/spark/IgniteRDD.scala
index ce51e9c..281c483 100644
--- a/modules/spark/src/main/scala/org/apache/ignite/spark/IgniteRDD.scala
+++ b/modules/spark/src/main/scala/org/apache/ignite/spark/IgniteRDD.scala
@@ -18,11 +18,11 @@ package org.apache.ignite.spark
 
 import javax.cache.Cache
 
-import org.apache.ignite.cache.query.{SqlQuery, ScanQuery}
+import org.apache.ignite.cache.query.{SqlFieldsQuery, SqlQuery, ScanQuery}
 import org.apache.ignite.cluster.ClusterNode
 import org.apache.ignite.configuration.CacheConfiguration
 import org.apache.ignite.lang.IgniteUuid
-import org.apache.ignite.spark.impl.{IgniteSqlRDD, IgnitePartition, 
IgniteQueryIterator}
+import org.apache.ignite.spark.impl.{IgniteAbstractRDD, IgniteSqlRDD, 
IgnitePartition, IgniteQueryIterator}
 import org.apache.spark.rdd.RDD
 import org.apache.spark.{TaskContext, Partition}
 
@@ -66,6 +66,14 @@ class IgniteRDD[K, V] (
         new IgniteSqlRDD[(K, V), Cache.Entry[K, V], K, V](ic, cacheName, 
cacheCfg, qry, entry => (entry.getKey, entry.getValue))
     }
 
+    def queryFields(sql: String, args: Any*): RDD[Seq[Any]] = {
+        val qry = new SqlFieldsQuery(sql)
+
+        qry.setArgs(args)
+
+        new IgniteSqlRDD[Seq[Any], java.util.List[_], K, V](ic, cacheName, 
cacheCfg, qry, list => list)
+    }
+
     def saveValues(rdd: RDD[V]) = {
         rdd.foreachPartition(it => {
             println("Using scala version: " + 
scala.util.Properties.versionString)

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7583bbc5/modules/spark/src/main/scala/org/apache/ignite/spark/examples/IgniteProcessExample.scala
----------------------------------------------------------------------
diff --git 
a/modules/spark/src/main/scala/org/apache/ignite/spark/examples/IgniteProcessExample.scala
 
b/modules/spark/src/main/scala/org/apache/ignite/spark/examples/IgniteProcessExample.scala
index cdb41d2..e1f4cf0 100644
--- 
a/modules/spark/src/main/scala/org/apache/ignite/spark/examples/IgniteProcessExample.scala
+++ 
b/modules/spark/src/main/scala/org/apache/ignite/spark/examples/IgniteProcessExample.scala
@@ -42,6 +42,10 @@ object IgniteProcessExample {
 
         results.saveValues(processedRdd)
 
+        // SQL query
         ignite.fromCache("indexed").query("Person", "age > ?", 20).collect()
+
+        // SQL fields query
+        ignite.fromCache("indexed").queryFields("select name, age from Person 
where age > ?", 20).collect()
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7583bbc5/modules/spark/src/main/scala/org/apache/ignite/spark/impl/IgniteAbstractRDD.scala
----------------------------------------------------------------------
diff --git 
a/modules/spark/src/main/scala/org/apache/ignite/spark/impl/IgniteAbstractRDD.scala
 
b/modules/spark/src/main/scala/org/apache/ignite/spark/impl/IgniteAbstractRDD.scala
new file mode 100644
index 0000000..25b3b56
--- /dev/null
+++ 
b/modules/spark/src/main/scala/org/apache/ignite/spark/impl/IgniteAbstractRDD.scala
@@ -0,0 +1,39 @@
+/*
+ * 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.ignite.spark.impl
+
+import org.apache.ignite.IgniteCache
+import org.apache.ignite.configuration.CacheConfiguration
+import org.apache.ignite.spark.IgniteContext
+import org.apache.spark.rdd.RDD
+
+import scala.reflect.ClassTag
+
+abstract class IgniteAbstractRDD[R:ClassTag, K, V] (
+    ic: IgniteContext[K, V],
+    cacheName: String,
+    cacheCfg: CacheConfiguration[K, V]
+) extends RDD[R] (ic.sparkContext, deps = Nil) {
+    protected def ensureCache(): IgniteCache[K, V] = {
+        // Make sure to deploy the cache
+        if (cacheCfg != null)
+            ic.ignite().getOrCreateCache(cacheCfg)
+        else
+            ic.ignite().getOrCreateCache(cacheName)
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7583bbc5/modules/spark/src/main/scala/org/apache/ignite/spark/impl/IgniteSqlRDD.scala
----------------------------------------------------------------------
diff --git 
a/modules/spark/src/main/scala/org/apache/ignite/spark/impl/IgniteSqlRDD.scala 
b/modules/spark/src/main/scala/org/apache/ignite/spark/impl/IgniteSqlRDD.scala
index e347c85..eea389d 100644
--- 
a/modules/spark/src/main/scala/org/apache/ignite/spark/impl/IgniteSqlRDD.scala
+++ 
b/modules/spark/src/main/scala/org/apache/ignite/spark/impl/IgniteSqlRDD.scala
@@ -19,7 +19,7 @@ package org.apache.ignite.spark.impl
 
 import org.apache.ignite.cache.query.Query
 import org.apache.ignite.configuration.CacheConfiguration
-import org.apache.ignite.spark.{IgniteAbstractRDD, IgniteContext}
+import org.apache.ignite.spark.IgniteContext
 import org.apache.spark.{TaskContext, Partition}
 
 import scala.reflect.ClassTag

Reply via email to