Date: Friday, December 30, 2005 @ 17:53:05
  Author: gilles
    Path: /cvsroot/carob/carob/src

Modified: SQLDataSerialization.cpp (1.12 -> 1.13)

Added Timestamp deserialization (untested)
Minor javadoc fixes


--------------------------+
 SQLDataSerialization.cpp |   46 +++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 42 insertions(+), 4 deletions(-)


Index: carob/src/SQLDataSerialization.cpp
diff -u carob/src/SQLDataSerialization.cpp:1.12 
carob/src/SQLDataSerialization.cpp:1.13
--- carob/src/SQLDataSerialization.cpp:1.12     Tue Dec 13 16:08:30 2005
+++ carob/src/SQLDataSerialization.cpp  Fri Dec 30 17:53:05 2005
@@ -30,6 +30,7 @@
 
 using namespace CarobNS;
 
+// String
 ResultSetDataType stringDeserializer(const DriverSocket& input)
     throw (SocketIOException, UnexpectedException)
 {
@@ -40,6 +41,8 @@
   return res;
 }
 // Big Decimal => see BigDecimal class
+
+// Int
 ResultSetDataType integerDeserializer(const DriverSocket& input)
     throw (SocketIOException, UnexpectedException)
 {
@@ -48,6 +51,7 @@
   return res;
 }
 
+// Bool
 ResultSetDataType booleanDeserializer(const DriverSocket& input)
     throw (SocketIOException, UnexpectedException)
 {
@@ -56,6 +60,7 @@
   return res;
 }
 
+// Long
 ResultSetDataType longDeserializer(const DriverSocket& input)
     throw (SocketIOException, UnexpectedException)
 {
@@ -64,8 +69,9 @@
   return res;
 }
 
+// Float
 /**
- * Convert the input integer which is in in IEEE 754 floating-point
+ * Converts the input integer which is in in IEEE 754 floating-point
  * "single format" bit layout to the corresponding float. 
  * Bit 31 (the most significant) is the sign bit,
  * bits 30-23 (masked by 0x7f800000) represent the exponent,
@@ -90,8 +96,9 @@
   return res;
 }
 
+// Double
 /**
- * Convert the argument in IEEE 754 floating-point "double format" bit layout
+ * Converts the argument in IEEE 754 floating-point "double format" bit layout
  * to the corresponding float. Bit 63 (the most significant) is the sign bit,
  * bits 62-52 (masked by 0x7ff0000000000000L) represent the exponent,
  * and bits 51-0 (masked by 0x000fffffffffffffL) are the mantissa.
@@ -115,6 +122,7 @@
   return res;
 }
 
+// Byte Array
 ResultSetDataType byteArrayDeserializer(const DriverSocket& input)
     throw (SocketIOException, UnexpectedException)
 {
@@ -132,8 +140,10 @@
   return res;
 }
 
+// Date
 /**
- * For now, we just return a long
+ * The long returned is the number of milliseconds since
+ * January 1, 1970, 00:00:00 GMT
  */
 ResultSetDataType SQLDateDeserializer(const DriverSocket& input)
     throw (SocketIOException, UnexpectedException)
@@ -143,8 +153,10 @@
   return res;
 }
 
+// Time
 /**
- * For now, we just return an int
+ * The integer returned is Returns the number of milliseconds since
+ * January 1, 1970, 00:00:00 GMT
  */
 ResultSetDataType SQLTimeDeserializer(const DriverSocket& input)
     throw (SocketIOException, UnexpectedException)
@@ -154,6 +166,30 @@
   return res;
 }
 
+// Timestamp
+/**
+ */
+ResultSetDataType SQLTimestampDeserializer(const DriverSocket& input)
+    throw (SocketIOException, UnexpectedException)
+{
+  //Timestamp is a long *and* an integer. Make use of our struct to put
+  //both values in it
+  ResultSetDataType res;
+  int64_t time = 0;
+  input>>time;
+  time = ((time/1000)*1000);
+  int32_t nanos = (int)((time%1000) * 1000000);
+  if (nanos < 0)
+  {
+    nanos = 1000000000 + nanos;     
+    time = ((time/1000)-1)*1000;
+  }
+  input>>nanos;
+  res.as_long = time;
+  res.as_int = nanos;
+  return res;
+}
+
 deserializerPtr SQLDataSerialization::getDeserializer(TypeTag ttPrm)
     throw (NotImplementedException, UnexpectedException)
 {
@@ -192,6 +228,8 @@
       return SQLTimeDeserializer;
     break;
     case TT_SQL_TIMESTAMP:
+      return SQLTimestampDeserializer;
+    break;
     case TT_BLOB:
     case TT_JAVA_SERIALIZABLE:
     default:

_______________________________________________
Carob-commits mailing list
[email protected]
https://forge.continuent.org/mailman/listinfo/carob-commits

Reply via email to