How to get all row column names in cassandra using phpcassa?

I want to get all row column names in cassandra, how can I do this in phpcassa?

If phpcassa does not support it, can any other language libs do this?

In my case, the column names are short, but the rows are long (about 1000 +), the data is large (about 100 thousand)

+4
source share
2 answers

You have a good question. Try something like this:

$pool = new ConnectionPool('feed', array('127.0.0.1')); $raw = $pool->get(); $rows = $raw->client->execute_cql_query("SELECT * FROM posts", cassandra_Compression::NONE); var_dump($rows); 

Perhaps this will help ...

0
source

Do you want to get names directly and only with phpCassa? I don’t know how to do this directly, but I used this by getting the whole row and then executing the foreach loop on the array that I have from the column family, for example:

1.- A small function to use everywhere (create your own if you need;)):

 function f_get_data_as_array($p_pool, $p_cf, $p_key, $p_col_count = 100, $p_column_names = NULL, $p_range_start = '', $p_range_end = '', $p_inverted_sort = false) { try{ $lv_slice = new ColumnSlice($p_range_start, $p_range_end, $p_col_count, p_inverted_sort); $lv_cf = new ColumnFamily($p_pool, $p_cf); $lv_cf->insert_format = ColumnFamily::ARRAY_FORMAT; $lv_cf->return_format = ColumnFamily::ARRAY_FORMAT; $lv_result = $lv_cf->get($p_key, $lv_slice, $p_column_names); }catch(Exception $lv_e) { return false; } return $lv_result; 

2.- I call this using the first four parameters, setting the pool, the name of the column family, the key I need and the number of columns I want to get (specify the number you need).

3.- Run a foreach loop on the returned array to get each column name. Or, if you know the structure that you get from your column family, you just need to use the necessary indexes, perhaps: $ lv_result [0] [0], $ lv_result [0] [1] and so ...

Hope this helps. And sorry for my english!

0
source

Source: https://habr.com/ru/post/1433515/


All Articles