3 new revisions:

Revision: be5bd3f75d0f
Author:   gdusbabek <gdusba...@gmail.com>
Date:     Tue Jan 17 08:50:18 2012
Log:      support for FloatTime, patch by Christoph Tavan.
http://code.google.com/a/apache-extras.org/p/cassandra-node/source/detail?r=be5bd3f75d0f

Revision: 15f8f312d037
Author:   gdusbabek <gdusba...@gmail.com>
Date:     Tue Jan 17 09:03:33 2012
Log:      node v4 support for FloatType.
http://code.google.com/a/apache-extras.org/p/cassandra-node/source/detail?r=15f8f312d037

Revision: f76849abc4b8
Author:   Gary Dusbabek <gdusba...@gmail.com>
Date:     Mon Jan 23 09:49:40 2012
Log:      Merge branch '29/floattype'
http://code.google.com/a/apache-extras.org/p/cassandra-node/source/detail?r=f76849abc4b8

==============================================================================
Revision: be5bd3f75d0f
Author:   gdusbabek <gdusba...@gmail.com>
Date:     Tue Jan 17 08:50:18 2012
Log:      support for FloatTime, patch by Christoph Tavan.

http://code.google.com/a/apache-extras.org/p/cassandra-node/source/detail?r=be5bd3f75d0f

Modified:
 /lib/decoder.js

=======================================
--- /lib/decoder.js     Wed Jan 11 09:03:09 2012
+++ /lib/decoder.js     Tue Jan 17 08:50:18 2012
@@ -97,7 +97,7 @@
   TimeUUIDType: 'org.apache.cassandra.db.marshal.TimeUUIDType',
   DateType: 'org.apache.cassandra.db.marshal.DateType',
   //BooleanType: 'org.apache.cassandra.db.marshal.BooleanType',
-  //FloatType: 'org.apache.cassandra.db.marshal.FloatType',
+  FloatType: 'org.apache.cassandra.db.marshal.FloatType',
   //DoubleType: 'org.apache.cassandra.db.marshal.DoubleType',
   //DecimalType: 'org.apache.cassandra.db.marshal.DecimalType',
   CounterColumnType: 'org.apache.cassandra.db.marshal.CounterColumnType',
@@ -120,6 +120,9 @@
   'org.apache.cassandra.db.marshal.DateType': function(bytes) {
     return new Date(+bytesToBigInt(bytes).toString());
   },
+  'org.apache.cassandra.db.marshal.FloatType': function(bytes) {
+    return bytes.readFloatBE(0);
+  },
   'org.apache.cassandra.db.marshal.Int32Type': function(bytes) {
     return bytesToNum(bytes);
   },

==============================================================================
Revision: 15f8f312d037
Author:   gdusbabek <gdusba...@gmail.com>
Date:     Tue Jan 17 09:03:33 2012
Log:      node v4 support for FloatType.

http://code.google.com/a/apache-extras.org/p/cassandra-node/source/detail?r=15f8f312d037

Added:
 /LICENSE_buffer_ieee754.txt
Modified:
 /lib/decoder.js

=======================================
--- /dev/null
+++ /LICENSE_buffer_ieee754.txt Tue Jan 17 09:03:33 2012
@@ -0,0 +1,30 @@
+// Copyright (c) 2008, Fair Oaks Labs, Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// * Redistributions of source code must retain the above copyright notice,
+//    this list of conditions and the following disclaimer.
+//
+// * Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation
+//    and/or other materials provided with the distribution.
+//
+// * Neither the name of Fair Oaks Labs, Inc. nor the names of its contributors
+//    may be used to endorse or promote products derived from this software
+//    without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+// POSSIBILITY OF SUCH DAMAGE.
+//
+//
=======================================
--- /lib/decoder.js     Tue Jan 17 08:50:18 2012
+++ /lib/decoder.js     Tue Jan 17 09:03:33 2012
@@ -18,6 +18,8 @@
 var BigInteger = require('./bigint').BigInteger;
 var UUID = require('./uuid');

+var v6Buffers = require('buffer').Buffer.prototype.readFloatBE ? true : false;
+
// remember: values x such that -2^31 > x or x > 2^31-1 will make this routine puke.
 var bytesToNum = module.exports.bytesToNum = function(bytes) {
   var num = 0;
@@ -105,6 +107,41 @@
//DynamicCompositeType: 'org.apache.cassandra.db.marshal.DynamicCompositeType',
 };

+// source: https://github.com/joyent/node/blob/master/lib/buffer_ieee754.js
+// license: LICENSE_buffer_ieee754.txt
+function readIEEE754(buffer, offset, isBE, mLen, nBytes) {
+  var e, m,
+      eLen = nBytes * 8 - mLen - 1,
+      eMax = (1 << eLen) - 1,
+      eBias = eMax >> 1,
+      nBits = -7,
+      i = isBE ? 0 : (nBytes - 1),
+      d = isBE ? 1 : -1,
+      s = buffer[offset + i];
+
+  i += d;
+
+  e = s & ((1 << (-nBits)) - 1);
+  s >>= (-nBits);
+  nBits += eLen;
+  for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8);
+
+  m = e & ((1 << (-nBits)) - 1);
+  e >>= (-nBits);
+  nBits += mLen;
+  for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8);
+
+  if (e === 0) {
+    e = 1 - eBias;
+  } else if (e === eMax) {
+    return m ? NaN : ((s ? -1 : 1) * Infinity);
+  } else {
+    m = m + Math.pow(2, mLen);
+    e = e - eBias;
+  }
+  return (s ? -1 : 1) * m * Math.pow(2, e - mLen);
+};
+
// These functions convert the raw bytes that cassandra gives us to meaningful
 // JS datat ypes.
 var converters = {
@@ -121,7 +158,8 @@
     return new Date(+bytesToBigInt(bytes).toString());
   },
   'org.apache.cassandra.db.marshal.FloatType': function(bytes) {
-    return bytes.readFloatBE(0);
+    // readFloatBE arrived with Node 0.5. Let's support 0.4.
+ return v6Buffers ? bytes.readFloatBE(0) : readIEEE754(bytes, 0, true, 23, 4);
   },
   'org.apache.cassandra.db.marshal.Int32Type': function(bytes) {
     return bytesToNum(bytes);

==============================================================================
Revision: f76849abc4b8
Author:   Gary Dusbabek <gdusba...@gmail.com>
Date:     Mon Jan 23 09:49:40 2012
Log:      Merge branch '29/floattype'

http://code.google.com/a/apache-extras.org/p/cassandra-node/source/detail?r=f76849abc4b8


Reply via email to