Hector Component Equality - cassandra

I was reading the following link, which provides an introduction to composite columns and I had few doubts, specially regarding the usage of ComponentEquality.EQUAL and ComponentEquality.GREATER_THAN_EQUAL.
In the following example:
Composite start = compositeFrom(startArg, Composite.ComponentEquality.EQUAL);
Composite end = compositeFrom(startArg, Composite.ComponentEquality.GREATER_THAN_EQUAL);
start.addComponent(1,"CA",Composite.ComponentEquality.EQUAL);
end.addComponent(1,"CA",Composite.ComponentEquality.GREATER_THAN_EQUAL);
I'm unable to comprehend why the end component needs GREATER_THAN_EQUAL as equality component.
An explanation with example would be really helpful

The way a slice query works in cassandra is that you specify a start column and an end column(limit/isDescending flag too but that is irrelevant here). One way of querying for your use case would be to pass the complete (Composite)column name for the first composite column that starts with US:CA and the last composite column that starts with US:CA. However, you do not know this in advance.
The good thing about slice queries is that the start and end columns do not need to be actual column names. Since column names are always sorted, if the start column in the slice query does not exist, cassandra will start from the next column greater than the start column provided.
So, we need to construct a start column and an end column for your query. As described in the link, a composite object has an e-o-c bit. This bit is used by slice queries.
A composite column has several components. Each component has the e-o-c bit. When a component has this bit set to Equal, Cassandra moves on to look at the next component. When a component has this bit set to GREATER_THAN_EQUAL, Cassandra will keep on looking at columns, until it finds something whose respective component is not equal to the component we are looking for.
So, now consider the example in the link: We want to do a slice query on a column family which has a composite comparator with three components. We want to get all columns where the first component is US and the second component equal to CA.
We have to create a start column and an end column. The start column will have two components(both with EQUAL as e-o-c) and the end column will have first component as EQUAL and the second component as GREATER_THAN_EQUAL. This will match all the columns whose first component is US and second component is CA.
If you set this bit to EQUAL, a slice query will match the first column it finds with start component is equal to 'CA'. This is fine but Cassandra also needs to know the end column for the slice query. For this, it will look at the end composite you provided.
Hope this helped.
EDIT: To make explanation better

Related

identify when values in a column change in spotfire

I am trying to create a calculated column that flags/counts the changes in values across rows in another column, in Spotfire. Below is an example of the data types I'm looking at and the desired results.
My hope is that for each Location, and ordered along Time, I can identify when the values of "colors" changes and have running count so that each cluster of similar values between changes is given the same label (Cluster Desire 1) for each Location. It would be best if the running count of clusters can restart at each location but this is not crucial. Any help would be more than appreciated!
I thought of a way to do it, relying on one intermediate column (I used two just to make it a bit clearer).
First: the concatenation of values for each row within its Location: called [concatString]
Concatenate(Concatenate([Color]) over (Intersect([Location],AllPrevious([Time]))),', ')
Spotfire defaults to comma followed by space as a separator: I could not find a way of changing that in this kind of expression.
Then within each [concatString] I remove repeated values. The complication is that the last one did not have the comma+space, and I did not manage to make the regular expression I am using understand that. So my workaround was to add a final comma+space to [concatString]. Hence the extra Concatenate(..).
The formula for the column without repetitions, [consolidatString] is:
RXReplace([concatString],"(\\w+\,\\s)\\1+","$1","g")
Then what we have achieved is an individual value for each line we want to group. We can then simply rank [consolidatString] to achieve the desired column:
DenseRank([consolidatString],[Location])

Matching Column B with A, and then sorting B with its expanded selection

I have to sets of data.
The first set is just a bunch of IDs.
The second set is the same set of IDs and other data related to each ID.
But the second set of IDs is not in the same order as the first set.
So how do I get the second set to match up in the same order as the first set and also sort the items related to it?
So, here is an unsorted example:
I need to get from that to the following:
Anyone know the simplest way to do this, keeping in mind that the 2nd set has to be sorted along with its relations?
JH
First of all, I don't know if you have any duplicate IDs in the first or second, but we'll cover them anyways.
First, create an enumeration to hold the sort order of what you have in the first table.
=IF(ROW(A2)=2,1,IF(B2=B1,A1,A1+1))
This basically just keeps the order that you have. If it's the first row you're using, give it a 1. If the ID on the current row is the same as the previous (a3 = alpha, a2 = alpha), keep whatever the previous ID was (so that duplicates are enumerated identically). Otherwise, increment the ID.
Then, on your other table, bring over the ID you created with a lookup formula - index match, vlookup both work.
=INDEX($A$2:$A$5, MATCH(E2, $B$2:$B$5, 0))
Finally, just sort the new lookup column on the second table.
Alternatively, you can cut out the first step of enumerating them and just use MATCH on your table 2 IDs to table 1 IDs and it will return the row position that it is in.
=MATCH(id in second table, <array of IDs in first table>, 0)
You can then sort based on that. It may or may not be more intuitive to do it one way or the other.

