Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated jomezarr API #42

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions modules/HortaTracer/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,12 @@
<dependency>
<groupId>org.aind</groupId>
<artifactId>jomezarr</artifactId>
<version>1.3.2</version>
<version>1.3.3</version>
</dependency>
<dependency>
<groupId>com.bc.zarr</groupId>
<groupId>dev.zarr</groupId>
<artifactId>jzarr</artifactId>
<version>0.3.9</version>
<version>0.4.2</version>
</dependency>
<dependency>
<groupId>edu.ucar</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public OmeZarrBlockTileSource init(String localPath, OmeZarrReaderProgressObserv

this.reader = null;

omeZarrGroup = OmeZarrGroup.open(Paths.get(localPath));
omeZarrGroup = OmeZarrGroupFactory.open(Paths.get(localPath));

return init(progressObserver, completionObserver);
}
Expand All @@ -82,20 +82,20 @@ public OmeZarrBlockTileSource init(TmSample sample, OmeZarrReaderProgressObserve

this.reader = new OmeZarrJadeReader(FileMgr.getFileMgr().getStorageService(), this.sampleOmeZarrTilesBaseDir);

omeZarrGroup = OmeZarrGroup.open(new JadeZarrStoreProvider("", reader));
omeZarrGroup = OmeZarrGroupFactory.open(new JadeZarrStoreProvider("", reader));

return init(progressObserver, completionObserver);
}

private OmeZarrBlockTileSource init(OmeZarrReaderProgressObserver progressObserver, OmeZarrReaderCompletionObserver completionObserver) {
cachedThreadPool.submit(() -> {
int datasetCount = omeZarrGroup.getAttributes().getMultiscales()[0].getDatasets().size();
int datasetCount = omeZarrGroup.getDatasetCount();

boolean haveExtents = false;

for (int idx = datasetCount - 1; idx >= 0; idx--) {
try {
OmeZarrDataset dataset = omeZarrGroup.getAttributes().getMultiscales()[0].getDatasets().get(idx);
OmeZarrDataset dataset = omeZarrGroup.getDataset(idx);

if (this.reader != null) {
dataset.setExternalZarrStore(new JadeZarrStoreProvider(dataset.getPath(), reader));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,57 +1,30 @@
package org.janelia.horta.omezarr;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.TreeSet;
import java.util.stream.Stream;

import org.aind.omezarr.zarr.ExternalZarrStore;

public class JadeZarrStoreProvider extends ExternalZarrStore {

private final OmeZarrJadeReader reader;

public JadeZarrStoreProvider(String prefix, OmeZarrJadeReader reader)
{
public JadeZarrStoreProvider(String prefix, OmeZarrJadeReader reader) {
super(prefix);

this.reader = reader;
}

@Override
public InputStream getInputStream(String s) throws IOException {
return reader.getInputStream(prefix.length() > 0 ? prefix + File.separator + s :s);
}

@Override
public OutputStream getOutputStream(String s) throws IOException {
return null;
}

@Override
public void delete(String s) throws IOException {

public ExternalZarrStore cloneWithPrefix(String prefix) {
return new JadeZarrStoreProvider(prefix, reader);
}

@Override
public TreeSet<String> getArrayKeys() throws IOException {
return null;
}

@Override
public TreeSet<String> getGroupKeys() throws IOException {
return null;
}

@Override
public TreeSet<String> getKeysEndingWith(String s) throws IOException {
return null;
public boolean exists(String s) {
return reader.exists(!prefix.isEmpty() ? prefix + File.separator + s : s);
}

@Override
public Stream<String> getRelativeLeafKeys(String s) throws IOException {
return null;
public InputStream getInputStream(String s) {
return reader.getInputStream(!prefix.isEmpty() ? prefix + File.separator + s : s);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,28 +38,34 @@ public String getBasePath() {
return this.basePath;
}

public boolean exists(String location) {
final Path path = Paths.get(getBasePath(), location);
String relativePath = storageLocation.getRelativePath(path.toString().replace("\\", "/"));
return jadeStorage.exists(storageLocation,relativePath);
}

public InputStream getInputStream(String location) {
final Path path = Paths.get(basePath, location);
final Path path = Paths.get(getBasePath(), location);
String relativePath = storageLocation.getRelativePath(path.toString().replace("\\", "/"));
return jadeStorage.getContent(storageLocation, relativePath);
}

public InputStream getAttributesStream() {
final Path path = Paths.get(basePath, attributesFile);
final Path path = Paths.get(getBasePath(), attributesFile);
String relativePath = storageLocation.getRelativePath(path.toString().replace("\\", "/"));
return jadeStorage.getContent(storageLocation, relativePath);
}

public String[] list(final String pathName) throws IOException {
log.trace("list " + pathName);
final Path path = Paths.get(basePath, pathName);
final Path path = Paths.get(getBasePath(), pathName);
String relativePath = storageLocation.getRelativePath(path.toString());

try (Stream<StorageObject> stream = jadeStorage.getChildren(storageLocation, relativePath).stream()) {
return stream
.filter(a -> a.isCollection())
.filter(StorageObject::isCollection)
.map(a -> path.relativize(Paths.get(a.getAbsolutePath())).toString())
.toArray(n -> new String[n]);
.toArray(String[]::new);
} catch (StorageObjectNotFoundException e) {
throw new RuntimeException(e);
}
Expand Down
Loading