Is Clickhouse primary key first row of the granule or not? - clickhouse

I read the clickhouse doc, it seem to be not.
Index entries (index marks) are not based on specific rows from our table but on granules. E.g. for index entry ‘mark 0’ in the diagram above there is no row in our table where UserID is 240.923 and URL is "goal://metry=10000467796a411...", instead, there is a granule 0 for the table where within that granule the minimum UserID vale is 240.923 and the minimum URL value is "goal://metry=10000467796a411..." and these two values are from separate rows.
But by source code primaty key column value is from granule.start_row.
for (const auto & granule : granules_to_write)
{
if (metadata_snapshot->hasPrimaryKey() && granule.mark_on_start)
{
for (size_t j = 0; j < primary_columns_num; ++j)
{
const auto & primary_column = primary_index_block.getByPosition(j);
index_columns[j]->insertFrom(*primary_column.column, granule.start_row);
primary_column.type->getDefaultSerialization()->serializeBinary(*primary_column.column, granule.start_row, *index_stream);
}
}
}
I'm confused,doc is wrong?

Related

Tables in Gherkin

I am trying to compare between two tables and test the results using Gherkin but I don't know how to make it declare two lists in the #when section instead of one, like how it is shown below:
#When("^the integer table :$")
public void the_integer_table_(List<Integer> comp1, List<Integer> comp2) {
for(int i = 0; i < comp1.size(); i++) {
compare[i] = comp1.get(i);
}
for(int i = 0; i < comp2.size(); i++) {
compare2[i] = comp1.get(i);
}
comparer.comparer_tableau( compare, compare2);
}
Here is my .feature file:
Scenario: Compare the elements of two tables and return a boolean table as a result
Given I am starting a comparision operation
When these two integer table are entered :
|1|2|3|4|5|
|0|2|5|4|5|
Then I should see the correct answer is:
|false|true|false|true|true|
Here is what I get when I run it:
#When("^these two integer table two are entered :$") public void these_two_integer_table_two_are_entered_(DataTable arg1) { }
P.S: I did try and look for solutions but didn't find any.
You can change the step definition as given below and get the values of each row then compare it.
#When("^these two integer table are entered :$")
public void these_two_integer_table_are_entered(DataTable arg1) throws Throwable {
List<DataTableRow> lstRows=arg1.getGherkinRows();
Integer[] compare=new Integer[lstRows.get(0).getCells().size()];
System.out.println(compare.length);
Integer[] compare2=new Integer[lstRows.get(1).getCells().size()];
System.out.println(compare2.length);
//Get the first row values
for(int i = 0; i < compare.length; i++) {
compare[i] = Integer.valueOf(lstRows.get(0).getCells().get(i));
System.out.println(compare[i]);
}
//Get the second row values
for(int i = 0; i < compare2.length; i++) {
compare2[i] = Integer.valueOf(lstRows.get(1).getCells().get(i));
System.out.println(compare2[i]);
}
comparer.comparer_tableau( compare, compare2);
}
AFAIK, You can have only one table per step. But can get the each row values inside your definition.
Cucumber will interpret your When step to use one DataTable
When these two integer table are entered :
|1|2|3|4|5|
|0|2|5|4|5|
Instead of trying to enter two tables in one step, try entering them in two separate steps (one table per step) like this:
When the following integer table is entered :
|1|2|3|4|5|
And the following integer table is entered :
|0|2|5|4|5|
I would use a scenario outline like this and handle the log to retrieve values for each column in step definition. (split value string by comma and use values accordingly).
Scenario Outline : Compare the elements of two tables and return a boolean table as a result
Given I am starting a comparision operation
When integer '<table1>' values are entered
When integer '<table2>' values are entered
Then I should see the correct '<answer>'
Examples:
| table1 | table2 | answer |
| 1,2,3,4,5 | 0,2,5,4,5 | false,true,false,true,true |

Looping Down A Column in Google Sheets Using Offset and Subtracting 2 Values in a Cell

I'm writing an inventory management script of Google Sheets. What i need to do...
I'm trying to loop down Column 'A' and check to see if a cell in column 'A' has a value. If that row in Column 'A' does have a value then i want to subtract the Value in Column 'E' from the Value in Column 'A' and then store that result of the difference in Column 'E'. After the program loops all down to the last cell of column A (which is hard coded at 327) then i want all values in Column 'A' to be cleared.
Currently what is happening is the that first row where column 'A' has a value works but after that its all over the place. I think my loop iterations might be wrong but i cant figure it out.
function myFunction4() {
var mySheet = SpreadsheetApp.getActiveSheet();
var high = mySheet.getRange("E10");
var low = mySheet.getRange("A10");
for (var i = 0; i < 327; i++) {
if (low.getValue() == 0 ) {
i = i + 1;
} else {
high = high.offset(i, 0);
low = low.offset(i, 0);
high.setValue(high.getValue() - low.getValue());
}
mySheet.getRange("A10:A328").clearContent();
}
}
Any help would be much appreciated. Trying to get the program to run as fast as possible!

How can I insert a row after the row that is now selected in a sorted table

this is more or less a duplicate of the ones below:
How can i sort java JTable with an empty Row and force the Empty row always be last?
http://www.java.net/node/645655
the only difference is that i would like to insert the new row after the row that is currently selected. the default behavior of DefaultRowSorter would sort immediately when the row is inserted, while what i need is to turn off sorting temporarily so that i could insert the row in a position that i specified, not a position from the sorter
i noticed that there were 2 links provided in How can i sort java JTable with an empty Row and force the Empty row always be last?, but they are not valid anymore, that's why i created this new question.
I copied completely DefaultRowSorter and TableRowSorter from JDK and changed insertInOrder() like below and it seems now working as I expected.
for (int i = 0; i < max; i++) {
if(sortOnInsert)
{
index = Arrays.binarySearch(current, toAdd.get(i));
if (index < 0) {
index = -1 - index;
}
}
else
{
Row rowBeforeAdd = new Row(this, toAdd.get(i).modelIndex - 1);
index = Arrays.binarySearch(current, rowBeforeAdd);
if (index < 0) {
index = viewToModel.length - 1;
}
else
{
index += 1;
}
}

Is there a way to get the column number by column name in jqgrid

I tried to access the rowObject in custom formatter function by column name but it didn't give any values. I have tried this with both JSON and XML data type .
Is there any way to get the column number by column name in jqgrid.
function Draw_Link ( cellvalue , options , rowObject )
{
return "<a href='someurl.php?col_name="+rowobject.col_name+"'>"+cellvalue+"</a>";
}
The column index for the column is the same as the index of the column in the colModel array before the jqGrid initialization (it is the same as in the input parameter colModel). If you use rownumbers:true, multiselect:true or subGrid:true additional columns will be addid to the grid as the first rows, so the column index which one has in the colModel array as the jqGrid parameter can be other as one have after the grid initialization. You can use for example this simple function to get the index
var getColumnSrcIndexByName = function(grid,columnName) {
var cm = grid.jqGrid('getGridParam','colModel'),
i=0, index=0, l=cm.length, cmName;
while (i<l) {
cmName = cm[i].name;
i++;
if (cmName===columnName) {
return index;
} else if (cmName!=='rn' && cmName!=='cb' && cmName!=='subgrid') {
index++;
}
}
return -1;
};
var index = getColumnSrcIndexByName($("#list"),'MyColumn');
UPDATED: Free jqGrid fork simplifies getting column index from column name because it holds internally the parameter iColByName, which is the map by the column name. One can just get iColByName via
var iColByName = $("#list").jqGrid("getGridParam", "iColByName");
and iColByName["MyColumn"] will be the required column index (iCol). I remind that one can use getGridParam without any parameter to get the reference to all parameters of jqGrid:
var p = $("#list").jqGrid("getGridParam");
The value
var iCol = p.iColByName["MyColumn"];
will be the column index and p.colModel[iCol].name will be "MyColumn".

How to iterate through table using selenium?

I have a table called UserManagement that contains information about the user.This table gets updated whenever new user is created. If i create two users then i need check whether two users are actually created or not. Table contains ID,UserName,FirstName,LastName,Bdate..ctc. Here ID will be generated automatically.
I am running Selenium-TestNG script.Using Selenium,how can i get the UserName of the two users which i have created? Should i have to iterate through table? If so how to iterate through the table?
Use ISelenium.GetTable(string) to get the contents of the table cells you want. For example,
selenium.GetTable("UserManagement.0.1");
will return the contents of the table's first row and second column. You could then assert that the correct username or usernames appear in the table.
Get the count of rows using Selenium.getxpathcount(\#id = fjsfj\td\tr") in a variable rowcount
Give the columncount in a variable
Ex:
int colcount = 5;
Give the req i.e New user
String user1 = "ABC"
for(i = 0;i <=rowcount;i++)
{
for(j=0;j<=colcount;j++)
{
if (user1==selenium.gettable("//#[id=dldl/tbody" +i "td"+j))
{
system.out.println(user1 + "Inserted");
break;
}
break;
}
}
Get the number of rows using:
int noOfRowsInTable = selenium.getXpathCount("//table[#id='TableId']//tr");
If the UserName you want to get is at fixed position, let's say at 2nd position, then for each row iterate as given below:
selenium.getText("xpath=//table[#id='TableId']//tr//td[1]");
Note: we can find the number of columns in that table using same procedure
int noOfColumnsInTable = selenium.getXpathCount("//table[#id='TableId']//tr//td");
Generically, something like this?
table = #browser.table(:id,'tableID')
table.rows.each do |row|
# perform row operations here
row.cells.each do |cell|
# do cell operations here
end
end

Resources