public NamespacePath(RootEntity root, List<FolderName> folderPath, LeafEntity leaf) { this.root = root; this.folderPath = folderPath; this.leaf = leaf; this.namespaceKey = new NamespaceKey(createPathList()); }
public ResourceTreeEntity(SpaceConfig spaceConfig) throws UnsupportedEncodingException { this.type = ResourceType.SPACE; this.name = spaceConfig.getName(); this.fullPath = Collections.singletonList(this.name); this.url = "/resourcetree/" + new NamespaceKey(this.fullPath).toUrlEncodedString(); }
public List<ResourceTreeEntity> getHomes(boolean all) throws NamespaceException, UnsupportedEncodingException { final List<ResourceTreeEntity> resources = Lists.newArrayList(); if (all) { for (HomeConfig homeConfig : namespaceService.get().getHomeSpaces()) { resources.add(new ResourceTreeEntity(homeConfig)); } } else { resources.add(new ResourceTreeEntity(namespaceService.get().getHome( new NamespaceKey(HomeName.getUserHomePath(securityContext.getUserPrincipal().getName()).getName())))); } return resources; }
private Optional<CatalogItem> getInternalItemByPath(List<String> path) throws NamespaceException { NameSpaceContainer rootEntity = getNamespaceEntity(new NamespaceKey(path.get(0))); if (rootEntity != null && rootEntity.getType() == NameSpaceContainer.Type.SOURCE) { return Optional.of(getInternalItemFromSource(rootEntity.getSource(), path)); } else { logger.warn("Can not find internal item with path [%s].", path); return Optional.absent(); } }
@Override public DremioCatalogReader withSchemaPath(List<String> newNamespacePath) { NamespaceKey withSchemaPath = newNamespacePath == null ? null : new NamespaceKey(newNamespacePath); return new DremioCatalogReader(catalog.resolveCatalog(withSchemaPath), typeFactory); }
public ResourceTreeEntity(FolderConfig folderConfig) throws UnsupportedEncodingException { this.type = ResourceType.FOLDER; this.name = folderConfig.getName(); this.fullPath = folderConfig.getFullPathList(); this.url = "/resourcetree/" + new NamespaceKey(this.fullPath).toUrlEncodedString(); }
@Override public List<ReflectionGoal> getRecommendedReflections(String datasetId) { DatasetConfig datasetConfig = namespaceService.get().findDatasetByUUID(datasetId); if (datasetConfig == null) { throw new NotFoundException("Dataset not found"); } ReflectionAnalyzer analyzer = new ReflectionAnalyzer(jobsService.get(), catalogService.get()); TableStats tableStats = analyzer.analyze(new NamespaceKey(datasetConfig.getFullPathList())); ReflectionSuggester suggester = new ReflectionSuggester(datasetConfig, tableStats); return suggester.getReflectionGoals(); }
@Override public Iterable<SourceTableDefinition> getDatasets(String user, DatasetRetrievalOptions ignored) throws Exception { try (Admin admin = connection.getConnection().getAdmin()) { return FluentIterable.of(admin.listTableNames()).transform(new Function<TableName, SourceTableDefinition>(){ @Override public SourceTableDefinition apply(TableName input) { final NamespaceKey key = new NamespaceKey(ImmutableList.<String>of(name, input.getNamespaceAsString(), input.getQualifierAsString())); return new HBaseTableBuilder(key, null, connection, storeConfig.isSizeCalcEnabled, context); }}); } }
@Override public RelNode visit(TableScan tableScan) { List<String> tablePath = tableScan.getTable().getQualifiedName(); final AccelerationSettings settings = reflectionSettings.getReflectionSettings(new NamespaceKey(tablePath)); refreshField.value = settings.getRefreshField(); return tableScan; } });
public static Map<String, NameSpaceContainer> listHome(NamespaceService ns, String parent) throws Exception { Map<String, NameSpaceContainer> children = new HashMap<>(); for (NameSpaceContainer container : ns.list(new NamespaceKey(parent))) { children.put(PathUtils.constructFullPath(container.getFullPathList()), container); } return children; }
public static TableWithPath verify(final Catalog catalog, SqlIdentifier identifier){ NamespaceKey path = catalog.resolveSingle(new NamespaceKey(identifier.names)); DremioTable table = catalog.getTable(path); if(table == null) { throw UserException.parseError().message("Unable to find table %s.", path).build(logger); } return new TableWithPath(table); }
public void createPhysicalDataset(SourceFolderPath folderPath, PhysicalDatasetConfig datasetConfig) throws NamespaceException { createCatalog().createOrUpdateDataset( namespaceService, new NamespaceKey(folderPath.getSourceName().getName()), new PhysicalDatasetPath(folderPath).toNamespaceKey(), toDatasetConfig(datasetConfig, null)); }
@Test public void testByPath() throws Exception { Source createdSource = createSource(); // test getting a source by name Source source = expectSuccess(getBuilder(getPublicAPI(3).path(CATALOG_PATH).path("by-path").path(createdSource.getName())).buildGet(), new GenericType<Source>() {}); assertEquals(source.getId(), createdSource.getId()); // test getting a folder by path expectSuccess(getBuilder(getPublicAPI(3).path(CATALOG_PATH).path("by-path").path(createdSource.getName()).path("json")).buildGet(), new GenericType<Folder>() {}); // test getting a file with a url character in name (?) expectSuccess(getBuilder(getPublicAPI(3).path(CATALOG_PATH).path("by-path").path(createdSource.getName()).path("testfiles").path("file_with_?.json")).buildGet(), new GenericType<File>() {}); newNamespaceService().deleteSource(new NamespaceKey(source.getName()), source.getTag()); }
@Test public void testDeleteFolder() throws Exception { Folder folder = new Folder("folder-id", Arrays.asList("source", "folder"), "1", null); NameSpaceContainer namespaceContainer = new NameSpaceContainer(); namespaceContainer.setFolder(CatalogServiceHelper.getFolderConfig(folder)); namespaceContainer.setType(NameSpaceContainer.Type.FOLDER); when(namespaceService.getEntityById(folder.getId())).thenReturn(namespaceContainer); catalogServiceHelper.deleteCatalogItem(folder.getId(), folder.getTag()); verify(namespaceService, times(1)).deleteFolder(new NamespaceKey(folder.getPath()), folder.getTag()); }
@AfterClass public static void after() throws Exception { NamespaceService namespaceService = newNamespaceService(); NamespaceKey namespaceKey = new NamespaceKey("searchSpace"); namespaceService.deleteSpace(namespaceKey, namespaceService.getSpace(namespaceKey).getTag()); }
@BeforeClass public static void init() throws Exception { BaseTestServer.init(); // setup space NamespaceKey key = new NamespaceKey("dsvTest"); SpaceConfig spaceConfig = new SpaceConfig(); spaceConfig.setName("dsvTest"); newNamespaceService().addOrUpdateSpace(key, spaceConfig); }
@AfterClass public static void shutdown() throws Exception { // setup space NamespaceKey key = new NamespaceKey("dsvTest"); SpaceConfig space = newNamespaceService().getSpace(key); newNamespaceService().deleteSpace(key, space.getTag()); }
@Test public void testSourceBrowsing() throws Exception { Source source = createSource(); // browse to the json directory String id = getFolderIdByName(source.getChildren(), "\"json\""); assertNotNull(id, "Failed to find json directory"); // deleting a folder on a source should fail expectStatus(Response.Status.BAD_REQUEST, getBuilder(getPublicAPI(3).path(CATALOG_PATH).path(com.dremio.common.utils.PathUtils.encodeURIComponent(id))).buildDelete()); newNamespaceService().deleteSource(new NamespaceKey(source.getName()), source.getTag()); }
@AfterClass public static void removeMiniDfsBasedStorage() throws Exception { SourceConfig config = getSabotContext().getNamespaceService(SystemUser.SYSTEM_USERNAME).getSource(new NamespaceKey(MINIDFS_STORAGE_PLUGIN_NAME)); ((CatalogServiceImpl) getSabotContext().getCatalogService()).getSystemUserCatalog().deleteSource(config); stopMiniDfsCluster(); } }
public static void addDS(NamespaceService ns, String name) throws Exception { final NamespaceKey dsPath = new NamespaceKey(PathUtils.parseFullPath(name)); final DatasetConfig ds = new DatasetConfig(); final VirtualDataset vds = new VirtualDataset(); vds.setVersion(DatasetVersion.newVersion()); ds.setType(DatasetType.VIRTUAL_DATASET); ds.setVirtualDataset(vds); ds.setFullPathList(dsPath.getPathComponents()); ds.setName(dsPath.getName()); ns.addOrUpdateDataset(dsPath, ds); }