s2-tools
Version:
A collection of geospatial tools primarily designed for WGS84, Web Mercator, and S2.
66 lines • 2.48 kB
TypeScript
import type { Stringifiable } from '..';
import type { Uint64, Uint64Cell } from '../dataStructures/uint64';
/** Options to create a S2FileStore */
export interface FileOptions {
/** If true, then the values are stored in the index section of the keys file */
valuesAreIndex?: boolean;
/** If true, then the data is already sorted and get calls can be immediately returned */
isSorted?: boolean;
/** The maximum heap size in bytes for each grouping of data. */
maxHeap?: number;
/** The number of threads to use for sorting */
threadCount?: number;
/** If desired, a temporary directory to use */
tmpDir?: string;
}
/** An entry in a file */
export interface FileEntry<V> {
key: Uint64Cell;
value: V;
}
/**
* NOTE: The File KVStore is designed to be used in states:
* - write-only. The initial state is write-only. Write all you need to before reading
* - read-only. Once you have written everything, the first read will lock the file to be static
* and read-only.
*/
export declare class S2FileStore<V = Stringifiable> {
#private;
readonly fileName: string;
/**
* Builds a new File based KV
* @param fileName - the path + file name without the extension
* @param options - the options of how the store should be created and used
*/
constructor(fileName?: string, options?: FileOptions);
/** @returns - the length of the store */
get length(): number;
/**
* Adds a value to be associated with a key
* @param key - the uint64 id
* @param value - the value to store
*/
set(key: Uint64, value: V): void;
/**
* Gets the value associated with a key
* @param key - the key
* @param max - the max number of values to return
* @param bigint - set to true if the key is a bigint
* @returns the value if the map contains values for the key
*/
get(key: Uint64, max?: number, bigint?: boolean): Promise<V[] | undefined>;
/** Sort the data if not sorted */
sort(): Promise<void>;
/**
* Iterates over all values in the store
* @param bigint - set to true if the value is a bigint stored in the index
* @yields an iterator
*/
entries(bigint?: boolean): AsyncIterableIterator<FileEntry<V>>;
/**
* Closes the store
* @param cleanup - set to true if you want to remove the .keys and .values files upon closing
*/
close(cleanup?: boolean): void;
}
//# sourceMappingURL=file.d.ts.map