calcite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jh...@apache.org
Subject incubator-calcite git commit: [CALCITE-615] AvaticaParameter should be Jackson serializable (Nick Dimiduk)
Date Thu, 12 Mar 2015 00:37:38 GMT
Repository: incubator-calcite
Updated Branches:
  refs/heads/master 469e5fc12 -> e848cc02e


[CALCITE-615] AvaticaParameter should be Jackson serializable (Nick Dimiduk)


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

Branch: refs/heads/master
Commit: e848cc02ed81153faa1d7426ddc6d4ac1abea41d
Parents: 469e5fc
Author: Julian Hyde <jhyde@apache.org>
Authored: Wed Mar 11 16:31:27 2015 -0700
Committer: Julian Hyde <jhyde@apache.org>
Committed: Wed Mar 11 16:31:27 2015 -0700

----------------------------------------------------------------------
 .../calcite/avatica/AvaticaParameter.java       | 32 ++++++++++++++------
 1 file changed, 23 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/e848cc02/avatica/src/main/java/org/apache/calcite/avatica/AvaticaParameter.java
----------------------------------------------------------------------
diff --git a/avatica/src/main/java/org/apache/calcite/avatica/AvaticaParameter.java b/avatica/src/main/java/org/apache/calcite/avatica/AvaticaParameter.java
index 228eb26..03fa4dc 100644
--- a/avatica/src/main/java/org/apache/calcite/avatica/AvaticaParameter.java
+++ b/avatica/src/main/java/org/apache/calcite/avatica/AvaticaParameter.java
@@ -18,6 +18,9 @@ package org.apache.calcite.avatica;
 
 import org.apache.calcite.avatica.util.ByteString;
 
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
 import java.io.InputStream;
 import java.io.Reader;
 import java.math.BigDecimal;
@@ -35,7 +38,7 @@ import java.sql.Timestamp;
 import java.util.Calendar;
 
 /**
- * Metadata for a parameter. Plus a slot to hold its value.
+ * Metadata for a parameter.
  */
 public class AvaticaParameter {
   public final boolean signed;
@@ -48,16 +51,17 @@ public class AvaticaParameter {
 
   /** Value that means the parameter has been set to null.
    * If value is null, parameter has not been set. */
-  public static final Object DUMMY_VALUE = new Object();
+  public static final Object DUMMY_VALUE = Dummy.INSTANCE;
 
+  @JsonCreator
   public AvaticaParameter(
-      boolean signed,
-      int precision,
-      int scale,
-      int parameterType,
-      String typeName,
-      String className,
-      String name) {
+      @JsonProperty("signed") boolean signed,
+      @JsonProperty("precision") int precision,
+      @JsonProperty("scale") int scale,
+      @JsonProperty("parameterType") int parameterType,
+      @JsonProperty("typeName") String typeName,
+      @JsonProperty("className") String className,
+      @JsonProperty("name") String name) {
     this.signed = signed;
     this.precision = precision;
     this.scale = scale;
@@ -244,6 +248,16 @@ public class AvaticaParameter {
   public void setObject(Object[] slots, int index, Object x, int targetSqlType,
       int scaleOrLength) {
   }
+
+  /** Singleton value to denote parameters that have been set to null (as
+   * opposed to not set).
+   *
+   * <p>Not a valid value for a parameter.
+   *
+   * <p>As an enum, it is serializable by Jackson. */
+  private enum Dummy {
+    INSTANCE
+  }
 }
 
 // End AvaticaParameter.java


Mime
View raw message