/**
 * 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 { InternalKey } from "./Format" ; import { CompactPointer , DeletedFile , NewFile , FileMetaData , } from "./VersionFormat" ; export default class VersionEdit { compactPointers : CompactPointer [ ] ; deletedFiles : DeletedFile [ ] ; newFiles : NewFile [ ] ; private _comparator : string ; private _logNumber ? : number ; private _prevLogNumber ? : number ; private _lastLogNumber ? : number ; private _lastSequence ? : bigint ; private _nextFileNumber ? : number ; private _hasComparator ? : boolean ; private _hasLogNumber ? : boolean ; private _hasPrevLogNumber ? : boolean ; private _hasNextFileNumber ? : boolean ; private _hasLastSequence ? : boolean ; constructor ( ) { this . _comparator = "" ; this . deletedFiles = [ ] ; this . newFiles = [ ] ; this . compactPointers = [ ] ; } clear ( ) { this . deletedFiles = [ ] ; this . newFiles = [ ] ; this . compactPointers = [ ] ; this . _logNumber = 0 ; this . _prevLogNumber = 0 ; this . _lastSequence = 0n ; this . _nextFileNumber = 0 ; this . _comparator = "" ; this . _lastLogNumber = 0 ; this . _hasComparator = false ; this . _hasLogNumber = false ; this . _hasPrevLogNumber = false ; this . _hasNextFileNumber = false ; this . _hasLastSequence = false ; } set comparator ( value ) { this . _comparator = value ; this . _hasComparator = true ; } get comparator ( ) : string { return this . _comparator ; } set logNumber ( value ) { this . _logNumber = value ; this . _hasLogNumber = true ; } get logNumber ( ) : number { return this . _logNumber || 0 ; } set prevLogNumber ( value ) { this . _prevLogNumber = value ; this . _hasPrevLogNumber = true ; } get prevLogNumber ( ) : number { return this . _prevLogNumber || 0 ; } set nextFileNumber ( value ) { this . _nextFileNumber = value ; this . _hasNextFileNumber = true ; } get nextFileNumber ( ) : number { return this . _nextFileNumber || 0 ; } set lastSequence ( value ) { this . _lastSequence = value ; this . _hasLastSequence = true ; } get lastSequence ( ) : bigint { return this . _lastSequence || 0n ; } get hasComparator ( ) : boolean { return this . _hasComparator || false ; } get hasLogNumber ( ) : boolean { return this . _hasLogNumber || false ; } get hasPrevLogNumber ( ) : boolean { return this . _hasPrevLogNumber || false ; } get hasNextFileNumber ( ) : boolean { return this . _hasNextFileNumber || false ; } get hasLastSequence ( ) : boolean { return this . _hasLastSequence || false ; } public deleteFile ( level , fileNum ) { this . deletedFiles . push ( { level , fileNum , } ) ; } addFile ( level , fileNum , fileSize , smallest , largest ) { const f = new FileMetaData ( ) ; f . number = fileNum ; f . fileSize = fileSize ; f . smallest = smallest ; f . largest = largest ; this . newFiles . push ( { level , fileMetaData : f } ) ; } setCompactPointer ( level , internalKey ) { this . compactPointers . push ( { level , internalKey , } ) ; } }