Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use new chunks header format #25

Merged
merged 2 commits into from
Feb 2, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Merge branch 'main' into katamartin/new-headers
  • Loading branch information
katamartin committed Feb 2, 2023
commit 9d8de88f098c3b8f397c9daee983b153dee73584
4 changes: 2 additions & 2 deletions components/store.js
Original file line number Diff line number Diff line change
@@ -141,7 +141,7 @@ const useStore = create((set, get) => ({
return
}

const { variable, arrays, chunks } = get()
const { variable, headers, chunks } = get()

set({
chunkKey,
@@ -157,8 +157,8 @@ const useStore = create((set, get) => ({
chunks: newChunks,
} = await getAllData(chunkKey, {
chunks,
arrays,
variable,
headers,
})

set({
28 changes: 10 additions & 18 deletions components/utils.js
Original file line number Diff line number Diff line change
@@ -141,16 +141,6 @@ const getChunksHeader = (metadata, variables, apiMetadata) => {
}

export const getArrays = async (url, metadata, variables, apiMetadata) => {
// TODO: validate that we can reuse compressors across the store
const compressorId =
metadata.metadata[`${variables[0]}/.zarray`].compressor.id
const compressor = COMPRESSORS[compressorId]
if (!compressor) {
throw new Error(`no compressor found for compressor.id=${compressorId}`)
}

zarr.registry.set(compressor.codecId, () => compressor)

// TODO: instantiate store with headers and clean up manual overrides
const headers = getChunksHeader(metadata, variables, apiMetadata)
const chunksOverrides = getChunksOverrides(metadata, variables, apiMetadata)
@@ -185,7 +175,7 @@ export const getArrays = async (url, metadata, variables, apiMetadata) => {
}

export const getVariableInfo = async (
variable,
name,
{ arrays, headers, metadata, apiMetadata }
) => {
const dataArray = arrays[name]
@@ -255,13 +245,15 @@ export const getVariableInfo = async (

const getChunkData = async (
chunkKey,
{ arrays, variable: { axes, name: variable, nullValue }, headers }
{
variable: { array, axes, nullValue, chunk_separator, chunk_shape, shape },
headers,
}
) => {
const dataArray = arrays[variable]
const chunkKeyArray = toKeyArray(chunkKey, { arrays, variable })
const data = await dataArray
const chunkKeyArray = toKeyArray(chunkKey, { chunk_separator })
const data = await array
.get_chunk(chunkKeyArray, { headers })
.then((c) => ndarray(new Float32Array(c.data), dataArray.chunk_shape))
.then((c) => ndarray(new Float32Array(c.data), chunk_shape))

const clim = getRange(data.data, { nullValue })

@@ -376,7 +368,7 @@ const getActiveChunkKeys = (chunkKey, variable) => {
.map((offset) => getAdjacentChunk(offset, chunkKey, variable))
.filter(Boolean)
}
export const getAllData = async (chunkKey, { chunks, variable }) => {
export const getAllData = async (chunkKey, { chunks, variable, headers }) => {
const activeChunkKeys = getActiveChunkKeys(chunkKey, variable)
const activeChunks = {}
const allChunks = await Promise.all(
@@ -385,7 +377,7 @@ export const getAllData = async (chunkKey, { chunks, variable }) => {
activeChunks[key] = chunks[key]
return chunks[key]
} else {
const chunk = await getChunkData(key, variable)
const chunk = await getChunkData(key, { variable, headers })
activeChunks[key] = chunk
return chunk
}
You are viewing a condensed version of this merge commit. You can view the full changes here.