/**
 * Copyright (c) 2018-present, heineiuo.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */ import { BytewiseComparator } from "./Comparator" ; import BloomFilter from "./BloomFilter" ; import { Comparator } from "./Comparator" ; import Slice from "./Slice" ; import { Env , FileHandle } from "./Env" ; import Block from "./SSTableBlock" ; import Cache from "./Cache" ; import { Buffer } from "./Buffer" ; import { Snapshot } from "./Snapshot" ; export interface FilterPolicy { name ( ) : string ; keyMayMatch ( key , filter ) : boolean ; } export interface ReadOptions { verifyChecksums ? : boolean ; fillCache ? : boolean ; snapshot ? : Snapshot ; } export const defaultReadOptions = { verifyChecksums : false , fillCache : true , } ; export interface IteratorOptions extends ReadOptions { reverse ? : boolean ; start ? : string | Buffer ; } export const defaultIteratorOptions = { reverse : false , start : Buffer . alloc ( 0 ) , ... defaultReadOptions , } ; export interface WriteOptions { sync ? : boolean ; } export const defaultWriteOptions = { sync : false , } ; export interface DatabaseOptions { comparator ? : Comparator ; writeBufferSize ? : number ; maxFileSize ? : number ; maxOpenFiles ? : number ; blockCache ? : Cache < Buffer , Block > ; blockSize ? : number ; blockRestartInterval ? : number ; reuseLogs ? : boolean ; filterPolicy ? : FilterPolicy ; debug ? : boolean ; lockfileStale ? : number ; env ? : Env ; log ? : ( message : string ) => Promise < void > ; infoLog ? : FileHandle | null ; } export type Options = Required < DatabaseOptions > ; export const defaultOptions = { comparator : new BytewiseComparator ( ) , writeBufferSize : 4 * 1024 * 1024 , maxFileSize : 2 * 1024 * 1024 , maxOpenFiles : 1000 , blockCache : new Cache < Buffer , Block > ( { max : 2048 , } ) , blockSize : 4 * 1024 , blockRestartInterval : 16 , reuseLogs : false , filterPolicy : new BloomFilter ( ) , debug : false , lockfileStale : 10000 , infoLog : null , async log ( message ) { if ( this . infoLog ) await this . infoLog . appendFile ( message + "\n" ) ; } , } ;