Created
July 10, 2024 13:33
-
-
Save bogovicj/ce9fd3fb15576f3ea71cf7473f88494c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Reads a {@link DataBlock} from an {@link InputStream}. | |
* | |
* @param in | |
* @param datasetAttributes | |
* @param gridPosition | |
* @return | |
* @throws IOException | |
*/ | |
@SuppressWarnings("incomplete-switch") | |
protected static DataBlock<?> readBlockNew( | |
final InputStream in, | |
final ZarrDatasetAttributes datasetAttributes, | |
final long... gridPosition) throws IOException { | |
final int[] blockSize = datasetAttributes.getBlockSize(); | |
final DType dType = datasetAttributes.getDType(); | |
final BlockReader reader = datasetAttributes.getCompression().getReader(); | |
if (dType.getDataType().equals(DataType.UINT8) || dType.getDataType().equals(DataType.INT8)) | |
{ | |
final ByteArrayDataBlock byteBlock = dType.createByteBlock(blockSize, gridPosition); | |
reader.read(byteBlock, in); | |
if (dType.getDataType() == DataType.STRING) { | |
return readVLenStringBlock(in, reader, byteBlock); | |
} | |
return byteBlock; | |
} else { | |
final DataBlock<?> dataBlock = dType.createDataBlock(blockSize, gridPosition); | |
reader.read(dataBlock, in); | |
return dataBlock; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment