use of org.ojai.FieldSegment in project drill by apache.
the class FieldPathHelper method schemaPathToFieldPath.
/**
* Returns {@link FieldPath} equivalent of the specified {@link SchemaPath}.
*
* @param schemaPath {@link SchemaPath} instance that should be converted
* @return {@link FieldPath} equivalent of the specified {@link SchemaPath}.
*/
public static FieldPath schemaPathToFieldPath(SchemaPath schemaPath) {
Deque<PathSegment> pathSegments = Queues.newArrayDeque();
PathSegment pathSegment = schemaPath.getRootSegment();
while (pathSegment != null) {
pathSegments.push(pathSegment);
pathSegment = pathSegment.getChild();
}
FieldSegment child = null;
while (!pathSegments.isEmpty()) {
pathSegment = pathSegments.pop();
if (pathSegment.isNamed()) {
child = new FieldSegment.NameSegment(((PathSegment.NameSegment) pathSegment).getPath(), child, false);
} else {
child = new FieldSegment.IndexSegment(String.valueOf(((PathSegment.ArraySegment) pathSegment).getIndex()), child);
}
}
return new FieldPath((FieldSegment.NameSegment) child);
}
use of org.ojai.FieldSegment in project drill by apache.
the class FieldPathHelper method schemaPath2FieldPath.
/**
* Returns {@link FieldPath} equivalent of the specified {@link SchemaPath}.
*/
public static FieldPath schemaPath2FieldPath(SchemaPath column) {
Stack<PathSegment> pathSegments = new Stack<PathSegment>();
PathSegment seg = column.getRootSegment();
while (seg != null) {
pathSegments.push(seg);
seg = seg.getChild();
}
FieldSegment child = null;
while (!pathSegments.isEmpty()) {
seg = pathSegments.pop();
if (seg.isNamed()) {
child = new FieldSegment.NameSegment(((PathSegment.NameSegment) seg).getPath(), child, false);
} else {
child = new FieldSegment.IndexSegment(((PathSegment.ArraySegment) seg).getIndex(), child);
}
}
return new FieldPath((FieldSegment.NameSegment) child);
}
use of org.ojai.FieldSegment in project drill by axbaretto.
the class FieldPathHelper method schemaPathToFieldPath.
/**
* Returns {@link FieldPath} equivalent of the specified {@link SchemaPath}.
*
* @param schemaPath {@link SchemaPath} instance that should be converted
* @return {@link FieldPath} equivalent of the specified {@link SchemaPath}.
*/
public static FieldPath schemaPathToFieldPath(SchemaPath schemaPath) {
Deque<PathSegment> pathSegments = Queues.newArrayDeque();
PathSegment pathSegment = schemaPath.getRootSegment();
while (pathSegment != null) {
pathSegments.push(pathSegment);
pathSegment = pathSegment.getChild();
}
FieldSegment child = null;
while (!pathSegments.isEmpty()) {
pathSegment = pathSegments.pop();
if (pathSegment.isNamed()) {
child = new FieldSegment.NameSegment(((PathSegment.NameSegment) pathSegment).getPath(), child, false);
} else {
child = new FieldSegment.IndexSegment(String.valueOf(((PathSegment.ArraySegment) pathSegment).getIndex()), child);
}
}
return new FieldPath((FieldSegment.NameSegment) child);
}
use of org.ojai.FieldSegment in project drill by apache.
the class FieldPathHelper method fieldPath2SchemaPath.
/**
* Returns {@link SchemaPath} equivalent of the specified {@link FieldPath}.
*/
public static SchemaPath fieldPath2SchemaPath(FieldPath fieldPath) {
Stack<FieldSegment> fieldSegments = new Stack<FieldSegment>();
FieldSegment seg = fieldPath.getRootSegment();
while (seg != null) {
fieldSegments.push(seg);
seg = seg.getChild();
}
PathSegment child = null;
while (!fieldSegments.isEmpty()) {
seg = fieldSegments.pop();
if (seg.isNamed()) {
child = new PathSegment.NameSegment(((FieldSegment.NameSegment) seg).getName(), child);
} else {
child = new PathSegment.ArraySegment(((FieldSegment.IndexSegment) seg).getIndex(), child);
}
}
return new SchemaPath((PathSegment.NameSegment) child);
}
Aggregations