Hector: how to delete a composite colums inside a row - cassandra

I have composite columns on the column family Tags
RowKey: A
=> (column=B:C, value=432b442b492b4b2b552b582b592b7465787433, timestamp=1338402672044003)
=> (column=C:D, value=442b492b4b2b552b582b592b7465787433, timestamp=1338402672044004)
=> (column=E:T, value=492b582b592b5a2b5a5a2b5a5a5a2b7465787434, timestamp=1338402672049002)
How could I delete in row A, column (C:D) for example
it seems:
Mutator<String> mutator = HFactory.createMutator(ks, se);
mutator.addDeletion(..
takes only 2 arguments the row and the CF

for people interested it's as easy as their creation;
CompositeSerializer ce = new CompositeSerializer();
Composite c = new Composite();
c.add(0, "John");
c.add(1, "Connor");
mutator.addDeletion("key", "MyCF", c, ce);

Related

Formula Language: Select all child documents

id
itemId
correlationId
1
A
2
B
A
3
A
4
C
B
5
D
B
6
E
D
Hello, I have a Notes database with a similar structure like the table above. This table contains a unique id for each document. It also contains an itemId, which is not unique, and a correlationId which creates a relation to another item (itemId).
I want to select all documents, which have a specific itemId (in this example A) and every document which is correlated to this itemId (directly or indirectly). The result should look similar to my table.
I was wondering if I need to write multiple requests or if it is possible to write only one formula.
SELECT #Contains(itemId; "A");
SELECT #Contains(correlationId;"A") => retrieve itemId: B ==>SELECT #Contains(correlationId;"B") => retrieve itemId: C, D ==> SELECT #Contains(correlationId;"C") (no result) and SELECT #Contains(correlationId;"D")

DAX: SUM a data from column C, filtering by column B where relationship is on column A

I need help,
I have to data sources in Excel where table A has a UID and table B has that same UID related many to single (many on table B, the single value on table A).
I want to add all the numerical data in column C on file B but only when column B value is "yes" and show that on table A based on the UID relationship between tables.
You should be able to do this with a SUMX in a calculated column:
YesSumC = SUMX(TableB,
IF(TableB[Column B] = "yes" &&
TableB[UID] = TableA[UID],
TableB[Column C], 0))
Instead of explicitly matching on UID you could also use RELATEDTABLE like this:
YesSumC = SUMX(RELATEDTABLE(TableB),
IF(TableB[Column B] = "yes",
TableB[Column C], 0))

How to see the column names of Dynamic CF in cassandra?

Am trying to get the column names of my column family which are created dynamically.
I created the CF
[default#test] CREATE COLUMN FAMILY blog_entry
WITH comparator = TimeUUIDType
AND key_validation_class=UTF8Type
AND default_validation_class = UTF8Type;
[default#test] show schema;
create column family blog_entry
with column_type = 'Standard'
and comparator = 'TimeUUIDType'
and default_validation_class = 'UTF8Type'
and key_validation_class = 'UTF8Type'
and read_repair_chance = 0.1
and dclocal_read_repair_chance = 0.0
and populate_io_cache_on_flush = false
and gc_grace = 864000
and min_compaction_threshold = 4
and max_compaction_threshold = 32
and replicate_on_write = true
and compaction_strategy = 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy'
and caching = 'KEYS_ONLY'
and compression_options = {'sstable_compression' : 'org.apache.cassandra.io.compress.SnappyCompressor'};
I inserted some data into it with the column names but now how to see my column names?
You have to query row by row to see any column names that aren't declared (by you) in the column metadata. If you want to add columns to the column metadata then you need to alter the column family definition. Cassandra will not automatically do this for you.

how to sort particular columns row in datatable using c#

eg:-
var Rows = (from row in dt1.AsEnumerable()
orderby row["Amount"] descending
select row);
if table like this
RegId Name
101 jone
102 Raj
103 guru
i want output like this using c# DataTable
RegId Name
103 jone
102 Raj
101 guru
i want sort only the regid column rows
So you want to order one column but keep the rest of the column in their old order? Strange requirement, are the columns not related to each other?
However, following code will select the desired column and order it descending. Then the DataTable will be updated with the new values of this column:
List<int> amountsOrdered = dt1.AsEnumerable()
.Select(r => r.Field<int>("Amount"))
.OrderByDescending(i => i)
.ToList();
for (int i = 0; i < dt1.Rows.Count; i++)
dt1.Rows[i].SetField("Amount", amountsOrdered[i]);
Note that the Field extension method is strongly typed what is a good thing. But it can cause an exception if your column's type is string. Then you first need to Parse it to int anyway.
var regIds = dt1.AsEnumerable()
.Cast<DataRow>()
.Select(r => (int)r["Amount"])
.OrderByDescending(id => id)
.ToArray();
for(int i=0; i < dt1.Rows.Count; i++)
{
DataRow row = dt1.Rows[i];
row["Amount"] = regIds[i];
}
Make sure you disable the constraints (if any) on the uniqueness of Amount column of your data table. More info in the documentation page.
if you can use dataview, then you can simple use dataview.sort = "expression"
otherwise i think there is no default option to sort data table, other than looping

Cassandra rangequery, knowing the beginning of start key

Let me clarify it
I have a Column Family, with UTF8 keys like that :apple#NewYork, banana#LosAngeles, banana#NewYork, cherry#NewYork, ... and so on
I need that because they are sorted, and then I would like to get all 'banana' starting keys?
Is it possible or is there a workaround?
How about composite types?
Map your current rows to columns like
row_key => {
banana:a => "value you wish",
banana:b => "value you wish",
...
}
Advantages of composite types are
They preserve type property while sorting
Incase your composite key is a:b:c you can query for all columns in the range of a, a:b and also point queries like a:b:c
Now you can perform Column Slice for example using phpcassa
Ex:
row_key => { 1:a => 1, 1:b => 1, 10:bb => 1, 1:c => 2}
ColumnSlice(array(1), array(1)) => All Columns with first component equal to 1
ColumnSlice(array(1), array(10)) => All Columns with first component between 1 and 10
ColumnSlice("", array(1, 'c')) => All Columns from the beginning of row whose first component less than 1 and second component less than 'c'
You can do the above said things in reverse and can also play with inclusive & exclusive limits.
Also one point to remember, You can't directly ask for all columns in the range of second component < x skipping the first one
Even row keys support composite types but in case you are using random partitioner then it makes no sense.

Resources