I have a Thrift php client and I want to write in a HBase table and I'm doing the following:
$mutations = array(
new Mutation( array(
'column' => 'entry:num',
'value' => array('a','b','c')
) ),
);
$client->mutateRow( $t, $row, $mutations );
The problem is that when inserting in HBase the value, which is an array, gets converted to 'Array' instead of storing the elements of the array. How can I store the list as an array (or byte array)
A HBase mutation object has required three fields with boolean/text values, not arrays. So you need to turn any structured value into a string, something like.
$mutations = array(
new Mutation( array(
'isDelete' => FALSE,
'column' => 'entry:num',
'value' => serialize(array('a','b','c'))
) ),
);
$client->mutateRow( $t, $row, $mutations );
The definition of the HBase Thrift API is here; http://svn.apache.org/viewvc/hbase/trunk/src/main/resources/org/apache/hadoop/hbase/thrift/Hbase.thrift?view=markup
I haven't tested this.
I must admit that I do not have a clue what you're trying to do (perhaps due to a lack of knowledge regarding Thrift and HBase), but if I understood your question correctly, you're trying to write some PHP data structure (array in this case) to a storage media. To achieve this you have to serialize your data somehow. That could be using a custom XML serialization, a custom binary serialization or, perhaps the most simple solution, the PHP internal serialization mechanism provided by serialize()
and the corresponding unserialize()
.
If you strive for inter-language-interoperability you should use a custom serialization or you have to write a unserialization function that unserializes the PHP serialization format in your target language.
Just a quick example - I don't know where you'd have to put this code, as I don't know exactly what you're doing:
$mutations = array(
new Mutation(array(
'column' => 'entry:num',
'value' => array('a','b','c')
)),
);
$data = serialize($mutations); // $data now is a string
// write $data to storage
// read $readData from storage
$readMutations = unserialize($readData);
// $readMutations == $mutations
// (but the Mutation instances are not the same instances any more)
Please seee
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.