private static FieldPath getFieldPathForProjection(SchemaPath column) { Stack<PathSegment.NameSegment> pathSegments = new Stack<>(); PathSegment seg = column.getRootSegment(); while (seg != null && seg.isNamed()) { pathSegments.push((PathSegment.NameSegment) seg); seg = seg.getChild(); } FieldSegment.NameSegment child = null; while (!pathSegments.isEmpty()) { child = new FieldSegment.NameSegment(pathSegments.pop().getPath(), child, false); } return new FieldPath(child); }
@Override public Void visitSchemaPath(SchemaPath path, StringBuilder sb) throws RuntimeException { PathSegment seg = path.getRootSegment(); if (seg.isArray()) { throw new IllegalStateException("Drill doesn't currently support top level arrays"); } sb.append('`'); sb.append(escapeBackTick(seg.getNameSegment().getPath())); sb.append('`'); while ( (seg = seg.getChild()) != null) { if (seg.isNamed()) { sb.append('.'); sb.append('`'); sb.append(escapeBackTick(seg.getNameSegment().getPath())); sb.append('`'); } else { sb.append('['); sb.append(seg.getArraySegment().getIndex()); sb.append(']'); } } return null; }
/** * 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); }
/** * 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); } }
/** * Traverses path segment to extract named segments, omits all other segments (i.e. array). * Order of named segments appearance will be preserved. * * @param currentSegment current segment * @param resultingSegment resulting segment * @return named segment */ private NameSegment getUnIndexedNameSegment(PathSegment currentSegment, NameSegment resultingSegment) { if (!currentSegment.isLastPath()) { resultingSegment = getUnIndexedNameSegment(currentSegment.getChild(), resultingSegment); } if (currentSegment.isNamed()) { String path = currentSegment.getNameSegment().getPath(); return new NameSegment(path, resultingSegment); } return resultingSegment; }
transformed.add(SchemaPath.getSimplePath(root.getPath())); PathSegment child = root.getChild(); if (child != null && child.isNamed()) { byte[] qualifier = child.getNameSegment().getPath().getBytes(); hbaseScanColumnsOnly.addColumn(family, qualifier);
|| (!field.getRootSegment().isLastPath() && field.getRootSegment().getChild().isLastPath() && field.getRootSegment().getChild().isNamed())
|| (!field.getRootSegment().isLastPath() && field.getRootSegment().getChild().isLastPath() && field.getRootSegment().getChild().isNamed())
private static FieldPath getFieldPathForProjection(SchemaPath column) { Stack<PathSegment.NameSegment> pathSegments = new Stack<>(); PathSegment seg = column.getRootSegment(); while (seg != null && seg.isNamed()) { pathSegments.push((PathSegment.NameSegment) seg); seg = seg.getChild(); } FieldSegment.NameSegment child = null; while (!pathSegments.isEmpty()) { child = new FieldSegment.NameSegment(pathSegments.pop().getPath(), child, false); } return new FieldPath(child); }
@Override public Void visitSchemaPath(SchemaPath path, StringBuilder sb) throws RuntimeException { PathSegment seg = path.getRootSegment(); if (seg.isArray()) { throw new IllegalStateException("Drill doesn't currently support top level arrays"); } sb.append('`'); sb.append(escapeBackTick(seg.getNameSegment().getPath())); sb.append('`'); while ( (seg = seg.getChild()) != null) { if (seg.isNamed()) { sb.append('.'); sb.append('`'); sb.append(escapeBackTick(seg.getNameSegment().getPath())); sb.append('`'); } else { sb.append('['); sb.append(seg.getArraySegment().getIndex()); sb.append(']'); } } return null; }
/** * 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); }
/** * 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); } }
/** * Traverses path segment to extract named segments, omits all other segments (i.e. array). * Order of named segments appearance will be preserved. * * @param currentSegment current segment * @param resultingSegment resulting segment * @return named segment */ private NameSegment getUnIndexedNameSegment(PathSegment currentSegment, NameSegment resultingSegment) { if (!currentSegment.isLastPath()) { resultingSegment = getUnIndexedNameSegment(currentSegment.getChild(), resultingSegment); } if (currentSegment.isNamed()) { String path = currentSegment.getNameSegment().getPath(); return new NameSegment(path, resultingSegment); } return resultingSegment; }
private void add(PathSegment segment){ if(segment.isNamed()){ boolean lastPath = segment.isLastPath(); FieldSelection child = addChild(segment.getNameSegment().getPath()); if (lastPath) { child.setAlwaysValid(); } if (!lastPath && !child.isAlwaysValid()) { child.add(segment.getChild()); } } }
PathSegment seg = path.getRootSegment(); do { if (seg.isNamed()) { segments.add(seg.getNameSegment().getPath());
transformed.add(SchemaPath.getSimplePath(root.getPath())); PathSegment child = root.getChild(); if (child != null && child.isNamed()) { byte[] qualifier = child.getNameSegment().getPath().getBytes(); hbaseScanColumnsOnly.addColumn(family, qualifier);
public static TypedFieldId getFieldIdIfMatchesUnion(UnionVector unionVector, TypedFieldId.Builder builder, boolean addToBreadCrumb, PathSegment seg) { if (seg != null) { if (seg.isNamed()) { ValueVector v = unionVector.getMap(); if (v != null) { return getFieldIdIfMatches(v, builder, addToBreadCrumb, seg); } else { return null; } } else if (seg.isArray()) { ValueVector v = unionVector.getList(); if (v != null) { return getFieldIdIfMatches(v, builder, addToBreadCrumb, seg); } else { return null; } } } else { if (addToBreadCrumb) { builder.intermediateType(unionVector.getField().getType()); } return builder.finalType(unionVector.getField().getType()).build(); } return null; }
|| (!field.getRootSegment().isLastPath() && field.getRootSegment().getChild().isLastPath() && field.getRootSegment().getChild().isNamed())
return getFieldIdIfMatchesUnion((UnionVector) v, builder, addToBreadCrumb, seg.getChild()); } else { if (seg.isNamed()) { if(addToBreadCrumb) { builder.intermediateType(v.getField().getType());