mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-25 09:02:00 +00:00
Merge branch 'master' of https://github.com/Miniwoffer/ClickHouse
This commit is contained in:
commit
94a2726a93
@ -107,18 +107,10 @@ capnp::StructSchema::Field getFieldOrThrow(capnp::StructSchema node, const std::
|
||||
else
|
||||
throw Exception("Field " + field + " doesn't exist in schema " + node.getShortDisplayName().cStr(), ErrorCodes::THERE_IS_NO_COLUMN);
|
||||
}
|
||||
bool checkEqualFrom(const std::vector<std::string> &a,const std::vector<std::string> &b, const size_t index)
|
||||
{
|
||||
for(int i = index; i >= 0; i++)
|
||||
{
|
||||
if(a[i] != b[i])
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void CapnProtoRowInputStream::createActions(const NestedFieldList & sortedFields, capnp::StructSchema reader)
|
||||
{
|
||||
//Store parents and their tokens in order to backtrack
|
||||
// Store parents and their tokens in order to backtrack
|
||||
std::vector<capnp::StructSchema::Field> parents;
|
||||
std::vector<std::string> tokens;
|
||||
|
||||
@ -126,23 +118,26 @@ void CapnProtoRowInputStream::createActions(const NestedFieldList & sortedFields
|
||||
size_t level = 0;
|
||||
for (const auto & field : sortedFields)
|
||||
{
|
||||
//Backtrackt to common parent
|
||||
while(level > (field.tokens.size()-1) || !checkEqualFrom(tokens,field.tokens,level-1))
|
||||
// Backtrack to common parent
|
||||
while(level > (field.tokens.size() - 1) || !checkEqualFrom(tokens, field.tokens, level - 1))
|
||||
{
|
||||
level--;
|
||||
actions.push_back({Action::POP});
|
||||
tokens.pop_back();
|
||||
parents.pop_back();
|
||||
if(level > 0)
|
||||
|
||||
if (level > 0)
|
||||
{
|
||||
cur_reader = parents[level-1].getType().asStruct();
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
cur_reader = reader;
|
||||
break;
|
||||
}
|
||||
}
|
||||
//Go forward
|
||||
|
||||
// Go forward
|
||||
for (; level < field.tokens.size() - 1; ++level)
|
||||
{
|
||||
|
||||
@ -208,14 +203,7 @@ CapnProtoRowInputStream::CapnProtoRowInputStream(ReadBuffer & istr_, const Block
|
||||
list.push_back(split(header, i));
|
||||
|
||||
// Order list first by value of strings then by length of sting vector.
|
||||
std::sort(list.begin(), list.end(), [](const NestedField & a, const NestedField & b)
|
||||
{
|
||||
size_t min = std::min(a.tokens.size(),b.tokens.size());
|
||||
for(size_t i = 0; i < min; i++)
|
||||
if(a.tokens[i] != b.tokens[i])
|
||||
return a.tokens[i] > b.tokens[i];
|
||||
return a.tokens.size() < b.tokens.size();
|
||||
});
|
||||
std::sort(list.begin(), list.end(), [](const NestedField & a, const NestedField & b) { return a.tokens < b.tokens; });
|
||||
createActions(list, root);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user