Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 18 additions & 22 deletions c++/src/TypeImpl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -403,9 +403,6 @@ namespace orc {
case proto::Type_Kind_STRUCT: {
TypeImpl* result = new TypeImpl(STRUCT);
std::unique_ptr<Type> return_value = std::unique_ptr<Type>(result);
uint64_t size = static_cast<uint64_t>(type.subtypes_size());
std::vector<Type*> typeList(size);
std::vector<std::string> fieldList(size);
for(int i=0; i < type.subtypes_size(); ++i) {
result->addStructField(type.fieldnames(i),
convertType(footer.types(static_cast<int>
Expand Down Expand Up @@ -644,57 +641,56 @@ namespace orc {
const std::string &input,
size_t start,
size_t end) {
std::string types = input.substr(start, end - start);
std::vector<std::pair<std::string, ORC_UNIQUE_PTR<Type> > > res;
size_t pos = 0;
size_t pos = start;

while (pos < types.size()) {
while (pos < end) {
size_t endPos = pos;
while (endPos < types.size() && (isalnum(types[endPos]) || types[endPos] == '_')) {
while (endPos < end && (isalnum(input[endPos]) || input[endPos] == '_')) {
++endPos;
}

std::string fieldName;
if (types[endPos] == ':') {
fieldName = types.substr(pos, endPos - pos);
if (input[endPos] == ':') {
fieldName = input.substr(pos, endPos - pos);
pos = ++endPos;
while (endPos < types.size() && isalpha(types[endPos])) {
while (endPos < end && isalpha(input[endPos])) {
++endPos;
}
}

size_t nextPos = endPos + 1;
if (types[endPos] == '<') {
if (input[endPos] == '<') {
int count = 1;
while (nextPos < types.size()) {
if (types[nextPos] == '<') {
while (nextPos < end) {
if (input[nextPos] == '<') {
++count;
} else if (types[nextPos] == '>') {
} else if (input[nextPos] == '>') {
--count;
}
if (count == 0) {
break;
}
++nextPos;
}
if (nextPos == types.size()) {
if (nextPos == end) {
throw std::logic_error("Invalid type string. Cannot find closing >");
}
} else if (types[endPos] == '(') {
while (nextPos < types.size() && types[nextPos] != ')') {
} else if (input[endPos] == '(') {
while (nextPos < end && input[nextPos] != ')') {
++nextPos;
}
if (nextPos == types.size()) {
if (nextPos == end) {
throw std::logic_error("Invalid type string. Cannot find closing )");
}
} else if (types[endPos] != ',' && types[endPos] != '\0') {
} else if (input[endPos] != ',' && endPos != end) {
throw std::logic_error("Unrecognized character.");
}

std::string category = types.substr(pos, endPos - pos);
res.push_back(std::make_pair(fieldName, parseCategory(category, types, endPos + 1, nextPos)));
std::string category = input.substr(pos, endPos - pos);
res.push_back(std::make_pair(fieldName, parseCategory(category, input, endPos + 1, nextPos)));

if (nextPos < types.size() && (types[nextPos] == ')' || types[nextPos] == '>')) {
if (nextPos < end && (input[nextPos] == ')' || input[nextPos] == '>')) {
pos = nextPos + 2;
} else {
pos = nextPos;
Expand Down