You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2015/08/27 08:34:18 UTC

[5/6] ignite git commit: Moved platform cache iterator to Ignite.

Moved platform cache iterator to Ignite.


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

Branch: refs/heads/ignite-1124
Commit: 136c099bf4ff1ba400e711dbad34216633b9236a
Parents: e428206
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Thu Aug 27 09:20:44 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Thu Aug 27 09:20:44 2015 +0300

----------------------------------------------------------------------
 .../platform/cache/PlatformCacheIterator.java   | 72 ++++++++++++++++++++
 1 file changed, 72 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/136c099b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/cache/PlatformCacheIterator.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/cache/PlatformCacheIterator.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/cache/PlatformCacheIterator.java
new file mode 100644
index 0000000..45e777d
--- /dev/null
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/cache/PlatformCacheIterator.java
@@ -0,0 +1,72 @@
+/*
+ * 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.internal.processors.platform.cache;
+
+import org.apache.ignite.*;
+import org.apache.ignite.internal.portable.*;
+import org.apache.ignite.internal.processors.platform.*;
+
+import javax.cache.*;
+import java.util.*;
+
+/**
+ * Interop cache iterator.
+ */
+public class PlatformCacheIterator extends PlatformAbstractTarget {
+    /** Operation: next entry. */
+    private static final int OP_NEXT = 1;
+
+    /** Iterator. */
+    private final Iterator<Cache.Entry> iter;
+
+    /**
+     * Constructor.
+     *
+     * @param platformCtx Context.
+     * @param iter Iterator.
+     */
+    public PlatformCacheIterator(PlatformContext platformCtx, Iterator<Cache.Entry> iter) {
+        super(platformCtx);
+
+        this.iter = iter;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void processOutOp(int type, PortableRawWriterEx writer) throws IgniteCheckedException {
+        switch (type) {
+            case OP_NEXT:
+                if (iter.hasNext()) {
+                    Cache.Entry e = iter.next();
+
+                    assert e != null;
+
+                    writer.writeBoolean(true);
+
+                    writer.writeObjectDetached(e.getKey());
+                    writer.writeObjectDetached(e.getValue());
+                }
+                else
+                    writer.writeBoolean(false);
+
+                break;
+
+            default:
+                throwUnsupported(type);
+        }
+    }
+}