Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/apache-spark/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache spark 如何使用put和get将list[String]list[(String,Int)]存储和检索到mapr/hbase表中_Apache Spark_Hbase_Mapr - Fatal编程技术网

Apache spark 如何使用put和get将list[String]list[(String,Int)]存储和检索到mapr/hbase表中

Apache spark 如何使用put和get将list[String]list[(String,Int)]存储和检索到mapr/hbase表中,apache-spark,hbase,mapr,Apache Spark,Hbase,Mapr,商业案例: 我需要为特定的行键保留对象的数组/列表。 例如,kwy r1行的c1列的模式为List,值为((“第一”,1),(“第二”,2)),另一列的c2列的模式为Array,值为(“a”,“b”,“c”) 现在我需要将这些信息保存到HBase/MapR二进制表中。 我以前把它当作 Put put = new Put("r1".getBytes) 我列出了数组类型的“list1” 另一个Listsaylist2=(“a”、“b”、“c”) 我们使用hTable.batch api将数据持久化

商业案例:

我需要为特定的行键保留对象的数组/列表。 例如,kwy r1行的c1列的模式为
List
,值为((“第一”,1),(“第二”,2)),另一列的c2列的模式为
Array
,值为(“a”,“b”,“c”)

现在我需要将这些信息保存到HBase/MapR二进制表中。 我以前把它当作

Put put = new Put("r1".getBytes)
我列出了
数组类型的“list1”

另一个
List
say
list2=(“a”、“b”、“c”)

我们使用hTable.batch api将数据持久化到hbase/mapr中

与在MapR中一样,每个属性都以二进制形式存储,没有任何模式信息,虽然我也有模式,并尝试使用模式读取,但仍然无法从MapR中获取列表/集合数据,即
list
或simple
list
,最后它以字符串形式出现,需要使用

使用scan或get时,它将以字符串格式返回所有内容,而我们不会使用schema获取元素值


有人能帮我解决吗。

你在用java吗?不会
list.toString
只返回类的名称吗?实际上我使用的是scala,但它直接包含一些对象集合,需要从MapR DB存储和检索。根据您的建议,如果我不使用toString,那么如何将对象集合转换为字节[],我知道可以使用ObjectOutputStream,但您能否提供一些示例或示例代码,因为不确定这是否也有效。
byte[] colValue1 =list1.toString.getBytes

put.addColumn("columnFamily".getBytes, "c1".getBytes, colValue1);
byte[] colValue2 = list2.toString().getBytes
put.addColumn("columnFamily".getBytes, "c1".getBytes, colValue1);