IGNITE-3478: Introduced MessageWriter.writeLongArray(String name, long[] val, 
int len) helper method.


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

Branch: refs/heads/ignite-7725
Commit: 625ad412c4a4580c3f2fc7ad4d88f5368a680e1b
Parents: 11472d2
Author: sboikov <sboi...@gridgain.com>
Authored: Mon Feb 19 12:53:33 2018 +0300
Committer: devozerov <voze...@gridgain.com>
Committed: Mon Feb 19 12:53:33 2018 +0300

----------------------------------------------------------------------
 .../ignite/internal/direct/DirectMessageWriter.java      |  9 +++++++++
 .../internal/direct/stream/DirectByteBufferStream.java   |  6 ++++++
 .../direct/stream/v1/DirectByteBufferStreamImplV1.java   |  8 ++++++++
 .../direct/stream/v2/DirectByteBufferStreamImplV2.java   | 11 +++++++++++
 .../plugin/extensions/communication/MessageWriter.java   | 10 ++++++++++
 5 files changed, 44 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/625ad412/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageWriter.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageWriter.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageWriter.java
index 3ce4dfe..b224d68 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageWriter.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageWriter.java
@@ -192,6 +192,15 @@ public class DirectMessageWriter implements MessageWriter {
     }
 
     /** {@inheritDoc} */
+    @Override public boolean writeLongArray(String name, long[] val, int len) {
+        DirectByteBufferStream stream = state.item().stream;
+
+        stream.writeLongArray(val, len);
+
+        return stream.lastFinished();
+    }
+
+    /** {@inheritDoc} */
     @Override public boolean writeFloatArray(String name, @Nullable float[] 
val) {
         DirectByteBufferStream stream = state.item().stream;
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/625ad412/modules/core/src/main/java/org/apache/ignite/internal/direct/stream/DirectByteBufferStream.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/direct/stream/DirectByteBufferStream.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/direct/stream/DirectByteBufferStream.java
index bc9de5a..204e6b0 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/direct/stream/DirectByteBufferStream.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/direct/stream/DirectByteBufferStream.java
@@ -116,6 +116,12 @@ public interface DirectByteBufferStream {
 
     /**
      * @param val Value.
+     * @param len Length.
+     */
+    public void writeLongArray(long[] val, int len);
+
+    /**
+     * @param val Value.
      */
     public void writeFloatArray(float[] val);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/625ad412/modules/core/src/main/java/org/apache/ignite/internal/direct/stream/v1/DirectByteBufferStreamImplV1.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/direct/stream/v1/DirectByteBufferStreamImplV1.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/direct/stream/v1/DirectByteBufferStreamImplV1.java
index 5b67717..76cb762 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/direct/stream/v1/DirectByteBufferStreamImplV1.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/direct/stream/v1/DirectByteBufferStreamImplV1.java
@@ -435,6 +435,14 @@ public class DirectByteBufferStreamImplV1 implements 
DirectByteBufferStream {
     }
 
     /** {@inheritDoc} */
+    @Override public void writeLongArray(long[] val, int len) {
+        if (val != null)
+            lastFinished = writeArray(val, GridUnsafe.LONG_ARR_OFF, len, len 
<< 3);
+        else
+            writeInt(-1);
+    }
+
+    /** {@inheritDoc} */
     @Override public void writeFloatArray(float[] val) {
         if (val != null)
             lastFinished = writeArray(val, GridUnsafe.FLOAT_ARR_OFF, 
val.length, val.length << 2);

http://git-wip-us.apache.org/repos/asf/ignite/blob/625ad412/modules/core/src/main/java/org/apache/ignite/internal/direct/stream/v2/DirectByteBufferStreamImplV2.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/direct/stream/v2/DirectByteBufferStreamImplV2.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/direct/stream/v2/DirectByteBufferStreamImplV2.java
index a2e494d..e338bc0 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/direct/stream/v2/DirectByteBufferStreamImplV2.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/direct/stream/v2/DirectByteBufferStreamImplV2.java
@@ -529,6 +529,17 @@ public class DirectByteBufferStreamImplV2 implements 
DirectByteBufferStream {
     }
 
     /** {@inheritDoc} */
+    @Override public void writeLongArray(long[] val, int len) {
+        if (val != null)
+            if (BIG_ENDIAN)
+                lastFinished = writeArrayLE(val, LONG_ARR_OFF, len, 8, 3);
+            else
+                lastFinished = writeArray(val, LONG_ARR_OFF, len, len << 3);
+        else
+            writeInt(-1);
+    }
+
+    /** {@inheritDoc} */
     @Override public void writeFloatArray(float[] val) {
         if (val != null)
             if (BIG_ENDIAN)

http://git-wip-us.apache.org/repos/asf/ignite/blob/625ad412/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageWriter.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageWriter.java
 
b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageWriter.java
index 982aef5..692955f 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageWriter.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/plugin/extensions/communication/MessageWriter.java
@@ -173,6 +173,16 @@ public interface MessageWriter {
     public boolean writeLongArray(String name, long[] val);
 
     /**
+     * Writes {@code long} array.
+     *
+     * @param name Field name.
+     * @param val {@code long} array.
+     * @param len Length.
+     * @return Whether array was fully written.
+     */
+    public boolean writeLongArray(String name, long[] val, int len);
+
+    /**
      * Writes {@code float} array.
      *
      * @param name Field name.

Reply via email to