Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-950 2bc8b2534 -> dee21a458


ignite-950: interface improvements


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

Branch: refs/heads/ignite-950
Commit: dee21a4584e6372cac2c21c1d41ef8c06532c270
Parents: 2bc8b25
Author: Denis Magda <dma...@gridgain.com>
Authored: Fri Jun 5 09:19:00 2015 +0300
Committer: Denis Magda <dma...@gridgain.com>
Committed: Fri Jun 5 09:19:00 2015 +0300

----------------------------------------------------------------------
 .../ignite/internal/util/io/GridDataInput.java     | 14 +++++++++++---
 .../internal/util/io/GridUnsafeDataInput.java      |  9 +++++++--
 .../optimized/OptimizedObjectInputStream.java      | 17 ++++++++++++++---
 3 files changed, 32 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dee21a45/modules/core/src/main/java/org/apache/ignite/internal/util/io/GridDataInput.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/util/io/GridDataInput.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/util/io/GridDataInput.java
index 81c6bcb..2583673 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/util/io/GridDataInput.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/util/io/GridDataInput.java
@@ -43,12 +43,20 @@ public interface GridDataInput extends DataInput {
     public void inputStream(InputStream in) throws IOException;
 
     /**
-     * Sets offset to the new position. Supported only for {@code 
GridDataInput} backed by byte array.
+     * Moves stream cursor to the new position. Supported only for {@code 
GridDataInput} backed by byte array.
      *
-     * @param off Offset.
+     * @param pos Position.
+     * @throws IOException In case of error.
+     */
+    public void position(int pos) throws IOException;
+
+    /**
+     * Returns current position in the {@code GridDataInput} stream.
+     *
+     * @return Position.
      * @throws IOException In case of error.
      */
-    public void offset(int off) throws IOException;
+    public int position() throws IOException;
 
     /**
      * Size of {@code GridDataInput}. Supported only for instances backed by 
byte array.

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dee21a45/modules/core/src/main/java/org/apache/ignite/internal/util/io/GridUnsafeDataInput.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/util/io/GridUnsafeDataInput.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/util/io/GridUnsafeDataInput.java
index 5f11768..d2ae22d 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/util/io/GridUnsafeDataInput.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/util/io/GridUnsafeDataInput.java
@@ -177,11 +177,16 @@ public class GridUnsafeDataInput extends InputStream 
implements GridDataInput {
     }
 
     /** {@inheritDoc} */
-    @Override public void offset(int off) throws IOException {
+    @Override public void position(int pos) throws IOException {
         if (in != null)
             throw new IOException("Unable to change offset in InputStream");
 
-        this.off = off;
+        this.off = pos;
+    }
+
+    /** {@inheritDoc} */
+    @Override public int position() throws IOException {
+        return off;
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dee21a45/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedObjectInputStream.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedObjectInputStream.java
 
b/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedObjectInputStream.java
index 5f5a042..27222c9 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedObjectInputStream.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedObjectInputStream.java
@@ -956,6 +956,17 @@ class OptimizedObjectInputStream extends ObjectInputStream 
{
         return -1;
     }
 
+    /**
+     * Checks whether the object has a field with name {@code fieldName}.
+     *
+     * @param fieldName Field name.
+     * @return {@code true} if field exists, {@code false} otherwise.
+     */
+    public boolean hasField(String fieldName) {
+
+        return false;
+    }
+
     //TODO
     Object readField(String fieldName) throws IOException, 
ClassNotFoundException {
         byte type = in.readByte();
@@ -966,7 +977,7 @@ class OptimizedObjectInputStream extends ObjectInputStream {
         int fieldId = resolveFieldId(fieldName);
 
         int end = in.size();
-        in.offset(end - 4);
+        in.position(end - 4);
 
         int footerLen = in.readInt();
 
@@ -974,7 +985,7 @@ class OptimizedObjectInputStream extends ObjectInputStream {
             return null; //TODO: IGNITE-950
 
         int footerStartOff = in.size() - footerLen;
-        in.offset(footerStartOff);
+        in.position(footerStartOff);
 
         int fieldsDataPos = in.readInt();
 
@@ -996,7 +1007,7 @@ class OptimizedObjectInputStream extends ObjectInputStream 
{
         }
 
         if (fieldOff > 0) {
-            in.offset(fieldOff);
+            in.position(fieldOff);
             return readObject();
         }
 

Reply via email to