Skip to content

Commit e66984b

Browse files
committed
PR feedback
1 parent fd083e9 commit e66984b

1 file changed

Lines changed: 10 additions & 13 deletions

File tree

src/lib/tableProvider.ts

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ export function parquetDataFrame(from: AsyncBufferFrom, metadata: FileMetaData):
5757
}
5858
}
5959

60-
function fetchRowGroup(groupIndex: number) {
61-
const group = groups[groupIndex]
60+
function fetchVirtualRowGroup(virtualGroupIndex: number) {
61+
const group = groups[virtualGroupIndex]
6262
if (group && !group.fetching) {
6363
group.fetching = true
6464
const { groupStart, groupEnd } = group
@@ -69,15 +69,14 @@ export function parquetDataFrame(from: AsyncBufferFrom, metadata: FileMetaData):
6969
}
7070
parquetQueryWorker({ from, metadata, rowStart: groupStart, rowEnd: groupEnd })
7171
.then(groupData => {
72-
for (let i = groupStart; i < groupEnd; i++) {
73-
const dataRow = data[i]
72+
for (let rowIndex = groupStart; rowIndex < groupEnd; rowIndex++) {
73+
const dataRow = data[rowIndex]
7474
if (dataRow === undefined) {
75-
throw new Error(`Missing data row for index ${i}`)
75+
throw new Error(`Missing data row for index ${rowIndex}`)
7676
}
77-
const j = i - groupStart
78-
const row = groupData[j]
77+
const row = groupData[rowIndex - groupStart]
7978
if (row === undefined) {
80-
throw new Error(`Missing row in groupData for index: ${i - groupStart}`)
79+
throw new Error(`Missing row in groupData for index ${rowIndex}`)
8180
}
8281
for (const [key, value] of Object.entries(row)) {
8382
const cell = dataRow.cells[key]
@@ -89,9 +88,7 @@ export function parquetDataFrame(from: AsyncBufferFrom, metadata: FileMetaData):
8988
}
9089
})
9190
.catch((error: unknown) => {
92-
const prefix = `Error fetching row group ${groupIndex} (${groupStart}-${groupEnd}).`
93-
console.error(prefix, error)
94-
const reason = `${prefix} ${error}`
91+
const reason = `Error fetching rows ${groupStart}-${groupEnd}: ${error}`
9592
// reject the index of the first row (it's enough to trigger the error bar)
9693
data[groupStart]?.index.reject(reason)
9794
})
@@ -132,7 +129,7 @@ export function parquetDataFrame(from: AsyncBufferFrom, metadata: FileMetaData):
132129
// Compute row groups to fetch
133130
for (const index of indices.slice(start, end)) {
134131
const groupIndex = groups.findIndex(({ groupEnd }) => index < groupEnd)
135-
fetchRowGroup(groupIndex)
132+
fetchVirtualRowGroup(groupIndex)
136133
}
137134

138135
// Re-assemble data in sorted order into wrapped
@@ -178,7 +175,7 @@ export function parquetDataFrame(from: AsyncBufferFrom, metadata: FileMetaData):
178175
} else {
179176
groups.forEach(({ groupStart, groupEnd }, i) => {
180177
if (groupStart < end && groupEnd > start) {
181-
fetchRowGroup(i)
178+
fetchVirtualRowGroup(i)
182179
}
183180
})
184181
const wrapped = data.slice(start, end)

0 commit comments

Comments
 (0)