-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
42 additions
and
62 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,19 @@ | ||
# Cloud optimised TAR @cotar/core | ||
|
||
|
||
Given a `.tar` with a `.index` using HTTP range requests fetch only the portion of the tar that contains the bytes of the file. | ||
|
||
For example `@cotar/core` can fetch a 1KB file from a 100GB tar file with only 1 HTTP range request and only download 1KB. Assuming the tar index is loaded into memory. | ||
|
||
|
||
## Usage | ||
|
||
Indexes can be created using the `@cotar/cli` package or programmatically using the `CotarIndexBuilder` | ||
|
||
```typescript | ||
import { CotarIndexBuilder } from '@cotar/core' | ||
import { CotarIndexBuilder } from '@cotar/core'; | ||
import * as fs from 'fs/promises'; | ||
|
||
const fd = await fs.open('tarFile.tar', 'r'); | ||
const res = await CotarIndexBuilder.create(fd, CotarIndex.Binary); | ||
await fs.write('tarFile.tar.index', res.buffer) | ||
await fs.write('tarFile.tar.index', res.buffer); | ||
await fd.close(); | ||
``` | ||
``` |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,34 @@ | ||
# Cloud optimised TAR @cotar/core | ||
|
||
|
||
Given a `.tar` with a `.index` using HTTP range requests fetch only the portion of the tar that contains the bytes of the file. | ||
|
||
For example `@cotar/core` can fetch a 1KB file from a 100GB tar file with only 1 HTTP range request and only download 1KB. Assuming the tar index is loaded into memory. | ||
|
||
|
||
## Usage | ||
|
||
|
||
To fetch a single tile, the index has to be loaded into memory then the cotar object provides a `get(fileName)` interface to access any file inside the tar | ||
|
||
```typescript | ||
import { Cotar, CotarIndexBinary } from '@cotar/core'; | ||
import { fsa } from '@chunkd/fs' | ||
import { Cotar } from '@cotar/core'; | ||
import { SourceUrl } from '@chunkd/source-url'; | ||
|
||
const source = fsa.source('s3://linz-basemaps/topographic.tar'); | ||
const source = new SourceUrl('s3://linz-basemaps/topographic.tar.co'); | ||
const cotar = Cotar.fromTar(source); | ||
|
||
// Fetch a gzipped PBF file from a tar | ||
const bytes = await cotar.get(`tiles/z10/5/5.pbf.gz`); | ||
const bytes = await cotar.get(`tiles/z10/5/5.pbf.gz`); | ||
``` | ||
|
||
### Creating indexes | ||
|
||
Indexes can be created using the `@cotar/cli` package or programmatically using the `CotarIndexBuilder` | ||
|
||
```typescript | ||
import { CotarIndexBuilder } from '@cotar/core' | ||
import { CotarIndexBuilder } from '@cotar/builder'; | ||
import * as fs from 'fs/promises'; | ||
|
||
const fd = await fs.open('tarFile.tar', 'r'); | ||
const res = await CotarIndexBuilder.create(fd, CotarIndex.Binary); | ||
await fs.write('tarFile.tar.index', res.buffer) | ||
await fs.write('tarFile.tar.index', res.buffer); | ||
await fd.close(); | ||
``` | ||
``` |
This file contains 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
This file contains 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
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,5 +4,5 @@ | |
"lib": ["es2018", "DOM"], | ||
"outDir": "build" | ||
}, | ||
"include": ["src"], | ||
"include": ["src"] | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,16 @@ | ||
# @cotar/tar | ||
# @cotar/tar | ||
|
||
Create tars from very large files, using hardlinks to deduplicate files | ||
|
||
|
||
```typescript | ||
|
||
import {TarBuilder} from '@cotar/tar'; | ||
import { TarBuilder } from '@cotar/tar'; | ||
|
||
const tb = new TarBuilder('./output.tar'); | ||
|
||
|
||
for (const fileName in fileList) { | ||
const fileData = await fs.promises.readFile(fileName) | ||
await tb.write(fileName, fileData); | ||
const fileData = await fs.promises.readFile(fileName); | ||
await tb.write(fileName, fileData); | ||
} | ||
|
||
await tb.close(); | ||
``` | ||
|