/** * Convert fs path to dotted schema path. * /a/b/c -> a.b.c * @param fsPath filesystem path * @return schema path. */ public static String toDottedPath(Path fsPath) { return constructFullPath(toPathComponents(fsPath)); }
public DatasetStateMutator(String username, VirtualDatasetState virtualDatasetState, boolean preview) { super(); this.virtualDatasetState = ProtostuffUtil.copy(virtualDatasetState); this.preview = preview; }
@Override public T fromJson(String v) throws IOException { return ProtostuffUtil.fromJSON(v, schema, false); } }
private void addParents(DocumentWriter writer, List<ParentDataset> parentDatasetList) { if (notEmpty(parentDatasetList)) { final String[] parents = new String[parentDatasetList.size()]; int i = 0; for (ParentDataset parent : parentDatasetList) { parents[i++] = PathUtils.constructFullPath(parent.getDatasetPathList()); } writer.write(DATASET_PARENTS, parents); } }
private static List<String> relativePath(List<String> tableSchemaPath, Path rootPath) { List<String> rootPathComponents = PathUtils.toPathComponents(rootPath); List<String> tablePathComponents = PathUtils.toPathComponents(PathUtils.toFSPathSkipRoot(tableSchemaPath, null)); return tablePathComponents.subList(rootPathComponents.size(), tablePathComponents.size()); } }
public NamespacePath(String path) { this(PathUtils.parseFullPath(path)); }
/** * Resolve given table path relative to source resolve it to a valid path in filesystem. * If the resolved path refers to an entity not under the base of the source then a permission error is thrown. * @param tablePath * @return */ public Path resolveTablePathToValidPath(String tablePath) { String relativePathClean = PathUtils.removeLeadingSlash(tablePath); Path combined = new Path(basePath, relativePathClean); PathUtils.verifyNoAccessOutsideBase(basePath, combined); return combined; }
@Override public String toJson(T v) { return ProtostuffUtil.toJSON(v, schema, false); }
@Override public String apply(String input) { return quoteIdentifier(input); }}; }
public String toUrlEncodedString() { return PathUtils.encodeURIComponent(schemaPath); }
private String quoteLiteral(String value, DataType type) { if (type == DataType.TEXT) { return stringLiteral(value); } else if (type == DataType.DATE) { return "DATE " + stringLiteral(value); } else if (type == DataType.TIME) { return "TIME " + stringLiteral(value); } else if (type == DataType.DATETIME) { return "TIMESTAMP " + stringLiteral(value); } return value; } }
public static String generateInternalId(List<String> path) { return INTERNAL_ID_PREFIX + com.dremio.common.utils.PathUtils.toFSPathString(path); }
/** * empty lists get read back as null * So there is no distinction between null and empty * @param list got from a protos getter * @return whether the list is null or empty */ public static <T> boolean notEmpty(List<T> list) { return !isEmpty(list); }
@Override public Foo newMessage() { return new Foo(); }
/** * Return clone of the sourceConfig * @return */ public SourceConfig getConfig() { return ProtostuffUtil.copy(sourceConfig); }
@Override public byte[] serialize(final T instance) throws IOException { try(final ByteArrayOutputStream out = new ByteArrayOutputStream()) { ProtostuffUtil.toJSON(out, instance, writeSchema, false); return out.toByteArray(); } }
public VirtualDatasetState getNewState() { return copy(newState); } public Set<String> getAddedColumns() {
public TransformActor( VirtualDatasetState initialState, boolean preview, String username, QueryExecutor executor) { super(); this.m = new DatasetStateMutator(username, copy(initialState), preview); this.preview = preview; this.username = username; this.executor = executor; }