AzureBlobStoreFileSystem extends FileSystem<AzfsResourceId> { @Override protected List<MatchResult> match(List<String> specs) { List<AzfsResourceId> paths = specs.stream().map(AzfsResourceId::fromUri).collect(Collectors.toList()); List<AzfsResourceId> globs = new ArrayList<>(); List<AzfsResourceId> nonGlobs = new ArrayList<>(); List<Boolean> isGlobBooleans = new ArrayList<>(); for (AzfsResourceId path : paths) { if (path.isWildcard()) { globs.add(path); isGlobBooleans.add(true); } else { nonGlobs.add(path); isGlobBooleans.add(false); } } Iterator<MatchResult> globMatches = matchGlobPaths(globs).iterator(); Iterator<MatchResult> nonGlobMatches = matchNonGlobPaths(nonGlobs).iterator(); ImmutableList.Builder<MatchResult> matchResults = ImmutableList.builder(); for (Boolean isGlob : isGlobBooleans) { if (isGlob) { checkState( globMatches.hasNext(), "Internal error encountered in AzureBlobStoreFileSystem: expected more elements in globMatches."); matchResults.add(globMatches.next()); } else { checkState( nonGlobMatches.hasNext(), "Internal error encountered in AzureBlobStoreFileSystem: expected more elements in nonGlobMatches."); matchResults.add(nonGlobMatches.next()); } } checkState( !globMatches.hasNext(), "Internal error encountered in AzureBlobStoreFileSystem: expected no more elements in globMatches."); checkState( !nonGlobMatches.hasNext(), "Internal error encountered in AzureBlobStoreFileSystem: expected no more elements in nonGlobMatches."); return matchResults.build(); } AzureBlobStoreFileSystem(BlobstoreOptions options);   }
@Test @Ignore public void testMatch() throws Exception { String container = "test-container" + randomUUID(); BlobContainerClient blobContainerClient = azureBlobStoreFileSystem.getClient().createBlobContainer(container); List<String> blobNames = new ArrayList<>(); blobNames.add("testdirectory/file1name"); blobNames.add("testdirectory/file2name"); blobNames.add("testdirectory/file3name"); blobNames.add("testdirectory/file4name"); blobNames.add("testdirectory/otherfile"); blobNames.add("testotherdirectory/anotherfile"); for (String blob : blobNames) { blobContainerClient.getBlobClient(blob).uploadFromFile("src/test/resources/in.txt"); } List<String> specs = ImmutableList.of( "azfs: "azfs: "azfs: List<MatchResult> matchResults = azureBlobStoreFileSystem.match(specs); assertEquals(3, matchResults.size()); assertEquals(MatchResult.Status.OK, matchResults.get(0).status()); assertThat( ImmutableList.of( "azfs: "azfs: "azfs: contains(toFilenames(matchResults.get(0)).toArray())); assertEquals(MatchResult.Status.NOT_FOUND, matchResults.get(1).status()); assertEquals(MatchResult.Status.OK, matchResults.get(2).status()); assertThat( ImmutableList.of("azfs: contains(toFilenames(matchResults.get(2)).toArray())); blobContainerClient.delete(); }