Skip to content

Commit 9223f51

Browse files
committed
Merge remote-tracking branch 'origin/development' into dev/sharding-squash
2 parents 7adab79 + fd9b715 commit 9223f51

7 files changed

Lines changed: 90 additions & 140 deletions

File tree

src/main/java/org/janelia/saalfeldlab/n5/N5Reader.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,8 @@ <T> T getAttribute(
284284
/**
285285
* Reads a {@link DataBlock}.
286286
*
287+
* @param <T>
288+
* the DataBlock data type
287289
* @param pathName
288290
* dataset path
289291
* @param datasetAttributes
@@ -305,6 +307,8 @@ <T> DataBlock<T> readBlock(
305307
* Implementations may optimize / batch read operations when possible, e.g.
306308
* in the case that the datasets are sharded.
307309
*
310+
* @param <T>
311+
* the DataBlock data type
308312
* @param pathName
309313
* dataset path
310314
* @param datasetAttributes

src/main/java/org/janelia/saalfeldlab/n5/N5Writer.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,6 @@ default void createDataset(
220220
* @param dimensions the dataset dimensions
221221
* @param blockSize the block size
222222
* @param dataType the data type
223-
* @param blockCodecInfo the block codec
224223
* @param compression the compression
225224
*/
226225
default void createDataset(

src/main/java/org/janelia/saalfeldlab/n5/readdata/segment/SegmentedReadData.java

Lines changed: 43 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,14 @@ interface SegmentsAndData {
2424
}
2525

2626
/**
27-
* Wrap {@code readData} and create one segment comprising the entire {@code
27+
* Wrap a {@link ReadData} and create one segment comprising the entire
28+
* {@code
2829
* readData}. The segment can be retrieved as the first (and only) element
2930
* of {@link SegmentedReadData#segments()}.
31+
*
32+
* @param readData
33+
* the ReadData to wrap
34+
* @return the SegmentedReadData
3035
*/
3136
static SegmentedReadData wrap(ReadData readData) {
3237
return new DefaultSegmentedReadData(readData);
@@ -35,8 +40,15 @@ static SegmentedReadData wrap(ReadData readData) {
3540
/**
3641
* Wrap {@code readData} and create segments at the given locations. The
3742
* order of segments in the returned {@link SegmentsAndData#segments()} list
38-
* matches the order of the given {@code locations} (while the {@link
39-
* #segments} in the {@link SegmentsAndData#data()} are ordered by offset).
43+
* matches the order of the given {@code locations} (while the
44+
* {@link #segments} in the {@link SegmentsAndData#data()} are ordered by
45+
* offset).
46+
*
47+
* @param readData
48+
* the ReadData to wrap
49+
* @param locations
50+
* the ranges for segments
51+
* @return the SegmentsAndData
4052
*/
4153
static SegmentsAndData wrap(ReadData readData, Range... locations) {
4254
return wrap(readData, Arrays.asList(locations));
@@ -45,8 +57,15 @@ static SegmentsAndData wrap(ReadData readData, Range... locations) {
4557
/**
4658
* Wrap {@code readData} and create segments at the given locations. The
4759
* order of segments in the returned {@link SegmentsAndData#segments()} list
48-
* matches the order of the given {@code locations} (while the {@link
49-
* #segments} in the {@link SegmentsAndData#data()} are ordered by offset).
60+
* matches the order of the given {@code locations} (while the
61+
* {@link #segments} in the {@link SegmentsAndData#data()} are ordered by
62+
* offset).
63+
*
64+
* @param readData
65+
* the ReadData to wrap
66+
* @param locations
67+
* the ranges for segments
68+
* @return the SegmentsAndData
5069
*/
5170
static SegmentsAndData wrap(ReadData readData, List<Range> locations) {
5271
return DefaultSegmentedReadData.wrap(readData, locations);
@@ -57,41 +76,45 @@ static SegmentsAndData wrap(ReadData readData, List<Range> locations) {
5776
* given {@code readDatas}. The concatenation contains the segments of all
5877
* concatenated {@code readData}s with appropriately offset locations.
5978
* <p>
60-
* In particular, it is also possible to concatenate {@code SegmentedReadData}s
61-
* with (yet) unknown length. (This is useful for postponing compression of
62-
* DataBlocks until they are actually written.) In that case, segment locations
63-
* are only available after all lengths become known. This happens when
64-
* concatenation (or all its constituents) is {@link #materialize()
65-
* materialized} or {@link #writeTo(OutputStream) written}.
79+
* In particular, it is also possible to concatenate
80+
* {@code SegmentedReadData}s with (yet) unknown length. (This is useful for
81+
* postponing compression of DataBlocks until they are actually written.) In
82+
* that case, segment locations are only available after all lengths become
83+
* known. This happens when concatenation (or all its constituents) is
84+
* {@link #materialize() materialized} or {@link #writeTo(OutputStream)
85+
* written}.
86+
*
87+
* @param readDatas
88+
* a list of ReadDatra to concatenate
89+
* @return the SegmentedReadData comprising all the input readDatas
6690
*/
6791
static SegmentedReadData concatenate(List<SegmentedReadData> readDatas) {
6892
return new ConcatenatedReadData(readDatas);
6993
}
7094

71-
72-
7395
/**
7496
* Returns the location of {@code segment} in this {@code ReadData}.
7597
* <p>
76-
* Note that this {@code ReadData} is not necessarily the source of the segment.
98+
* Note that this {@code ReadData} is not necessarily the source of the
99+
* segment.
77100
* <p>
78101
* The returned {@code Range} may be {@code {offset=0, length=-1}}, which
79-
* means that the segment comprises this whole {@code ReadData} (and the length of
80-
* this {@code ReadData} is not yet known).
102+
* means that the segment comprises this whole {@code ReadData} (and the
103+
* length of this {@code ReadData} is not yet known).
81104
*
82105
* @param segment
83-
* the segment id
106+
* the segment id
84107
*
85108
* @return location of the segment, or null
86109
*
87110
* @throws IllegalArgumentException
88-
* if the segment is not contained in this ReadData
111+
* if the segment is not contained in this ReadData
89112
*/
90113
Range location(Segment segment) throws IllegalArgumentException;
91114

92115
/**
93-
* Return all segments (fully) contained in this {@code ReadData}, ordered by location
94-
* (that is, sorted by {@link Range#COMPARATOR}).
116+
* Return all segments (fully) contained in this {@code ReadData}, ordered
117+
* by location (that is, sorted by {@link Range#COMPARATOR}).
95118
*
96119
* @return all segments contained in this {@code ReadData}.
97120
*/

src/main/java/org/janelia/saalfeldlab/n5/shard/PositionValueAccess.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,15 @@
1717
public interface PositionValueAccess {
1818

1919
/**
20-
* @return ReadData for the given key or {@code null} if the key doesn't exist
20+
* Gets the {@link ReadData} for the DataBlock (or shard) at the given
21+
* position in the block (or shard) grid.
22+
*
23+
* @param key
24+
* The position of the data block or shard
25+
* @return ReadData for the given key or {@code null} if the key doesn't
26+
* exist
27+
* @throws N5Exception.N5IOException
28+
* if an error occurs while reading
2129
*/
2230
ReadData get(long[] key) throws N5Exception.N5IOException;
2331

@@ -53,14 +61,9 @@ class KvaPositionValueAccess implements PositionValueAccess {
5361
}
5462

5563
/**
56-
* Constructs the path for a shard or data block at a given
57-
* grid position.
58-
* <br>
59-
* If the gridPosition passed in refers to shard position in a sharded
60-
* dataset, this will return the path to the shard key.
64+
* Constructs the absolute path for a data block (or shard) at a given grid
65+
* position.
6166
*
62-
* @param normalPath
63-
* normalized dataset path
6467
* @param gridPosition
6568
* to the target data block
6669
* @return the absolute path to the data block ad gridPosition

src/main/java/org/janelia/saalfeldlab/n5/shard/RawShard.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,20 @@ public class RawShard {
2626
}
2727

2828
/**
29-
* The ReadData from which the shard was constructed, or {@code null}
30-
* for a new empty shard.
29+
* The ReadData from which the shard was constructed, or {@code null} for a
30+
* new empty shard.
31+
*
32+
* @return this shard's source ReadData, or null.
3133
*/
3234
public SegmentedReadData sourceData() {
3335
return sourceData;
3436
}
3537

3638
/**
37-
* Maps grid position of shard elements to {@link Segment}s.
39+
* Maps grid position of shard elements to {@link Segment}s that give the
40+
* byte range for the blocks in this shard.
41+
*
42+
* @return an NDArray of segments
3843
*/
3944
public NDArray<Segment> index() {
4045
return index;

src/main/java/org/janelia/saalfeldlab/n5/shard/ShardCodecInfo.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,35 @@ public interface ShardCodecInfo extends BlockCodecInfo {
99

1010
/**
1111
* Chunk size of each shard element (either nested shard or DataBlock)
12+
*
13+
* @return the size of each shard element
1214
*/
1315
int[] getInnerBlockSize();
1416

1517
/**
16-
* BlockCodec for shard elements (either nested shard or DataBlock)
18+
* BlockCodecInfo for shard elements (either nested shard or DataBlock)
19+
*
20+
* @return the BlockCodecInfo for DataBlocks in this shard
1721
*/
1822
BlockCodecInfo getInnerBlockCodecInfo();
1923

2024
/**
21-
* DataCodecs for inner BlockCodec
25+
* @return the collection of DataCodecInfos applied to data blocks for this
26+
* shard.
2227
*/
2328
DataCodecInfo[] getInnerDataCodecInfos();
2429

2530
/**
2631
* BlockCodec for shard index
32+
*
33+
* @return the BlockCodecInfo for this shard's index
2734
*/
2835
BlockCodecInfo getIndexBlockCodecInfo();
2936

3037
/**
3138
* Deterministic-size DataCodecs for index BlockCodec
39+
*
40+
* @return the collection of DataCodecInfos for this shard's index
3241
*/
3342
DataCodecInfo[] getIndexDataCodecInfos();
3443

0 commit comments

Comments
 (0)