Skip to content

Commit c8aa6e8

Browse files
committed
style: Zarr3DatasetAttributes use "dimensions" and "size"
* instead of "shape"
1 parent b1fb6dd commit c8aa6e8

1 file changed

Lines changed: 46 additions & 46 deletions

File tree

src/main/java/org/janelia/saalfeldlab/n5/zarr/v3/ZarrV3DatasetAttributes.java

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -97,49 +97,49 @@ public class ZarrV3DatasetAttributes extends DatasetAttributes implements ZarrV3
9797
protected transient final byte[] fillBytes;
9898

9999
public ZarrV3DatasetAttributes(
100-
final long[] shape,
100+
final long[] dimensions,
101101
int[] blockSize,
102102
DataType dataType,
103103
final Compression compression) {
104104

105105
this(
106-
shape,
106+
dimensions,
107107
defaultChunkAttributes(blockSize),
108108
ZarrV3DataType.fromDataType(dataType),
109109
"0", // default fill value
110-
defaultDimensionNames(shape.length),
110+
defaultDimensionNames(dimensions.length),
111111
null,
112112
null,
113113
ZarrV3Compressor.fromCompression(compression));
114114
}
115115

116116
public ZarrV3DatasetAttributes(
117-
final long[] shape,
117+
final long[] dimensions,
118118
int[] shardSize,
119119
int[] blockSize,
120120
DataType dataType,
121121
final DataCodecInfo... dataCodecs) {
122122

123123
this(
124-
shape,
124+
dimensions,
125125
defaultChunkAttributes(shardSize),
126126
ZarrV3DataType.fromDataType(dataType),
127127
"0", // default fill value
128-
defaultDimensionNames(shape.length),
128+
defaultDimensionNames(dimensions.length),
129129
defaultShardCodecInfo(blockSize, dataCodecs),
130130
null);
131131
}
132132

133133
public ZarrV3DatasetAttributes(
134-
final long[] shape,
134+
final long[] dimensions,
135135
int[] shardSize,
136136
int[] blockSize,
137137
DataType dataType,
138138
String[] dimensionNames,
139139
final DataCodecInfo... dataCodecs) {
140140

141141
this(
142-
shape,
142+
dimensions,
143143
defaultChunkAttributes(shardSize),
144144
ZarrV3DataType.fromDataType(dataType),
145145
"0", // default fill value
@@ -149,26 +149,26 @@ public ZarrV3DatasetAttributes(
149149
}
150150

151151
public ZarrV3DatasetAttributes(
152-
final long[] shape,
152+
final long[] dimensions,
153153
int[] blockSize,
154154
DataType dataType,
155155
String fillValue,
156156
String[] dimensionNames,
157157
final DataCodecInfo... dataCodecs) {
158158

159159
this(
160-
shape,
160+
dimensions,
161161
defaultChunkAttributes(blockSize),
162162
ZarrV3DataType.fromDataType(dataType),
163163
fillValue,
164-
defaultDimensionNames(shape.length),
164+
defaultDimensionNames(dimensions.length),
165165
null,
166166
null,
167167
dataCodecs);
168168
}
169169

170170
public ZarrV3DatasetAttributes(
171-
final long[] shape,
171+
final long[] dimensions,
172172
int[] shardSize,
173173
int[] blockSize,
174174
DataType dataType,
@@ -177,7 +177,7 @@ public ZarrV3DatasetAttributes(
177177
final DataCodecInfo... dataCodecs) {
178178

179179
this(
180-
shape,
180+
dimensions,
181181
defaultChunkAttributes(shardSize),
182182
ZarrV3DataType.fromDataType(dataType),
183183
fillValue,
@@ -187,7 +187,7 @@ public ZarrV3DatasetAttributes(
187187
}
188188

189189
public ZarrV3DatasetAttributes(
190-
final long[] shape,
190+
final long[] dimensions,
191191
final ChunkAttributes chunkAttributes,
192192
final ZarrV3DataType zarrDataType,
193193
final String fillValue,
@@ -196,7 +196,7 @@ public ZarrV3DatasetAttributes(
196196
final DatasetCodecInfo[] datasetCodecInfos,
197197
final DataCodecInfo... dataCodecInfos) {
198198

199-
super(shape,
199+
super(dimensions,
200200
chunkAttributes.getGrid().getShape(),
201201
zarrDataType.getDataType(),
202202
toJson(fillValue),
@@ -211,7 +211,7 @@ public ZarrV3DatasetAttributes(
211211
}
212212

213213
public ZarrV3DatasetAttributes(
214-
final long[] shape,
214+
final long[] dimensions,
215215
final int[] chunkShape,
216216
final ZarrV3DataType dataType,
217217
final String fillValue,
@@ -221,12 +221,12 @@ public ZarrV3DatasetAttributes(
221221
final DatasetCodecInfo[] datasetCodecInfos,
222222
final DataCodecInfo... dataCodecInfos) {
223223

224-
this(shape, new ChunkAttributes(new RegularChunkGrid(chunkShape), chunkKeyEncoding), dataType, fillValue,
224+
this(dimensions, new ChunkAttributes(new RegularChunkGrid(chunkShape), chunkKeyEncoding), dataType, fillValue,
225225
dimensionNames, blockCodecInfo, datasetCodecInfos, dataCodecInfos );
226226
}
227227

228228
public ZarrV3DatasetAttributes(
229-
final long[] shape,
229+
final long[] dimensions,
230230
final int[] chunkShape,
231231
final ZarrV3DataType dataType,
232232
final String fillValue,
@@ -236,7 +236,7 @@ public ZarrV3DatasetAttributes(
236236
final DatasetCodecInfo[] datasetCodecInfos,
237237
final DataCodecInfo... dataCodecInfos) {
238238

239-
this(shape, chunkShape, dataType, fillValue, dimensionNames,
239+
this(dimensions, chunkShape, dataType, fillValue, dimensionNames,
240240
new DefaultChunkKeyEncoding(dimensionSeparator), blockCodecInfo, datasetCodecInfos, dataCodecInfos);
241241
}
242242

@@ -334,7 +334,7 @@ public static ZarrV3DatasetAttributes from(final DatasetAttributes datasetAttrib
334334
if (datasetAttributes instanceof ZarrV3DatasetAttributes)
335335
return (ZarrV3DatasetAttributes)datasetAttributes;
336336

337-
final long[] shape = datasetAttributes.getDimensions().clone();
337+
final long[] dimensions = datasetAttributes.getDimensions().clone();
338338
final int[] chunkShape = datasetAttributes.getChunkSize().clone();
339339

340340
// TODO this may not be correct when sharding?
@@ -343,8 +343,8 @@ public static ZarrV3DatasetAttributes from(final DatasetAttributes datasetAttrib
343343
new DefaultChunkKeyEncoding(dimensionSeparator));
344344

345345
final ZarrV3DataType dType = ZarrV3DataType.fromDataType(datasetAttributes.getDataType());
346-
return new ZarrV3DatasetAttributes(shape, chunkAttrs,
347-
dType, fillValue, defaultDimensionNames(shape.length),
346+
return new ZarrV3DatasetAttributes(dimensions, chunkAttrs,
347+
dType, fillValue, defaultDimensionNames(dimensions.length),
348348
replaceBlockCodec(datasetAttributes.getBlockCodecInfo(), dType, fillValue),
349349
null, // dataset codecs
350350
datasetAttributes.getDataCodecInfos());
@@ -465,15 +465,15 @@ public ZarrV3DatasetAttributes deserialize(JsonElement json, Type typeOfT, JsonD
465465
final String typestr = obj.get(DATA_TYPE_KEY).getAsString();
466466
final ZarrV3DataType dataType = ZarrV3DataType.valueOf(typestr.toLowerCase());
467467

468-
final long[] shape = context.deserialize(obj.get(SHAPE_KEY), long[].class);
468+
final long[] dimensions = context.deserialize(obj.get(SHAPE_KEY), long[].class);
469469
final String[] dimensionNames = context.deserialize(obj.get(DIMENSION_NAMES_KEY), String[].class);
470470

471-
ArrayUtils.reverse(shape); // c- to f-order
471+
ArrayUtils.reverse(dimensions); // c- to f-order
472472
ArrayUtils.reverse(dimensionNames); // c- to f-order
473473

474474
final ChunkAttributes chunkAttributes = context.deserialize(obj, ChunkAttributes.class);
475475
return new ZarrV3DatasetAttributes(
476-
shape,
476+
dimensions,
477477
chunkAttributes,
478478
dataType,
479479
obj.get(FILL_VALUE_KEY).getAsString(),
@@ -602,9 +602,9 @@ private static CodecInfo[] concatenateCodecs( ZarrV3DatasetAttributes attributes
602602
return codecs;
603603
}
604604

605-
public static Builder builder(final long[] shape, final DataType dataType) {
605+
public static Builder builder(final long[] dimensions, final DataType dataType) {
606606

607-
return new Builder(shape, dataType);
607+
return new Builder(dimensions, dataType);
608608
}
609609

610610
/**
@@ -626,7 +626,7 @@ public static Builder builder(final long[] shape, final DataType dataType) {
626626
public static class Builder {
627627

628628
// Required parameters
629-
private final long[] shape;
629+
private final long[] dimensions;
630630
private final ZarrV3DataType dataType;
631631

632632
// Optional parameters with defaults
@@ -641,32 +641,32 @@ public static class Builder {
641641
private DataCodecInfo[] shardIndexDataCodecInfos = new DataCodecInfo[0];
642642

643643
// For sharding
644-
private int[] shardShape;
644+
private int[] shardSize;
645645

646646
/**
647647
* Creates a new builder with the required parameters.
648648
*
649-
* @param shape the dimensions of the array
649+
* @param dimensions the dimensions of the array
650650
* @param dataType the N5 data type
651651
*/
652-
public Builder(final long[] shape, final DataType dataType) {
652+
public Builder(final long[] dimensions, final DataType dataType) {
653653

654-
this.shape = shape.clone();
654+
this.dimensions = dimensions.clone();
655655
this.dataType = ZarrV3DataType.fromDataType(dataType);
656-
this.blockSize = Arrays.stream(shape).mapToInt(x -> (int)x).toArray();
656+
this.blockSize = Arrays.stream(dimensions).mapToInt(x -> (int)x).toArray();
657657
}
658658

659659
/**
660660
* Creates a new builder with the required parameters.
661661
*
662-
* @param shape the dimensions of the array
662+
* @param dimensions the dimensions of the array
663663
* @param dataType the Zarr v3 data type
664664
*/
665-
public Builder(final long[] shape, final ZarrV3DataType dataType) {
665+
public Builder(final long[] dimensions, final ZarrV3DataType dataType) {
666666

667-
this.shape = shape.clone();
667+
this.dimensions = dimensions.clone();
668668
this.dataType = dataType;
669-
this.blockSize = Arrays.stream(shape).mapToInt(x -> (int)x).toArray();
669+
this.blockSize = Arrays.stream(dimensions).mapToInt(x -> (int)x).toArray();
670670
}
671671

672672
/**
@@ -688,9 +688,9 @@ public Builder blockSize(final int[] blockSize) {
688688
* @param shardShape the shard dimensions
689689
* @return this builder
690690
*/
691-
public Builder shardShape(final int[] shardShape) {
691+
public Builder shardSize(final int[] shardSize) {
692692

693-
this.shardShape = shardShape.clone();
693+
this.shardSize = shardSize.clone();
694694
return this;
695695
}
696696

@@ -814,7 +814,7 @@ public ZarrV3DatasetAttributes build() {
814814
// Resolve dimension names
815815
final String[] resolvedDimensionNames = dimensionNames != null
816816
? dimensionNames
817-
: defaultDimensionNames(shape.length);
817+
: defaultDimensionNames(dimensions.length);
818818

819819
// Resolve chunk key encoding
820820
final DefaultChunkKeyEncoding resolvedChunkKeyEncoding = chunkKeyEncoding != null
@@ -823,19 +823,19 @@ public ZarrV3DatasetAttributes build() {
823823

824824
final int[] resolvedBlockSize = blockSize != null
825825
? blockSize
826-
: defaultChunkShape(shape);
826+
: defaultChunkShape(dimensions);
827827

828828
// Determine if sharding is enabled
829-
if (shardShape != null) {
829+
if (shardSize != null) {
830830
// Sharded configuration
831831
final BlockCodecInfo resolvedBlockCodecInfo = blockCodecInfo != null
832832
? blockCodecInfo
833833
: defaultShardCodecInfo(resolvedBlockSize, dataCodecInfos, shardIndexDataCodecInfos);
834834

835-
// For sharding, the outer chunk is the shard shape
835+
// For sharding, the outer chunk is the shard size
836836
return new ZarrV3DatasetAttributes(
837-
shape,
838-
shardShape,
837+
dimensions,
838+
shardSize,
839839
dataType,
840840
fillValue,
841841
resolvedDimensionNames,
@@ -849,7 +849,7 @@ public ZarrV3DatasetAttributes build() {
849849
: new PaddedRawBlockCodecInfo();
850850

851851
return new ZarrV3DatasetAttributes(
852-
shape,
852+
dimensions,
853853
resolvedBlockSize,
854854
dataType,
855855
fillValue,

0 commit comments

Comments
 (0)