You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by qi...@apache.org on 2020/04/27 09:31:20 UTC

[incubator-iotdb] branch check_is_null created (now 08a01fa)

This is an automated email from the ASF dual-hosted git repository.

qiaojialin pushed a change to branch check_is_null
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git.


      at 08a01fa  check is null in Filed

This branch includes the following new commits:

     new 08a01fa  check is null in Filed

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[incubator-iotdb] 01/01: check is null in Filed

Posted by qi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

qiaojialin pushed a commit to branch check_is_null
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git

commit 08a01fa245a095be62b28f7cc704fe9ea3e5af5b
Author: qiaojialin <64...@qq.com>
AuthorDate: Mon Apr 27 17:31:07 2020 +0800

    check is null in Filed
---
 .../iotdb/tsfile/exception/NullFieldException.java | 27 ++++++++++++++++++
 .../org/apache/iotdb/tsfile/read/common/Field.java | 19 +++++++++++++
 .../apache/iotdb/tsfile/read/common/FieldTest.java | 32 ++++++++++++++++++++++
 3 files changed, 78 insertions(+)

diff --git a/tsfile/src/main/java/org/apache/iotdb/tsfile/exception/NullFieldException.java b/tsfile/src/main/java/org/apache/iotdb/tsfile/exception/NullFieldException.java
new file mode 100644
index 0000000..eed41d5
--- /dev/null
+++ b/tsfile/src/main/java/org/apache/iotdb/tsfile/exception/NullFieldException.java
@@ -0,0 +1,27 @@
+/*
+ * 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.iotdb.tsfile.exception;
+
+public class NullFieldException extends TsFileRuntimeException {
+
+  public NullFieldException() {
+    super("Field is null");
+  }
+
+}
diff --git a/tsfile/src/main/java/org/apache/iotdb/tsfile/read/common/Field.java b/tsfile/src/main/java/org/apache/iotdb/tsfile/read/common/Field.java
index bd6c4fa..cc4e58a 100644
--- a/tsfile/src/main/java/org/apache/iotdb/tsfile/read/common/Field.java
+++ b/tsfile/src/main/java/org/apache/iotdb/tsfile/read/common/Field.java
@@ -18,6 +18,7 @@
  */
 package org.apache.iotdb.tsfile.read.common;
 
+import org.apache.iotdb.tsfile.exception.NullFieldException;
 import org.apache.iotdb.tsfile.exception.write.UnSupportedDataTypeException;
 import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
 import org.apache.iotdb.tsfile.utils.Binary;
@@ -80,6 +81,9 @@ public class Field {
   }
 
   public boolean getBoolV() {
+    if (dataType == null) {
+      throw new NullFieldException();
+    }
     return boolV;
   }
 
@@ -88,6 +92,9 @@ public class Field {
   }
 
   public int getIntV() {
+    if (dataType == null) {
+      throw new NullFieldException();
+    }
     return intV;
   }
 
@@ -96,6 +103,9 @@ public class Field {
   }
 
   public long getLongV() {
+    if (dataType == null) {
+      throw new NullFieldException();
+    }
     return longV;
   }
 
@@ -104,6 +114,9 @@ public class Field {
   }
 
   public float getFloatV() {
+    if (dataType == null) {
+      throw new NullFieldException();
+    }
     return floatV;
   }
 
@@ -112,6 +125,9 @@ public class Field {
   }
 
   public double getDoubleV() {
+    if (dataType == null) {
+      throw new NullFieldException();
+    }
     return doubleV;
   }
 
@@ -120,6 +136,9 @@ public class Field {
   }
 
   public Binary getBinaryV() {
+    if (dataType == null) {
+      throw new NullFieldException();
+    }
     return binaryV;
   }
 
diff --git a/tsfile/src/test/java/org/apache/iotdb/tsfile/read/common/FieldTest.java b/tsfile/src/test/java/org/apache/iotdb/tsfile/read/common/FieldTest.java
new file mode 100644
index 0000000..52d2eaf
--- /dev/null
+++ b/tsfile/src/test/java/org/apache/iotdb/tsfile/read/common/FieldTest.java
@@ -0,0 +1,32 @@
+/*
+ * 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.iotdb.tsfile.read.common;
+
+import org.apache.iotdb.tsfile.exception.NullFieldException;
+import org.junit.Test;
+
+public class FieldTest {
+
+  @Test(expected = NullFieldException.class)
+  public void construct() {
+    Field field = new Field(null);
+    field.getIntV();
+  }
+
+}