Permalink
Browse files

add double and float column support

  • Loading branch information...
Brian Guarraci
Brian Guarraci committed Oct 24, 2012
1 parent b449f32 commit 76bba8a0961a6899d461d6bd4e67e4d488fb1750
Binary file not shown.
@@ -22,23 +22,21 @@
}
},
{
- "name": "glu",
+ "name": "cloudcmd",
"dimensions": 12,
"fields": {
- "agent": 6,
- "metadata.container.kind": 2,
- "metadata.container.name": 2,
- "mountPoint": 2
+ "fileext": 4,
+ "path": 2,
+ "filename": 6
}
},
{
- "name": "cloudcmd",
+ "name": "stocks",
"dimensions": 12,
"fields": {
- "fileext": 4,
- "path": 2,
- "filename": 6
+ "symbol": 6,
+ "date": 6
}
}
]
-}
+}
@@ -213,7 +213,10 @@ object Node {
val ids = node.insert(projection, jsonRecords)
JsonUtil.jsonResponse("id", JsonUtil.toJsonArray(ids))
} catch {
- case e: IllegalArgumentException => return new StatusResponse(HttpResponseStatus.BAD_REQUEST)
+ case e: IllegalArgumentException => {
+ e.printStackTrace()
+ return new StatusResponse(HttpResponseStatus.BAD_REQUEST)
+ }
}
}
})
@@ -158,9 +158,12 @@ class H2IndexStorage(configRoot: String) extends IndexStorage {
colType = "LONG"
} else if (colVal.isInstanceOf[Int]) {
colType = "LONG"
+ } else if (colVal.isInstanceOf[Float] || colVal.isInstanceOf[Double]) {
+ colType = "DOUBLE"
} else if (colVal.isInstanceOf[Boolean]) {
colType = "BOOLEAN"
} else {
+ H2IndexStorage.log.error("unknown filed type: " + colVal.getClass.getName)
H2IndexStorage.log.info(colName + " " + colVal.getClass.toString)
throw new IllegalArgumentException("unknown obj type: " + colVal.getClass.toString)
}
@@ -196,10 +199,16 @@ class H2IndexStorage(configRoot: String) extends IndexStorage {
statement.setLong(idx, obj.asInstanceOf[Long])
} else if (obj.isInstanceOf[Int]) {
statement.setInt(idx, obj.asInstanceOf[Int])
+ } else if (obj.isInstanceOf[Float]) {
+ statement.setFloat(idx, obj.asInstanceOf[Float])
+ } else if (obj.isInstanceOf[Double]) {
+ statement.setDouble(idx, obj.asInstanceOf[Double])
} else if (obj.isInstanceOf[Boolean]) {
statement.setBoolean(idx, obj.asInstanceOf[Boolean])
} else {
- throw new IllegalArgumentException("unknown obj type: " + obj.toString)
+ val msg = "unknown obj type: " + obj.toString
+ H2IndexStorage.log.error(msg)
+ throw new IllegalArgumentException(msg)
}
}

0 comments on commit 76bba8a

Please sign in to comment.