如何将Cassandra结果集转换为java对象或数组列表

时间:2017-08-11 11:31:54

标签: java json cassandra

您好朋友我有复杂的问题,请帮我解决一下,让我解释一下问题:

  

Cassandra表

DeviceID | companyId | data |
abc123   : xyz1      :{"Temperature":{"x":"67.824"},"Humidity":117.828,"vibration":{"y":"2.276","x":"72.995"},"date":1487641956515}
  

“日期列数据类型为文本”

现在我正在尝试使用此查询在java中获取数据

ResultSet results = inSession.execute("SELECT data from keyspace.tablename where companyid = 4d91f767-2312-4f32-a25a-4674e8bae244 limit 24");

并像这样成功获取数据......

{"Temperature":{"x":"67.824"},"Humidity":117.828,"vibration":{"y":"2.276","x":"72.995"},"date":1487641956515}{"Temperature":{"x":"73.981"},"Humidity":58.561,"vibration":{"y":"87.482","x":"87.131"},"date":1487641951512}{"Temperature":{"x":"62.747"},"Humidity":88.611,"vibration":{"y":"137.792","x":"36.363"},"date":1487641946512}{"Temperature":{"x":"36.072"},"Humidity":55.819,"vibration":{"y":"60.062","x":"2.779"},"date":1487641941508}{"Temperature":{"x":"36.724"},"Humidity":68.209,"vibration":{"y":"49.323","x":"64.822"},"date":1487641936507}{"Temperature":{"x":"31.777"},"Humidity":131.955,"vibration":{"y":"68.690","x":"6.737"},"date":1487641931503}{"Temperature":{"x":"41.768"},"Humidity":81.847,"vibration":{"y":"74.360","x":"60.438"},"date":1487641926499}{"Temperature":{"x":"49.538"},"Humidity":57.258,"vibration":{"y":"34.688","x":"81.397"},"date":1487641921496}{"Temperature":{"x":"98.013"},"Humidity":61.1,"vibration":{"y":"121.482","x":"93.721"},"date":1487641916492}{"Temperature":{"x":"98.307"},"Humidity":63.377,"vibration":{"y":"106.067","x":"98.968"},"date":1487641911487}{"Temperature":{"x":"92.119"},"Humidity":70.677,"vibration":{"y":"66.953","x":"59.440"},"date":1487641906481}{"Temperature":{"x":"41.627"},"Humidity":73.739,"vibration":{"y":"54.557","x":"82.876"},"date":1487641901475}{"Temperature":{"x":"74.684"},"Humidity":125.163,"vibration":{"y":"77.522","x":"96.560"},"date":1487641896471}{"Temperature":{"x":"50.228"},"Humidity":53.3,"vibration":{"y":"58.011","x":"26.710"},"date":1487641891468}{"Temperature":{"x":"61.710"},"Humidity":75.869,"vibration":{"y":"67.637","x":"69.842"},"date":1487641886465}{"Temperature":{"x":"61.908"},"Humidity":43.106,"vibration":{"y":"6.975","x":"15.009"},"date":1487641881461}{"Temperature":{"x":"75.157"},"Humidity":61.452,"vibration":{"y":"39.608","x":"58.490"},"date":1487826732069}{"Temperature":{"x":"77.562"},"Humidity":65.951,"vibration":{"y":"102.782","x":"24.761"},"date":1487826731069}{"Temperature":{"x":"60.483"},"Humidity":57.307,"vibration":{"y":"96.702","x":"86.667"},"date":1487826730068}{"Temperature":{"x":"85.893"},"Humidity":58.953,"vibration":{"y":"49.167","x":"86.790"},"date":1487826729067}{"Temperature":{"x":"84.073"},"Humidity":142.27,"vibration":{"y":"94.980","x":"65.363"},"date":1487826728065}{"Temperature":{"x":"81.733"},"Humidity":145.871,"vibration":{"y":"81.889","x":"57.215"},"date":1487826727064}{"Temperature":{"x":"41.944"},"Humidity":139.18,"vibration":{"y":"62.525","x":"74.986"},"date":1487826726063}{"Temperature":{"x":"85.298"},"Humidity":80.534,"vibration":{"y":"47.796","x":"74.527"},"date":1487826725062}

现在我的问题是我需要使用键值创建列表或数组,意味着  温度[24]或温度等级列表,是否可能???怎么样 ???

0 个答案:

没有答案