private SchemaEntity getSchemaEntity(FileStatus status, Set<List<String>> tableNames, List<String> p) { SchemaEntityType entityType; if (status.isDirectory()) { if (tableNames.contains(p)) { entityType = SchemaEntityType.FOLDER_TABLE; } else { entityType = SchemaEntityType.FOLDER; } } else { if (tableNames.contains(p)) { entityType = SchemaEntityType.FILE_TABLE; } else { entityType = SchemaEntityType.FILE; } } return new SchemaEntity(PathUtils.getQuotedFileName(status.getPath()), entityType, status.getOwner()); }
private void addToNamespaceTree(NamespaceTree ns, List<SchemaEntity> entities, SourceName source, String prefix) throws IOException, PhysicalDatasetNotFoundException, NamespaceException { for (SchemaEntity entity: entities) { switch (entity.getType()) { case SUBSCHEMA: case FOLDER: SourceFolderPath path = new SourceFolderPath(prefix + "." + entity.getPath()); FolderConfig folderConfig = new FolderConfig(); folderConfig.setFullPathList(path.toPathList()); PhysicalDatasetPath path = new PhysicalDatasetPath(prefix + "." + entity.getPath()); PhysicalDatasetConfig datasetConfig = new PhysicalDatasetConfig(); datasetConfig.setName(path.getFileName().getName()); final SourceFilePath filePath = new SourceFilePath(prefix + '.' + entity.getPath()); final File file = getFileDataset(source, filePath, entity.getOwner()); ns.addFile(file); final SourceFolderPath folderPath = new SourceFolderPath(prefix + "." + entity.getPath()); fileConfig.setOwner(entity.getOwner()); final SourceFilePath path = new SourceFilePath(prefix + '.' + entity.getPath()); addFileToNamespaceTree(ns, source, path, entity.getOwner()); throw new IllegalArgumentException("Invalid SchemaEntity type " + entity.getType());
private CatalogItem convertSchemaEntityToCatalogItem(SchemaEntity entity, List<String> parentPath) { final List<String> entityPath = Lists.newArrayList(parentPath); entityPath.add(entity.getPath()); switch(entity.getType()) { case FILE: { catalogItem = new CatalogItem.Builder() throw new RuntimeException(String.format("Trying to convert unexpected schema entity [%s] of type [%s].", entity.getPath(), entity.getType()));
SchemaEntity schemaEntityFolder1 = new SchemaEntity(com.dremio.common.utils.PathUtils.constructFullPath(folderConfig1.getFullPathList()), SchemaEntity.SchemaEntityType.FOLDER, "testuser"); SchemaEntity schemaEntityFolder2 = new SchemaEntity(com.dremio.common.utils.PathUtils.constructFullPath(folderConfig2.getFullPathList()), SchemaEntity.SchemaEntityType.FOLDER, "testuser");