You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by vo...@apache.org on 2015/11/18 14:53:59 UTC
ignite git commit: IGNITE-1917: Refactoring: all primitive types.
Repository: ignite
Updated Branches:
refs/heads/ignite-1917 c905464f2 -> c375c3f59
IGNITE-1917: Refactoring: all primitive types.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/c375c3f5
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/c375c3f5
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/c375c3f5
Branch: refs/heads/ignite-1917
Commit: c375c3f59c837044477d23e56262f03fb7bd0ad3
Parents: c905464
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Wed Nov 18 16:54:44 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Wed Nov 18 16:54:44 2015 +0300
----------------------------------------------------------------------
.../internal/portable/BinaryReaderExImpl.java | 263 ++++++++-----------
1 file changed, 109 insertions(+), 154 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/c375c3f5/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryReaderExImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryReaderExImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryReaderExImpl.java
index 7460fd4..84ad45b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryReaderExImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryReaderExImpl.java
@@ -306,131 +306,6 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Obje
/**
* @param fieldId Field ID.
* @return Value.
- * @throws BinaryObjectException If failed.
- */
- long readLong(int fieldId) throws BinaryObjectException {
- return findFieldById(fieldId) && checkFlag(LONG) == Flag.NORMAL ? in.readLong() : 0;
- }
-
- /**
- * @param fieldId Field ID.
- * @return Value.
- * @throws BinaryObjectException In case of error.
- */
- @Nullable Long readLongNullable(int fieldId) throws BinaryObjectException {
- if (findFieldById(fieldId)) {
- if (checkFlag(LONG) == Flag.NULL)
- return null;
-
- return in.readLong();
- }
- else
- return null;
- }
-
- /**
- * @param fieldId Field ID.
- * @return Value.
- * @throws BinaryObjectException If failed.
- */
- float readFloat(int fieldId) throws BinaryObjectException {
- return findFieldById(fieldId) && checkFlag(FLOAT) == Flag.NORMAL ? in.readFloat() : 0;
- }
-
- /**
- * @param fieldId Field ID.
- * @return Value.
- * @throws BinaryObjectException In case of error.
- */
- @Nullable Float readFloatNullable(int fieldId) throws BinaryObjectException {
- if (findFieldById(fieldId)) {
- if (checkFlag(FLOAT) == Flag.NULL)
- return null;
-
- return in.readFloat();
- }
- else
- return null;
- }
-
- /**
- * @param fieldId Field ID.
- * @return Value.
- * @throws BinaryObjectException If failed.
- */
- double readDouble(int fieldId) throws BinaryObjectException {
- return findFieldById(fieldId) && checkFlag(DOUBLE) == Flag.NORMAL ? in.readDouble() : 0;
- }
-
- /**
- * @param fieldId Field ID.
- * @return Value.
- * @throws BinaryObjectException In case of error.
- */
- @Nullable Double readDoubleNullable(int fieldId) throws BinaryObjectException {
- if (findFieldById(fieldId)) {
- if (checkFlag(DOUBLE) == Flag.NULL)
- return null;
-
- return in.readDouble();
- }
- else
- return null;
- }
-
- /**
- * @param fieldId Field ID.
- * @return Value.
- * @throws BinaryObjectException If failed.
- */
- char readChar(int fieldId) throws BinaryObjectException {
- return findFieldById(fieldId) && checkFlag(CHAR) == Flag.NORMAL ? in.readChar() : 0;
- }
-
- /**
- * @param fieldId Field ID.
- * @return Value.
- * @throws BinaryObjectException In case of error.
- */
- @Nullable Character readCharNullable(int fieldId) throws BinaryObjectException {
- if (findFieldById(fieldId)) {
- if (checkFlag(CHAR) == Flag.NULL)
- return null;
-
- return in.readChar();
- }
- else
- return null;
- }
-
- /**
- * @param fieldId Field ID.
- * @return Value.
- * @throws BinaryObjectException If failed.
- */
- boolean readBoolean(int fieldId) throws BinaryObjectException {
- return findFieldById(fieldId) && checkFlag(BOOLEAN) == Flag.NORMAL && in.readBoolean();
- }
-
- /**
- * @param fieldId Field ID.
- * @return Value.
- * @throws BinaryObjectException In case of error.
- */
- @Nullable Boolean readBooleanNullable(int fieldId) throws BinaryObjectException {
- if (findFieldById(fieldId)) {
- if (checkFlag(BOOLEAN) == Flag.NULL)
- return null;
-
- return in.readBoolean();
- }
- else
- return null;
- }
-
- /**
- * @param fieldId Field ID.
- * @return Value.
* @throws BinaryObjectException In case of error.
*/
@Nullable BigDecimal readDecimal(int fieldId) throws BinaryObjectException {
@@ -972,6 +847,34 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Obje
}
/** {@inheritDoc} */
+ @Override public boolean readBoolean(String fieldName) throws BinaryObjectException {
+ return findFieldByName(fieldName) && checkFlagPrimitive(BOOLEAN) == Flag.NORMAL && in.readBoolean();
+ }
+
+ /**
+ * @param fieldId Field ID.
+ * @return Value.
+ * @throws BinaryObjectException If failed.
+ */
+ boolean readBoolean(int fieldId) throws BinaryObjectException {
+ return findFieldById(fieldId) && checkFlagPrimitive(BOOLEAN) == Flag.NORMAL && in.readBoolean();
+ }
+
+ /**
+ * @param fieldId Field ID.
+ * @return Value.
+ * @throws BinaryObjectException In case of error.
+ */
+ @Nullable Boolean readBooleanNullable(int fieldId) throws BinaryObjectException {
+ return findFieldById(fieldId) && checkFlagPrimitive(BOOLEAN) == Flag.NORMAL ? in.readBoolean() : null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean readBoolean() throws BinaryObjectException {
+ return in.readBoolean();
+ }
+
+ /** {@inheritDoc} */
@Override public short readShort(String fieldName) throws BinaryObjectException {
return findFieldByName(fieldName) && checkFlagPrimitive(SHORT) == Flag.NORMAL ? in.readShort() : 0;
}
@@ -1000,6 +903,34 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Obje
}
/** {@inheritDoc} */
+ @Override public char readChar(String fieldName) throws BinaryObjectException {
+ return findFieldByName(fieldName) && checkFlagPrimitive(CHAR) == Flag.NORMAL ? in.readChar() : 0;
+ }
+
+ /**
+ * @param fieldId Field ID.
+ * @return Value.
+ * @throws BinaryObjectException If failed.
+ */
+ char readChar(int fieldId) throws BinaryObjectException {
+ return findFieldById(fieldId) && checkFlagPrimitive(CHAR) == Flag.NORMAL ? in.readChar() : 0;
+ }
+
+ /**
+ * @param fieldId Field ID.
+ * @return Value.
+ * @throws BinaryObjectException In case of error.
+ */
+ @Nullable Character readCharNullable(int fieldId) throws BinaryObjectException {
+ return findFieldById(fieldId) && checkFlagPrimitive(CHAR) == Flag.NORMAL ? in.readChar() : null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public char readChar() throws BinaryObjectException {
+ return in.readChar();
+ }
+
+ /** {@inheritDoc} */
@Override public int readInt(String fieldName) throws BinaryObjectException {
return findFieldByName(fieldName) && checkFlagPrimitive(INT) == Flag.NORMAL ? in.readInt() : 0;
}
@@ -1029,9 +960,25 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Obje
/** {@inheritDoc} */
@Override public long readLong(String fieldName) throws BinaryObjectException {
- Long val = readLongNullable(fieldId(fieldName));
+ return findFieldByName(fieldName) && checkFlagPrimitive(LONG) == Flag.NORMAL ? in.readLong() : 0;
+ }
- return val != null ? val : 0;
+ /**
+ * @param fieldId Field ID.
+ * @return Value.
+ * @throws BinaryObjectException If failed.
+ */
+ long readLong(int fieldId) throws BinaryObjectException {
+ return findFieldById(fieldId) && checkFlagPrimitive(LONG) == Flag.NORMAL ? in.readLong() : 0;
+ }
+
+ /**
+ * @param fieldId Field ID.
+ * @return Value.
+ * @throws BinaryObjectException In case of error.
+ */
+ @Nullable Long readLongNullable(int fieldId) throws BinaryObjectException {
+ return findFieldById(fieldId) && checkFlagPrimitive(LONG) == Flag.NORMAL ? in.readLong() : null;
}
/** {@inheritDoc} */
@@ -1041,50 +988,58 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Obje
/** {@inheritDoc} */
@Override public float readFloat(String fieldName) throws BinaryObjectException {
- Float val = readFloatNullable(fieldId(fieldName));
-
- return val != null ? val : 0;
+ return findFieldByName(fieldName) && checkFlagPrimitive(FLOAT) == Flag.NORMAL ? in.readFloat() : 0;
}
- /** {@inheritDoc} */
- @Override public float readFloat() throws BinaryObjectException {
- return in.readFloat();
+ /**
+ * @param fieldId Field ID.
+ * @return Value.
+ * @throws BinaryObjectException If failed.
+ */
+ float readFloat(int fieldId) throws BinaryObjectException {
+ return findFieldById(fieldId) && checkFlagPrimitive(FLOAT) == Flag.NORMAL ? in.readFloat() : 0;
}
- /** {@inheritDoc} */
- @Override public double readDouble(String fieldName) throws BinaryObjectException {
- Double val = readDoubleNullable(fieldId(fieldName));
-
- return val != null ? val : 0;
+ /**
+ * @param fieldId Field ID.
+ * @return Value.
+ * @throws BinaryObjectException In case of error.
+ */
+ @Nullable Float readFloatNullable(int fieldId) throws BinaryObjectException {
+ return findFieldById(fieldId) && checkFlagPrimitive(FLOAT) == Flag.NORMAL ? in.readFloat() : null;
}
/** {@inheritDoc} */
- @Override public double readDouble() throws BinaryObjectException {
- return in.readDouble();
+ @Override public float readFloat() throws BinaryObjectException {
+ return in.readFloat();
}
/** {@inheritDoc} */
- @Override public char readChar(String fieldName) throws BinaryObjectException {
- Character val = readCharNullable(fieldId(fieldName));
-
- return val != null ? val : 0;
+ @Override public double readDouble(String fieldName) throws BinaryObjectException {
+ return findFieldByName(fieldName) && checkFlagPrimitive(DOUBLE) == Flag.NORMAL ? in.readDouble() : 0;
}
- /** {@inheritDoc} */
- @Override public char readChar() throws BinaryObjectException {
- return in.readChar();
+ /**
+ * @param fieldId Field ID.
+ * @return Value.
+ * @throws BinaryObjectException If failed.
+ */
+ double readDouble(int fieldId) throws BinaryObjectException {
+ return findFieldById(fieldId) && checkFlagPrimitive(DOUBLE) == Flag.NORMAL ? in.readDouble() : 0;
}
- /** {@inheritDoc} */
- @Override public boolean readBoolean(String fieldName) throws BinaryObjectException {
- Boolean val = readBooleanNullable(fieldId(fieldName));
-
- return val != null ? val : false;
+ /**
+ * @param fieldId Field ID.
+ * @return Value.
+ * @throws BinaryObjectException In case of error.
+ */
+ @Nullable Double readDoubleNullable(int fieldId) throws BinaryObjectException {
+ return findFieldById(fieldId) && checkFlagPrimitive(DOUBLE) == Flag.NORMAL ? in.readDouble() : null;
}
/** {@inheritDoc} */
- @Override public boolean readBoolean() throws BinaryObjectException {
- return in.readBoolean();
+ @Override public double readDouble() throws BinaryObjectException {
+ return in.readDouble();
}
/** {@inheritDoc} */