HLOOKUP/MATCH combination returning incorrect value

I'm attempting to perform a lookup in a table I've created using HLOOKUP to find my column, and MATCH to give me the correct row, which should result in the correct value being posted in my cell.
This is largely the case, however, certain values I'm looking up within the HLOOKUP are producing incorrect results. Specifically they're pulling from on column over.
Here's a smaller version of my table.
--------|CHS |DDR |MWD |MTR |RSS |SUS |WRL |WPS |
UAED |3067110 |3067100 |3067112 |3067102 |3067104 |3067118 |3067116 |3067114 |
MOWD |3075110 |3075100 |3075112 |3075102 |3075104 |3075118 |3075116 3075114 |
My formula is as follows, apologies for the long table references, I'm looking up a table in another file.
=HLOOKUP(S4003,'[UAT_EXT_MatTypes.xlsx]Plant-PL-PrftCntr'!$A$1:$I$72,MATCH(C4003,'[UAT_EXT_MatTypes.xlsx]Plant-PL-PrftCntr'!$A$1:$A$72,0))
S4003 and C4003 are the two values I'm using within my destination table to find the appropriate value in my lookup table. S#### refers to a product line (such as WRL or RSS), while C#### refers to a plant.
The issue I'm having is that whenever I pull a WPS product or an MWD tool, it will pull from the SUS and MTR fields respectively. This does not occur with any other values
For context on how these numbers are derived, the first 4 digits are derived from the plant, while the last 3 are derived by product line.
If anyone has any suggestions as to why this isn't working and how I can fix it, or any alternatives, I'd be very thankful.

How does the new interface method Cassandra::get_paged_slice works and what is its purpose?

In the updated Cassandra thrift interface I found new service method get_paged_slice but it still not described in wiki.
Who can explain me how does it works and what is its purpose?
This method is intended to iterate over all columns of row range. It should be used when the rows are too long, and the method get_range_slices is inconvenient.
The method returns all columns of the row specified by KeyRange, starting from column specified by start_column. If the row ends before collecting enough results, the response is filled up with starting columns of the next row. Next time it should be called with last returned row id and last column name as params.
I suppose, it's not described on wiki, since it's somewhat experimental yet (as of version 1.1.6):
I may only return the whole row, there's no way to specify SlicePredicate;
KeyRange.count is intended to specify row count, and here it's used to specify column count;
There are open bugs in cassandra jira that look severe, for example: https://issues.apache.org/jira/browse/CASSANDRA-4596

JSF 2 : dataTable columnClasses is not replicated after 2 columns

Im using glassfish 3.0.1 and was experimenting with columnClasses in dataTable for the first time.
It's something like this :
<h:dataTable value="#{coreGridBean.heroBeanList}" var="hero"
captionStyle="font-size: 0.95em; font-style:italic"
styleClass="orders"
headerClass="ordersHeader"
footerClass="ordersHeader"
columnClasses="oddColumn,evenColumn">
From the core jsf book im reading, it says that by specifying only 2 classes in the columnClasses attribute, those 2 will be repeated when the column amount is more than 2.
Let's say that i have five columns, the columnClasses would become something like oddColumn,evenColumn,oddColumn,evenColumn,oddColumn, and we just need to define it like this : columnClasses="oddColumn,evenColumn"
But in my experience with 3 columns, it's not like this. From the third column they got no classes. I had to specify columnClasses="oddColumn,evenColumn,oddColumn" to make it work
Is this a bug or i just have a bad error ?
The repetition only applies on rowClasses.
From the JSF 2.0 h:dataTable tag documentation:
columnClasses
Comma-delimited list of CSS style classes that will be applied to the columns of this table. A space separated list of classes may also be specified for any individual column. If the number of elements in this list is less than the number of actual column children of the UIData, no "class" attribute is output for each column greater than the number of elements in the list. If the number of elements in the list is greater than the number of actual column children of the UIData, the elements at the posisiton in the list after the last column are ignored.
rowClasses
Comma-delimited list of CSS style classes that will be applied to the rows of this table. A space separated list of classes may also be specified for any individual row. Thes styles are applied, in turn, to each row in the table. For example, if the list has two elements, the first style class in the list is applied to the first row, the second to the second row, the first to the third row, the second to the fourth row, etc. In other words, we keep iterating through the list until we reach the end, and then we start at the beginning again.
Maybe the book was wrong, or you misread the book.
Since the column number is usually always fixed in the view definition anyway, it's little effort to just repeat them yourself.
<h:dataTable columnClasses="oddColumn,evenColumn,oddColumn,evenColumn">
<h:column></h:column>
<h:column></h:column>
<h:column></h:column>
<h:column></h:column>
</h:dataTable>

Resources