From f59af0e666d2659fde3766489d379cfdf59af74e Mon Sep 17 00:00:00 2001 From: Caleb Hulbert Date: Mon, 15 Jul 2024 16:30:14 -0400 Subject: [PATCH] perf: skip file exists for `getAttributes` --- .../org/janelia/saalfeldlab/n5/GsonKeyValueN5Reader.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/janelia/saalfeldlab/n5/GsonKeyValueN5Reader.java b/src/main/java/org/janelia/saalfeldlab/n5/GsonKeyValueN5Reader.java index 080d5df..4e728eb 100644 --- a/src/main/java/org/janelia/saalfeldlab/n5/GsonKeyValueN5Reader.java +++ b/src/main/java/org/janelia/saalfeldlab/n5/GsonKeyValueN5Reader.java @@ -76,11 +76,10 @@ default JsonElement getAttributes(final String pathName) throws N5Exception { final String groupPath = N5URI.normalizeGroupPath(pathName); final String attributesPath = absoluteAttributesPath(groupPath); - if (!getKeyValueAccess().isFile(attributesPath)) - return null; - try (final LockedChannel lockedChannel = getKeyValueAccess().lockForReading(attributesPath)) { return GsonUtils.readAttributes(lockedChannel.newReader(), getGson()); + } catch (final N5Exception.N5NoSuchKeyException e) { + return null; } catch (final IOException | UncheckedIOException e) { throw new N5IOException("Failed to read attributes from dataset " + pathName, e); }