Skip to content

Commit 99ce85a

Browse files
committed
Reorganize files in the repo.
Move avro into nested folder. Add index.js. Rename avroData to avroRead.
1 parent 1839413 commit 99ce85a

20 files changed

+40
-39
lines changed

example.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { icebergRead } from './src/iceberg.js'
1+
import { icebergRead } from './src/index.js'
22

3-
const tableUrl = 'https://s3.amazonaws.com/hyperparam-iceberg/warehouse/bunnies'
3+
const tableUrl = 'https://s3.amazonaws.com/hyperparam-iceberg/spark/bunnies'
44
const metadataFileName = 'v3.metadata.json'
55

66
/**

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@
2424
"types"
2525
],
2626
"type": "module",
27-
"types": "types/iceberg.d.ts",
27+
"types": "types/index.d.ts",
2828
"exports": {
2929
".": {
30-
"types": "./types/iceberg.d.ts",
31-
"import": "./src/iceberg.js"
30+
"types": "./types/index.d.ts",
31+
"import": "./src/index.js"
3232
},
3333
"./src/*.js": {
3434
"types": "./types/*.d.ts",
File renamed without changes.

src/avro.data.js renamed to src/avro/avro.read.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { parseDecimal } from 'hyparquet/src/convert.js'
1212
* @param {Uint8Array} options.syncMarker
1313
* @returns {Record<string, any>[]}
1414
*/
15-
export function avroData({ reader, metadata, syncMarker }) {
15+
export function avroRead({ reader, metadata, syncMarker }) {
1616
const blocks = []
1717
while (reader.offset < reader.view.byteLength) {
1818
let recordCount = readZigZag(reader)
@@ -63,7 +63,7 @@ export function avroData({ reader, metadata, syncMarker }) {
6363

6464
/**
6565
* @import {DataReader} from 'hyparquet/src/types.js'
66-
* @import {AvroType} from '../src/types.js'
66+
* @import {AvroType} from '../../src/types.js'
6767
* @param {DataReader} reader
6868
* @param {AvroType} type
6969
* @returns {any}

src/avro.write.js renamed to src/avro/avro.write.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export function avroWrite({ writer, schema, records, blockSize = 512 }) {
4848

4949
/**
5050
* @import {Writer} from 'hyparquet-writer/src/types.js'
51-
* @import {AvroRecord, AvroType} from '../src/types.js'
51+
* @import {AvroRecord, AvroType} from '../../src/types.js'
5252
* @param {Writer} writer
5353
* @param {AvroType} schema
5454
* @param {*} value

src/iceberg.fetch.js renamed to src/fetch.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { asyncBufferFromUrl, cachedAsyncBuffer, parquetReadObjects } from 'hyparquet'
22
import { compressors } from 'hyparquet-compressors'
3-
import { avroData } from './avro.data.js'
4-
import { avroMetadata } from './avro.metadata.js'
3+
import { avroRead } from './avro/avro.read.js'
4+
import { avroMetadata } from './avro/avro.metadata.js'
55

66
/**
77
* Translates an S3A URL to an HTTPS URL for direct access to the object.
@@ -92,5 +92,5 @@ export async function fetchAvroRecords(manifestUrl, requestInit) {
9292
const buffer = await fetch(safeUrl, requestInit).then(res => res.arrayBuffer())
9393
const reader = { view: new DataView(buffer), offset: 0 }
9494
const { metadata, syncMarker } = await avroMetadata(reader)
95-
return await avroData({ reader, metadata, syncMarker })
95+
return await avroRead({ reader, metadata, syncMarker })
9696
}

src/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export { icebergRead } from './read.js'
2+
export { icebergLatestVersion, icebergListVersions, icebergMetadata } from './metadata.js'
3+
export { icebergManifests } from './manifest.js'
4+
export { avroMetadata } from './avro/avro.metadata.js'
5+
export { avroRead } from './avro/avro.read.js'
6+
export { avroWrite } from './avro/avro.write.js'

src/iceberg.manifest.js renamed to src/manifest.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { fetchAvroRecords } from './iceberg.fetch.js'
1+
import { fetchAvroRecords } from './fetch.js'
22

33
/**
44
* Returns manifest entries for the current snapshot.

src/iceberg.metadata.js renamed to src/metadata.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { translateS3Url } from './iceberg.fetch.js'
1+
import { translateS3Url } from './fetch.js'
22

33
/**
44
* Fetches the iceberg metadata version using the version hint file.

src/iceberg.js renamed to src/read.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
import { asyncBufferFromUrl, cachedAsyncBuffer, parquetMetadataAsync, parquetReadObjects } from 'hyparquet'
22
import { compressors } from 'hyparquet-compressors'
3-
import { fetchDeleteMaps, translateS3Url } from './iceberg.fetch.js'
4-
import { icebergLatestVersion, icebergListVersions, icebergMetadata } from './iceberg.metadata.js'
5-
import { icebergManifests, splitManifestEntries } from './iceberg.manifest.js'
3+
import { fetchDeleteMaps, translateS3Url } from './fetch.js'
4+
import { icebergMetadata } from './metadata.js'
5+
import { icebergManifests, splitManifestEntries } from './manifest.js'
66
import { equalityMatch, sanitize } from './utils.js'
77

8-
export { icebergMetadata, icebergManifests, icebergLatestVersion, icebergListVersions }
9-
export { avroMetadata } from './avro.metadata.js'
10-
export { avroData } from './avro.data.js'
11-
128
/**
139
* Reads data from the Iceberg table with optional row-level delete processing.
1410
* Row indices are zero-based and rowEnd is exclusive.

test/avro.metadata.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import fs from 'fs'
22
import { describe, expect, it } from 'vitest'
3-
import { avroMetadata } from '../src/avro.metadata.js'
3+
import { avroMetadata } from '../src/avro/avro.metadata.js'
44
import { asyncBufferFromFile, toJson } from 'hyparquet'
55
import { fileToJson } from './helpers.js'
66

test/avro.data.test.js renamed to test/avro.read.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import fs from 'fs'
22
import { describe, expect, it } from 'vitest'
3-
import { avroData } from '../src/avro.data.js'
4-
import { avroMetadata } from '../src/avro.metadata.js'
3+
import { avroRead } from '../src/avro/avro.read.js'
4+
import { avroMetadata } from '../src/avro/avro.metadata.js'
55
import { asyncBufferFromFile, toJson } from 'hyparquet'
66
import { fileToJson } from './helpers.js'
77

8-
describe('avroData from test files', () => {
8+
describe('avroRead from test files', () => {
99
const files = fs.readdirSync('test/files').filter(f => f.endsWith('.avro'))
1010

1111
files.forEach(filename => {
@@ -14,7 +14,7 @@ describe('avroData from test files', () => {
1414
const buffer = await file.slice(0)
1515
const reader = { view: new DataView(buffer), offset: 0 }
1616
const { metadata, syncMarker } = await avroMetadata(reader)
17-
const data = await avroData({ reader, metadata, syncMarker })
17+
const data = await avroRead({ reader, metadata, syncMarker })
1818

1919
const base = filename.replace('.avro', '')
2020
const expected = fileToJson(`test/files/${base}.json`)

test/avro.roundtrip.test.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { describe, expect, it } from 'vitest'
22
import { ByteWriter } from 'hyparquet-writer'
3-
import { avroWrite } from '../src/avro.write.js'
4-
import { avroData, avroMetadata } from '../src/iceberg.js'
3+
import { avroMetadata, avroRead, avroWrite } from '../src/index.js'
54

65
/**
76
* @import {AvroType} from '../src/types.js'
@@ -33,7 +32,7 @@ describe('Avro round-trip', () => {
3332

3433
const reader = { view: new DataView(writer.getBuffer()), offset: 0 }
3534
const { metadata, syncMarker } = avroMetadata(reader)
36-
const rows = avroData({ reader, metadata, syncMarker })
35+
const rows = avroRead({ reader, metadata, syncMarker })
3736

3837
expect(rows).toEqual(records)
3938
})
@@ -58,7 +57,7 @@ describe('Avro round-trip', () => {
5857

5958
const reader = { view: new DataView(writer.getBuffer()), offset: 0 }
6059
const { metadata, syncMarker } = avroMetadata(reader)
61-
const got = avroData({ reader, metadata, syncMarker })
60+
const got = avroRead({ reader, metadata, syncMarker })
6261

6362
expect(got).toEqual(recs)
6463
})
@@ -84,7 +83,7 @@ describe('Avro round-trip', () => {
8483

8584
const reader = { view: new DataView(writer.getBuffer()), offset: 0 }
8685
const { metadata, syncMarker } = avroMetadata(reader)
87-
const round = avroData({ reader, metadata, syncMarker })
86+
const round = avroRead({ reader, metadata, syncMarker })
8887

8988
expect(round[0].ts.getTime()).toBe(original[0].ts.getTime())
9089
})
@@ -114,7 +113,7 @@ describe('Avro round-trip', () => {
114113

115114
const reader = { view: new DataView(writer.getBuffer()), offset: 0 }
116115
const { metadata, syncMarker } = avroMetadata(reader)
117-
const got = avroData({ reader, metadata, syncMarker })
116+
const got = avroRead({ reader, metadata, syncMarker })
118117

119118
expect(got).toEqual(recs)
120119
})

test/iceberg.manifest.test.js renamed to test/manifest.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { describe, expect, it } from 'vitest'
2-
import { icebergManifests } from '../src/iceberg.manifest.js'
3-
import { icebergMetadata } from '../src/iceberg.metadata.js'
2+
import { icebergManifests } from '../src/manifest.js'
3+
import { icebergMetadata } from '../src/metadata.js'
44

55
describe('Iceberg Manifests', () => {
66
const tableUrl = 'https://s3.amazonaws.com/hyperparam-iceberg/spark/bunnies'

test/iceberg.metadata.test.js renamed to test/metadata.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { describe, expect, it, vi } from 'vitest'
2-
import { icebergLatestVersion, icebergListVersions, icebergMetadata } from '../src/iceberg.metadata.js'
2+
import { icebergLatestVersion, icebergListVersions, icebergMetadata } from '../src/metadata.js'
33

44
describe.concurrent('Iceberg Metadata', () => {
55
const tableUrl = 'https://s3.amazonaws.com/hyperparam-iceberg/spark/bunnies'

test/iceberg.athena.test.js renamed to test/read.athena.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { describe, expect, it } from 'vitest'
2-
import { icebergLatestVersion, icebergListVersions, icebergMetadata, icebergRead } from '../src/iceberg.js'
2+
import { icebergLatestVersion, icebergListVersions, icebergMetadata, icebergRead } from '../src/index.js'
33

44
describe.concurrent('icebergRead from athena table', () => {
55
const tableUrl = 'https://s3.amazonaws.com/hyperparam-iceberg/athena/example'

test/iceberg.column.rename.test.js renamed to test/read.column.rename.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { describe, expect, it } from 'vitest'
2-
import { icebergRead } from '../src/iceberg.js'
2+
import { icebergRead } from '../src/read.js'
33

44
describe.concurrent('icebergRead from table with renamed column', () => {
55
const tableUrl = 'https://s3.amazonaws.com/hyperparam-iceberg/spark/rename_column'

test/iceberg.java.test.js renamed to test/read.java.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { describe, expect, it, vi } from 'vitest'
2-
import { icebergRead } from '../src/iceberg.js'
2+
import { icebergRead } from '../src/read.js'
33

44
describe.concurrent('icebergRead from java iceberg table', () => {
55
const tableUrl = 'https://s3.amazonaws.com/hyperparam-iceberg/java/bunnies'

test/iceberg.spark.test.js renamed to test/read.spark.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { describe, expect, it } from 'vitest'
2-
import { icebergRead } from '../src/iceberg.js'
2+
import { icebergRead } from '../src/read.js'
33

44
describe.concurrent('icebergRead from spark iceberg table', () => {
55
const tableUrl = 'https://s3.amazonaws.com/hyperparam-iceberg/spark/bunnies'

test/iceberg.test.js renamed to test/read.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { describe, expect, it } from 'vitest'
2-
import { icebergRead } from '../src/iceberg.js'
2+
import { icebergRead } from '../src/read.js'
33

44
describe.concurrent('icebergRead', () => {
55
it('throws for missing tableUrl', async () => {

0 commit comments

Comments
 (0)