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)
-
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 correspondingunserialize()
.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