Skip to content

Commit 25e8a95

Browse files
committed
Error Msg
1 parent ac9cd32 commit 25e8a95

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/components/ui/ErrorList.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,9 @@ export const ErrorList = {
2222
tsException: {
2323
title: "1D Transect Unavailable",
2424
description: "1D transects are unavailable when using face displacement on the sphere plot."
25+
},
26+
largeArray :{
27+
title: "Requested too Much Memory",
28+
description: "Browzarr cannot request that much data in one call. This is a fixable issue, open an issue on GitHub so I am motivated to implement it."
2529
}
2630
}

src/components/zarr/ZarrLoaderLRU.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ export async function GetArray(): Promise<{
252252
const hasTimeChunks = is4D ? fullShape[1]/chunkShape[0] > 1 : fullShape[0]/chunkShape[0] > 1
253253

254254
//---- Strategy 1. Download whole array (No time chunks) ----//
255-
if (!hasTimeChunks){ // No chunking along time axis, can download whole array at once
255+
if (!hasTimeChunks){
256256
setStatus("Downloading...")
257257
const chunk = await fetchWithRetry(
258258
() => is4D ? zarr.get(outVar, [idx4D, null, null, null]) : zarr.get(outVar),
@@ -264,6 +264,7 @@ export async function GetArray(): Promise<{
264264
throw new Error("BigInt arrays not supported.");
265265
}
266266
const shape = is4D ? outVar.shape.slice(1) : outVar.shape;
267+
267268
setStrides(chunk.stride) // Need strides for the point cloud
268269
const [typedArray, scalingFactor] = ToFloat16(chunk.data as Float32Array, null)
269270
const cacheChunk = {
@@ -309,6 +310,10 @@ export async function GetArray(): Promise<{
309310
setArraySize(totalElements);
310311
setCurrentChunks({ x: [xDim.start, xDim.end], y: [yDim.start, yDim.end], z: [zDim.start, zDim.end] }); //These are used to stitch timeseries data
311312
}
313+
if (totalElements > 1e9){
314+
useErrorStore.getState().setError('largeArray');
315+
throw Error("Cannot allocate unbokrne memory segment for array.")
316+
}
312317
const typedArray = new Float16Array(totalElements);
313318

314319
// State for the loop

0 commit comments

Comments
 (0)