11/*
2- * Copyright (c) 1998-2018 John Caron and University Corporation for Atmospheric Research/Unidata
2+ * Copyright (c) 1998-2026 John Caron and University Corporation for Atmospheric Research/Unidata
33 * See LICENSE for license information.
44 */
5+
56package ucar .nc2 .internal .iosp .hdf5 ;
67
78import com .google .common .primitives .Ints ;
@@ -71,9 +72,27 @@ public class H5tiledLayoutBB implements LayoutBB {
7172 */
7273 public H5tiledLayoutBB (Variable v2 , Section wantSection , RandomAccessFile raf , H5objects .Filter [] filterProps ,
7374 ByteOrder byteOrder ) throws InvalidRangeException , IOException {
74- wantSection = Section .fill (wantSection , v2 .getShape ());
75+ this ((H5headerNew .Vinfo ) v2 .getSPobject (), v2 .getShape (), v2 .getElementSize (), wantSection , raf , filterProps ,
76+ byteOrder );
77+ }
78+
79+ /**
80+ * This constructor can be used when the Variable is not yet built.
81+ *
82+ * @param vinfo the data object
83+ * @param varShape the variable's shape
84+ * @param elemSize the variable's element size in bytes
85+ * @param wantSection the wanted section of data, contains a List of Range objects. must be complete
86+ * @param raf the RandomAccessFile
87+ * @param filterProps set of filter properties from which filter object will be created
88+ * @throws InvalidRangeException if section invalid for this variable
89+ * @throws IOException on io error
90+ */
91+ H5tiledLayoutBB (H5headerNew .Vinfo vinfo , int [] varShape , int elemSize , Section wantSection , RandomAccessFile raf ,
92+ H5objects .Filter [] filterProps , ByteOrder byteOrder ) throws InvalidRangeException , IOException {
93+
94+ wantSection = Section .fill (wantSection , varShape );
7595
76- H5headerNew .Vinfo vinfo = (H5headerNew .Vinfo ) v2 .getSPobject ();
7796 assert vinfo .isChunked ;
7897 assert vinfo .btree != null ;
7998
@@ -82,7 +101,7 @@ public H5tiledLayoutBB(Variable v2, Section wantSection, RandomAccessFile raf, H
82101 for (int i = 0 ; i < filterProps .length ; i ++) {
83102 // add var info to filter props
84103 Map <String , Object > props = filterProps [i ].getProperties ();
85- props .put (Filters .Keys .ELEM_SIZE , v2 . getElementSize () );
104+ props .put (Filters .Keys .ELEM_SIZE , elemSize );
86105 // try to get filter by name or id, throw if not recognized filter
87106 try {
88107 filters [i ] = Filters .getFilter (props );
@@ -95,7 +114,7 @@ public H5tiledLayoutBB(Variable v2, Section wantSection, RandomAccessFile raf, H
95114 // we have to translate the want section into the same rank as the storageSize, in order to be able to call
96115 // Section.intersect(). It appears that storageSize (actually msl.chunkSize) may have an extra dimension, relative
97116 // to the Variable.
98- DataType dtype = v2 . getDataType ();
117+ DataType dtype = vinfo . getNCDataType ();
99118 if ((dtype == DataType .CHAR ) && (wantSection .getRank () < vinfo .storageSize .length )) {
100119 this .want = Section .builder ().appendRanges (wantSection .getRanges ()).appendRange (1 ).build ();
101120 } else {
0 commit comments