4 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/AbstractComparator.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual typealias AbstractComparator = org.rocksdb.AbstractComparator
4 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/AbstractImmutableNativeReference.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual typealias AbstractImmutableNativeReference = org.rocksdb.AbstractImmutableNativeReference
4 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/AbstractMutableOptions.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual typealias AbstractMutableOptions = org.rocksdb.AbstractMutableOptions
4 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/AbstractNativeReference.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual typealias AbstractNativeReference = org.rocksdb.AbstractNativeReference
4 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/AbstractRocksIterator.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual typealias AbstractRocksIterator = org.rocksdb.AbstractRocksIterator
4 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/AbstractSlice.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | /**
4 | * Regards the lifecycle of Java Slices in RocksDB:
5 | * At present when you configure a Comparator from Java, it creates an
6 | * instance of a C++ BaseComparatorJniCallback subclass and
7 | * passes that to RocksDB as the comparator. That subclass of
8 | * BaseComparatorJniCallback creates the Java
9 | *
10 | * @see AbstractSlice subclass Objects. When you dispose
11 | * the Java @see AbstractComparator subclass, it disposes the
12 | * C++ BaseComparatorJniCallback subclass, which in turn destroys the
13 | * Java @see maryk.rocksdb.AbstractSlice subclass Objects.
14 | */
15 | actual typealias AbstractSlice = org.rocksdb.AbstractSlice
16 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/AbstractTraceWriter.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual typealias AbstractTraceWriter = org.rocksdb.AbstractTraceWriter
4 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/AbstractTransactionNotifier.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual typealias AbstractTransactionNotifier = org.rocksdb.AbstractTransactionNotifier
4 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/AbstractWriteBatch.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual typealias AbstractWriteBatch = org.rocksdb.AbstractWriteBatch
4 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/BackupEngine.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | import org.rocksdb.BackupEngineOptions
4 |
5 | actual typealias BackupEngine = org.rocksdb.BackupEngine
6 |
7 | actual fun openBackupEngine(
8 | env: Env,
9 | options: BackupEngineOptions
10 | ): BackupEngine = BackupEngine.open(
11 | env, options
12 | )
13 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/BackupEngineOptions.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual typealias BackupEngineOptions = org.rocksdb.BackupEngineOptions
4 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/BackupInfo.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | /**
4 | * Instances of this class describe a Backup made by
5 | * [BackupEngine].
6 | */
7 | actual typealias BackupInfo = org.rocksdb.BackupInfo
8 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/BottommostLevelCompaction.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual typealias BottommostLevelCompaction = org.rocksdb.CompactRangeOptions.BottommostLevelCompaction
4 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/BuiltinComparator.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual typealias BuiltinComparator = org.rocksdb.BuiltinComparator
4 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/Cache.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual typealias Cache = org.rocksdb.Cache
4 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/ChecksumType.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | /** Checksum types used in conjunction with BlockBasedTable. */
4 | actual typealias ChecksumType = org.rocksdb.ChecksumType
5 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/ColumnFamilyDescriptor.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual typealias ColumnFamilyDescriptor = org.rocksdb.ColumnFamilyDescriptor
4 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/ColumnFamilyHandle.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual typealias ColumnFamilyHandle = org.rocksdb.ColumnFamilyHandle
4 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/ColumnFamilyMetaData.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual typealias ColumnFamilyMetaData = org.rocksdb.ColumnFamilyMetaData
4 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/ColumnFamilyOptions.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual typealias ColumnFamilyOptions = org.rocksdb.ColumnFamilyOptions
4 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/CompactRangeOptions.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual typealias CompactRangeOptions = org.rocksdb.CompactRangeOptions
4 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/CompactionPriority.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual typealias CompactionPriority = org.rocksdb.CompactionPriority
4 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/CompactionReason.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual typealias CompactionReason = org.rocksdb.CompactionReason
4 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/CompactionStopStyle.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual typealias CompactionStopStyle = org.rocksdb.CompactionStopStyle
4 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/CompactionStyle.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual typealias CompactionStyle = org.rocksdb.CompactionStyle
4 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/ComparatorOptions.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual typealias ComparatorOptions = org.rocksdb.ComparatorOptions
4 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/CompressionType.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual typealias CompressionType = org.rocksdb.CompressionType
4 |
5 | actual fun getCompressionType(libraryName: String?) =
6 | CompressionType.getCompressionType(libraryName)
7 |
8 | actual fun getCompressionType(byteIdentifier: Byte) =
9 | CompressionType.getCompressionType(byteIdentifier)
10 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/DBOptions.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual typealias DBOptions = org.rocksdb.DBOptions
4 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/DataBlockIndexType.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual typealias DataBlockIndexType = org.rocksdb.DataBlockIndexType
4 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/DirectSlice.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual typealias DirectSlice = org.rocksdb.DirectSlice
4 |
5 | actual val DirectSliceNone = DirectSlice.NONE
6 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/EncodingType.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual typealias EncodingType = org.rocksdb.EncodingType
4 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/Env.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual typealias Env = org.rocksdb.Env
4 |
5 | actual fun getDefaultEnv(): Env = Env.getDefault()
6 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/FilterPolicy.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | /**
4 | * Filters are stored in rocksdb and are consulted automatically
5 | * by rocksdb to decide whether or not to read some
6 | * information from disk. In many cases, a filter can cut down the
7 | * number of disk seeks form a handful to a single disk seek per
8 | * DB::Get() call.
9 | */
10 | actual typealias FilterPolicy = org.rocksdb.Filter
11 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/GetStatus.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual typealias GetStatus = org.rocksdb.GetStatus
4 |
5 | /**
6 | * The status of the fetch operation.
7 | */
8 | actual fun GetStatus.getStatus(): Status {
9 | return this.status
10 | }
11 |
12 | /**
13 | * The size of the data fetched, which may be bigger than the buffer.
14 | */
15 | actual fun GetStatus.getRequiredSize(): Int {
16 | return this.requiredSize
17 | }
18 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/HistogramData.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual typealias HistogramData = org.rocksdb.HistogramData
4 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/HistogramType.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual typealias HistogramType = org.rocksdb.HistogramType
4 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/Holder.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | import org.rocksdb.Holder
4 |
5 | /** Simple instance reference wrapper. */
6 | actual typealias Holder = Holder
7 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/IndexType.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual typealias IndexType = org.rocksdb.IndexType
4 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/InfoLogLevel.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual typealias InfoLogLevel = org.rocksdb.InfoLogLevel
4 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/LRUCache.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual typealias LRUCache = org.rocksdb.LRUCache
4 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/LevelMetaData.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual typealias LevelMetaData = org.rocksdb.LevelMetaData
4 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/MemTableConfig.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual typealias MemTableConfig = org.rocksdb.MemTableConfig
4 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/MemoryUsageType.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual typealias MemoryUsageType = org.rocksdb.MemoryUsageType
4 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/MergeOperator.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual typealias MergeOperator = org.rocksdb.MergeOperator
4 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/OptimisticTransactionDB.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | import org.rocksdb.OptimisticTransactionDB
4 |
5 | actual typealias OptimisticTransactionDB = OptimisticTransactionDB
6 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/OptimisticTransactionOptions.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | import org.rocksdb.OptimisticTransactionOptions
4 |
5 | actual typealias OptimisticTransactionOptions = OptimisticTransactionOptions
6 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/Options.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual typealias Options = org.rocksdb.Options
4 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/Priority.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual typealias Priority = org.rocksdb.Priority
4 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/Range.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual typealias Range = org.rocksdb.Range
4 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/ReadOptions.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual typealias ReadOptions = org.rocksdb.ReadOptions
4 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/ReadTier.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual typealias ReadTier = org.rocksdb.ReadTier
4 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/RemoveEmptyValueCompactionFilter.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual typealias RemoveEmptyValueCompactionFilter = org.rocksdb.RemoveEmptyValueCompactionFilter
4 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/RestoreOptions.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual typealias RestoreOptions = org.rocksdb.RestoreOptions
4 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/RocksCallbackObject.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual typealias RocksCallbackObject = org.rocksdb.RocksCallbackObject
4 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/RocksDB.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual typealias RocksDB = org.rocksdb.RocksDB
4 |
5 | actual val defaultColumnFamily = RocksDB.DEFAULT_COLUMN_FAMILY
6 | actual val rocksDBNotFound = RocksDB.NOT_FOUND
7 |
8 | actual fun destroyRocksDB(path: String, options: Options) {
9 | RocksDB.destroyDB(path, options)
10 | }
11 |
12 | actual fun listColumnFamilies(
13 | options: Options,
14 | path: String
15 | ) = RocksDB.listColumnFamilies(options, path)
16 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/RocksDBException.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual typealias RocksDBException = org.rocksdb.RocksDBException
4 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/RocksIterator.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual typealias RocksIterator = org.rocksdb.RocksIterator
4 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/RocksIteratorInterface.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual typealias RocksIteratorInterface = org.rocksdb.RocksIteratorInterface
4 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/RocksMutableObject.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual typealias RocksMutableObject = org.rocksdb.RocksMutableObject
4 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/RocksObject.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual typealias RocksObject = org.rocksdb.RocksObject
4 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/SizeApproximationFlag.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual typealias SizeApproximationFlag = org.rocksdb.SizeApproximationFlag
4 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/Slice.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual typealias Slice = org.rocksdb.Slice
4 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/Snapshot.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual typealias Snapshot = org.rocksdb.Snapshot
4 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/SstFileMetaData.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual typealias SstFileMetaData = org.rocksdb.SstFileMetaData
4 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/Statistics.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual typealias Statistics = org.rocksdb.Statistics
4 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/StatsLevel.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual typealias StatsLevel = org.rocksdb.StatsLevel
4 |
5 | fun getStatsLevel(value: Byte) =
6 | StatsLevel.getStatsLevel(value)
7 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/Status.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual typealias Status = org.rocksdb.Status
4 |
5 | actual typealias StatusCode = org.rocksdb.Status.Code
6 |
7 | actual typealias StatusSubCode = org.rocksdb.Status.SubCode
8 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/StringAppendOperator.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual typealias StringAppendOperator = org.rocksdb.StringAppendOperator
4 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/TableFormatConfig.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual typealias TableFormatConfig = org.rocksdb.TableFormatConfig
4 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/TickerType.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | import org.rocksdb.TickerType
4 |
5 | actual typealias TickerType = TickerType
6 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/TimedEnv.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual typealias TimedEnv = org.rocksdb.TimedEnv
4 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/TraceOptions.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual typealias TraceOptions = org.rocksdb.TraceOptions
4 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/TraceWriter.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual typealias TraceWriter = org.rocksdb.TraceWriter
4 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/Transaction.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual typealias Transaction = org.rocksdb.Transaction
4 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/TransactionDB.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual typealias TransactionDB = org.rocksdb.TransactionDB
4 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/TransactionDBOptions.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual typealias TransactionDBOptions = org.rocksdb.TransactionDBOptions
4 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/TransactionOptions.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual typealias TransactionOptions = org.rocksdb.TransactionOptions
4 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/TransactionState.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | import org.rocksdb.Transaction
4 |
5 | actual typealias TransactionState = Transaction.TransactionState
6 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/TxnDBWritePolicy.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual typealias TxnDBWritePolicy = org.rocksdb.TxnDBWritePolicy
4 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/WBWIRocksIterator.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual typealias WBWIRocksIterator = org.rocksdb.WBWIRocksIterator
4 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/WaitingTransactions.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual typealias WaitingTransactions = org.rocksdb.Transaction.WaitingTransactions
4 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/WalFileType.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual typealias WalFileType = org.rocksdb.WalFileType
4 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/WriteBatch.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual typealias WriteBatch = org.rocksdb.WriteBatch
4 |
5 | actual typealias WriteBatchSavePoint = org.rocksdb.WriteBatch.SavePoint
6 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/WriteBatchInterface.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual typealias WriteBatchInterface = org.rocksdb.WriteBatchInterface
4 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/WriteBatchWithIndex.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual typealias WriteBatchWithIndex = org.rocksdb.WriteBatchWithIndex
4 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/WriteEntry.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual typealias WriteEntry = org.rocksdb.WBWIRocksIterator.WriteEntry
4 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/WriteOptions.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual typealias WriteOptions = org.rocksdb.WriteOptions
4 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/WriteType.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual typealias WriteType = org.rocksdb.WBWIRocksIterator.WriteType
4 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/createCheckPoint.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual typealias Checkpoint = org.rocksdb.Checkpoint
4 |
5 | actual fun createCheckpoint(db: RocksDB) = Checkpoint.create(db)
6 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/loadLibrary.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual fun loadRocksDBLibrary() {
4 | RocksDB.loadLibrary()
5 | }
6 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/openOptimisticTransactionDB.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | @Throws(RocksDBException::class)
4 | actual fun openOptimisticTransactionDB(
5 | dbOptions: DBOptions,
6 | path: String,
7 | columnFamilyDescriptors: List,
8 | columnFamilyHandles: MutableList
9 | ): OptimisticTransactionDB =
10 | org.rocksdb.OptimisticTransactionDB.open(dbOptions, path, columnFamilyDescriptors, columnFamilyHandles)
11 |
12 | @Throws(RocksDBException::class)
13 | actual fun openOptimisticTransactionDB(
14 | options: Options,
15 | path: String
16 | ): OptimisticTransactionDB =
17 | org.rocksdb.OptimisticTransactionDB.open(options, path)
18 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/openRocksDB.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual fun openRocksDB(path: String) = RocksDB.open(path)
4 |
5 | actual fun openRocksDB(options: Options, path: String) = RocksDB.open(options, path)
6 |
7 | actual fun openRocksDB(
8 | path: String,
9 | columnFamilyDescriptors: List,
10 | columnFamilyHandles: MutableList
11 | ) = RocksDB.open(path, columnFamilyDescriptors, columnFamilyHandles)
12 |
13 | actual fun openRocksDB(
14 | options: DBOptions,
15 | path: String,
16 | columnFamilyDescriptors: List,
17 | columnFamilyHandles: MutableList
18 | ) = RocksDB.open(options, path, columnFamilyDescriptors, columnFamilyHandles)
19 |
20 | actual fun openReadOnlyRocksDB(path: String) =
21 | RocksDB.openReadOnly(path)
22 |
23 | actual fun openReadOnlyRocksDB(
24 | path: String,
25 | columnFamilyDescriptors: List,
26 | columnFamilyHandles: MutableList
27 | ) = RocksDB.openReadOnly(path, columnFamilyDescriptors, columnFamilyHandles)
28 |
29 | actual fun openReadOnlyRocksDB(options: Options, path: String) =
30 | RocksDB.openReadOnly(options, path)
31 |
32 | actual fun openReadOnlyRocksDB(
33 | options: DBOptions,
34 | path: String,
35 | columnFamilyDescriptors: List,
36 | columnFamilyHandles: MutableList
37 | ) = RocksDB.openReadOnly(options, path, columnFamilyDescriptors, columnFamilyHandles)
38 |
--------------------------------------------------------------------------------
/src/jvmMain/kotlin/maryk/rocksdb/openTransactionDB.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | @Throws(RocksDBException::class)
4 | actual fun openTransactionDB(
5 | dbOptions: DBOptions,
6 | transactionDbOptions: TransactionDBOptions,
7 | path: String,
8 | columnFamilyDescriptors: List,
9 | columnFamilyHandles: MutableList
10 | ): TransactionDB =
11 | org.rocksdb.TransactionDB.open(dbOptions, transactionDbOptions, path, columnFamilyDescriptors, columnFamilyHandles)
12 |
13 | @Throws(RocksDBException::class)
14 | actual fun openTransactionDB(
15 | options: Options,
16 | transactionDbOptions: TransactionDBOptions,
17 | path: String
18 | ): TransactionDB =
19 | org.rocksdb.TransactionDB.open(options, transactionDbOptions, path)
20 |
--------------------------------------------------------------------------------
/src/jvmTest/kotlin/maryk/createFolder.kt:
--------------------------------------------------------------------------------
1 | package maryk
2 |
3 | import java.io.File
4 |
5 | actual fun createFolder(path: String) = File(path).mkdirs()
6 |
--------------------------------------------------------------------------------
/src/jvmTest/kotlin/maryk/deleteFolder.kt:
--------------------------------------------------------------------------------
1 | package maryk
2 |
3 | import java.io.File
4 |
5 | actual fun deleteFolder(path: String): Boolean {
6 | return File(path).deleteRecursively()
7 | }
8 |
--------------------------------------------------------------------------------
/src/jvmTest/kotlin/maryk/doesFolderExist.kt:
--------------------------------------------------------------------------------
1 | package maryk
2 |
3 | import java.io.File
4 |
5 | actual fun doesFolderExist(path: String) =
6 | File(path).exists()
7 |
--------------------------------------------------------------------------------
/src/linuxTest/kotlin/maryk/createFolder.kt:
--------------------------------------------------------------------------------
1 | package maryk
2 |
3 | import platform.posix.S_IRWXU
4 | import platform.posix.mkdir
5 |
6 | actual fun createFolder(path: String) =
7 | when (mkdir(path, S_IRWXU.toUInt())) {
8 | 0 -> true
9 | else -> false
10 | }
11 |
--------------------------------------------------------------------------------
/src/linuxTest/kotlin/maryk/deleteFolder.kt:
--------------------------------------------------------------------------------
1 | package maryk
2 |
3 | import platform.posix.rmdir
4 |
5 | actual fun deleteFolder(path: String) =
6 | when (rmdir(path)) {
7 | 0 -> true
8 | else -> false
9 | }
10 |
--------------------------------------------------------------------------------
/src/linuxTest/kotlin/maryk/doesFolderExist.kt:
--------------------------------------------------------------------------------
1 | package maryk
2 |
3 | import platform.posix.opendir
4 |
5 | actual fun doesFolderExist(path: String): Boolean {
6 | val directory = opendir(path)
7 | return directory != null
8 | }
9 |
--------------------------------------------------------------------------------
/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/src/mingwTest/kotlin/maryk/createFolder.kt:
--------------------------------------------------------------------------------
1 | package maryk
2 |
3 | import platform.posix.mkdir
4 |
5 | actual fun createFolder(path: String) =
6 | when (mkdir(path)) {
7 | 0 -> true
8 | else -> false
9 | }
10 |
--------------------------------------------------------------------------------
/src/mingwTest/kotlin/maryk/deleteFolder.kt:
--------------------------------------------------------------------------------
1 | package maryk
2 |
3 | import platform.posix.rmdir
4 |
5 | actual fun deleteFolder(path: String) =
6 | when (rmdir(path)) {
7 | 0 -> true
8 | else -> false
9 | }
10 |
--------------------------------------------------------------------------------
/src/mingwTest/kotlin/maryk/doesFolderExist.kt:
--------------------------------------------------------------------------------
1 | package maryk
2 |
3 | import platform.posix.opendir
4 |
5 | actual fun doesFolderExist(path: String): Boolean {
6 | val directory = opendir(path)
7 | return directory != null
8 | }
9 |
--------------------------------------------------------------------------------
/src/nativeInterop/cinterop/rocksdb.def:
--------------------------------------------------------------------------------
1 | headers = c.h
2 | package = rocksdb
3 | staticLibraries = libbz2.a liblz4.a libz.a libzstd.a libsnappy.a librocksdb.a
4 | libraryPaths = rocksdb/include/rocksdb lib/include
5 | libraryPaths.ios_arm64 = rocksdb/build/ios_arm64
6 | libraryPaths.ios_simulator_arm64 = rocksdb/build/ios_simulator_arm64
7 | libraryPaths.macos_arm64 = rocksdb/build/macos_arm64
8 | libraryPaths.macos_x64 = rocksdb/build/macos_x86_64
9 | libraryPaths.linux_arm64 = rocksdb/build/linux_arm64
10 | libraryPaths.linux_x64 = rocksdb/build/linux_x86_64
11 | libraryPaths.mingw_x64 = rocksdb/build/mingw_x86_64 rocksdb/build/mingw_x86_64/rocksdb-build
12 |
13 | noStringConversion = rocksdb_key_may_exist rocksdb_key_may_exist_cf rocksdb_get rocksdb_get_cf rocksdb_put rocksdb_put_cf rocksdb_delete rocksdb_delete_cf rocksdb_merge rocksdb_merge_cf rocksdb_create_column_family rocksdb_delete_range_cf rocksdb_iter_seek rocksdb_iter_seek_for_prev rocksdb_compact_range_cf_opt rocksdb_compact_range_cf rocksdb_compact_range_opt rocksdb_compact_range rocksdb_transaction_get rocksdb_transaction_get_cf rocksdb_transaction_get_for_update rocksdb_transaction_get_for_update_cf rocksdb_transaction_put rocksdb_transaction_put_cf rocksdb_transaction_put_untracked rocksdb_transaction_put_untracked_cf rocksdb_transaction_delete rocksdb_transaction_delete_cf rocksdb_transaction_merge rocksdb_transaction_merge_cf rocksdb_transaction_merge_untracked rocksdb_transaction_merge_untracked_cf rocksdb_transaction_delete_untracked rocksdb_transaction_delete_untracked_cf rocksdb_transaction_undo_get_for_update rocksdb_transaction_undo_get_for_update_cf rocksdb_writebatch_put rocksdb_writebatch_put_cf rocksdb_writebatch_merge rocksdb_writebatch_merge_cf rocksdb_writebatch_delete rocksdb_writebatch_delete_cf rocksdb_writebatch_singledelete rocksdb_writebatch_singledelete_cf rocksdb_writebatch_delete_range rocksdb_writebatch_delete_range_cf rocksdb_writebatch_put_log_data rocksdb_writebatch_wi_get_from_batch rocksdb_writebatch_wi_get_from_batch_cf rocksdb_writebatch_wi_merge rocksdb_writebatch_wi_merge_cf rocksdb_writebatch_wi_put rocksdb_writebatch_wi_put_cf rocksdb_writebatch_wi_delete rocksdb_writebatch_wi_delete_cf rocksdb_writebatch_wi_singledelete rocksdb_writebatch_wi_singledelete_cf rocksdb_writebatch_wi_delete_range rocksdb_writebatch_wi_delete_range_cf rocksdb_writebatch_wi_put_log_data rocksdb_transaction_put_log_data
14 |
--------------------------------------------------------------------------------
/src/nativeMain/kotlin/maryk/BooleanToUByte.kt:
--------------------------------------------------------------------------------
1 | package maryk
2 |
3 | internal fun Boolean.toUByte(): UByte = if (this) 1u else 0u
4 |
--------------------------------------------------------------------------------
/src/nativeMain/kotlin/maryk/Buffer.kt:
--------------------------------------------------------------------------------
1 | package maryk
2 |
3 | actual abstract class Buffer(
4 | internal var capacity: Int,
5 | internal var limit: Int,
6 | internal var position: Int = 0
7 | ) {
8 |
9 | actual abstract fun array(): Any
10 |
11 | open fun flip(): Buffer {
12 | limit = position
13 | position = 0
14 | return this
15 | }
16 |
17 | actual fun position(): Int = position
18 |
19 | actual fun remaining() = limit - position
20 |
21 | fun limit(newLimit: Int): Buffer {
22 | if (newLimit > capacity || newLimit < 0) throw IllegalArgumentException()
23 | limit = newLimit
24 | if (position > limit) position = limit
25 | return this
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/nativeMain/kotlin/maryk/UByteToBoolean.kt:
--------------------------------------------------------------------------------
1 | package maryk
2 |
3 | private val TRUE = 1u.toUByte()
4 | internal fun UByte.toBoolean() = when (this) {
5 | TRUE -> true
6 | else -> false
7 | }
8 |
--------------------------------------------------------------------------------
/src/nativeMain/kotlin/maryk/byteArrayToCPointer.kt:
--------------------------------------------------------------------------------
1 | package maryk
2 |
3 | import kotlinx.cinterop.ByteVar
4 | import kotlinx.cinterop.CArrayPointer
5 | import kotlinx.cinterop.MemScope
6 | import kotlinx.cinterop.allocArray
7 | import kotlinx.cinterop.set
8 |
9 | fun MemScope.byteArrayToCPointer(
10 | key: ByteArray,
11 | offset: Int,
12 | len: Int
13 | ): CArrayPointer {
14 | val cKey = allocArray(len)
15 | for (i in (0 until len)) {
16 | cKey[i] = key[i + offset]
17 | }
18 | return cKey
19 | }
20 |
--------------------------------------------------------------------------------
/src/nativeMain/kotlin/maryk/convertToStatus.kt:
--------------------------------------------------------------------------------
1 | package maryk
2 |
3 | import maryk.rocksdb.Status
4 | import maryk.rocksdb.getStatusCode
5 | import maryk.rocksdb.getStatusSubCode
6 |
7 | fun convertToStatus(error: String): Status? {
8 | val regex = Regex("""^\[(\d+)\|(\d+)]\s*(.+)$""")
9 | val matchResult = regex.find(error)
10 |
11 | return if (matchResult != null) {
12 | val (code, subcode, message) = matchResult.destructured
13 | Status(getStatusCode(code.toByte()), getStatusSubCode(subcode.toByte()), message)
14 | } else {
15 | null
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/nativeMain/kotlin/maryk/rocksdb/AbstractCompactionFilterContext.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | /**
4 | * Note that disposeInternal should be called only after all
5 | * RocksDB instances referencing the compaction filter are closed.
6 | * Otherwise an undefined behavior will occur.
7 | */
8 | actual abstract class AbstractCompactionFilter> protected constructor() : RocksObject()
9 |
10 | actual open class AbstractCompactionFilterContext(
11 | private val fullCompaction: Boolean,
12 | private val manualCompaction: Boolean
13 | ) {
14 | actual fun isFullCompaction() = fullCompaction
15 |
16 | actual fun isManualCompaction() = manualCompaction
17 | }
18 |
--------------------------------------------------------------------------------
/src/nativeMain/kotlin/maryk/rocksdb/AbstractCompactionFilterFactory.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual abstract class AbstractCompactionFilterFactory> actual constructor() :
4 | RocksCallbackObject() {
5 | actual abstract fun name(): String
6 |
7 | actual abstract fun createCompactionFilter(context: AbstractCompactionFilterContext): T
8 | }
9 |
--------------------------------------------------------------------------------
/src/nativeMain/kotlin/maryk/rocksdb/AbstractImmutableNativeReference.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | import kotlin.concurrent.AtomicReference
4 | import kotlin.experimental.ExperimentalNativeApi
5 | import kotlin.native.identityHashCode
6 |
7 | actual abstract class AbstractImmutableNativeReference(): AbstractNativeReference() {
8 | private val isClosed = AtomicReference(false)
9 |
10 | actual open fun isOwningHandle(): Boolean {
11 | return !isClosed.value
12 | }
13 |
14 | internal fun disownHandle() {
15 | isClosed.getAndSet(true)
16 | }
17 |
18 | actual override fun close() {
19 | isClosed.compareAndSet(false, true)
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/nativeMain/kotlin/maryk/rocksdb/AbstractMutableOptions.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual open class AbstractMutableOptions
4 |
--------------------------------------------------------------------------------
/src/nativeMain/kotlin/maryk/rocksdb/AbstractNativeReference.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual abstract class AbstractNativeReference : AutoCloseable
4 |
--------------------------------------------------------------------------------
/src/nativeMain/kotlin/maryk/rocksdb/AbstractSlice.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual abstract class AbstractSlice protected constructor() : RocksMutableObject() {
4 | abstract var data: T
5 |
6 | actual fun data(): T {
7 | return this.getData()
8 | }
9 |
10 | protected abstract fun getData(): T
11 |
12 | actual abstract fun removePrefix(n: Int)
13 |
14 | actual abstract fun clear()
15 |
16 | abstract operator fun get(offset: Int): Byte
17 |
18 | actual open fun size(): Int {
19 | throw NotImplementedError()
20 | }
21 |
22 | actual open fun empty(): Boolean {
23 | throw NotImplementedError()
24 | }
25 |
26 | actual open fun toString(hex: Boolean): String {
27 | throw NotImplementedError()
28 | }
29 |
30 | actual override fun toString(): String {
31 | return toString(false)
32 | }
33 |
34 | actual open fun compare(other: AbstractSlice<*>): Int {
35 | val minLength = minOf(this.size(), other.size())
36 |
37 | for (i in 0 until minLength) {
38 | val a = this[i].toInt() and 0xFF
39 | val b = other[i].toInt() and 0xFF
40 | if (a != b) {
41 | return a - b
42 | }
43 | }
44 |
45 | return this.size() - other.size()
46 | }
47 |
48 | actual override fun hashCode(): Int {
49 | return toString().hashCode()
50 | }
51 |
52 | actual override fun equals(other: Any?) = when (other) {
53 | null, !is AbstractSlice<*> -> false
54 | else -> {
55 | this.compare(other) == 0
56 | }
57 | }
58 |
59 | actual fun startsWith(prefix: AbstractSlice<*>): Boolean {
60 | if (prefix.size() == 0) return true
61 |
62 | if (prefix.size() > this.size()) return false
63 |
64 | for (i in 0 until prefix.size()) {
65 | if (this[i] != prefix[i]) {
66 | return false
67 | }
68 | }
69 | return true
70 | }
71 |
72 | override fun disposeInternal() {
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/src/nativeMain/kotlin/maryk/rocksdb/AbstractTraceWriter.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual abstract class AbstractTraceWriter actual constructor() : RocksCallbackObject(), TraceWriter
4 |
--------------------------------------------------------------------------------
/src/nativeMain/kotlin/maryk/rocksdb/AbstractTransactionNotifier.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual abstract class AbstractTransactionNotifier: RocksCallbackObject() {
4 | actual abstract fun snapshotCreated(newSnapshot: Snapshot)
5 | }
6 |
--------------------------------------------------------------------------------
/src/nativeMain/kotlin/maryk/rocksdb/AbstractWriteBatch.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual abstract class AbstractWriteBatch : RocksObject(), WriteBatchInterface {
4 |
5 | actual override fun singleDelete(key: ByteArray) {
6 | throw NotImplementedError()
7 | }
8 |
9 | actual override fun singleDelete(columnFamilyHandle: ColumnFamilyHandle, key: ByteArray) {
10 | throw NotImplementedError()
11 | }
12 |
13 | actual override fun count(): Int =
14 | throw NotImplementedError()
15 |
16 | actual override fun put(key: ByteArray, value: ByteArray) {
17 | throw NotImplementedError()
18 | }
19 |
20 | actual override fun put(columnFamilyHandle: ColumnFamilyHandle, key: ByteArray, value: ByteArray) {
21 | throw NotImplementedError()
22 | }
23 |
24 | actual override fun merge(key: ByteArray, value: ByteArray) {
25 | throw NotImplementedError()
26 | }
27 |
28 | actual override fun merge(columnFamilyHandle: ColumnFamilyHandle, key: ByteArray, value: ByteArray) {
29 | throw NotImplementedError()
30 | }
31 |
32 | actual override fun delete(key: ByteArray) {
33 | throw NotImplementedError()
34 | }
35 |
36 | actual override fun delete(columnFamilyHandle: ColumnFamilyHandle, key: ByteArray) {
37 | throw NotImplementedError()
38 | }
39 |
40 | actual override fun deleteRange(beginKey: ByteArray, endKey: ByteArray) {
41 | throw NotImplementedError()
42 | }
43 |
44 | actual override fun deleteRange(columnFamilyHandle: ColumnFamilyHandle, beginKey: ByteArray, endKey: ByteArray) {
45 | throw NotImplementedError()
46 | }
47 |
48 | actual override fun putLogData(blob: ByteArray) {
49 | throw NotImplementedError()
50 | }
51 |
52 | actual override fun clear() {
53 | throw NotImplementedError()
54 | }
55 |
56 | actual override fun setSavePoint() {
57 | throw NotImplementedError()
58 | }
59 |
60 | actual override fun rollbackToSavePoint() {
61 | throw NotImplementedError()
62 | }
63 |
64 | actual override fun popSavePoint() {
65 | throw NotImplementedError()
66 | }
67 |
68 | actual override fun setMaxBytes(maxBytes: Long) {
69 | throw NotImplementedError()
70 | }
71 |
72 | actual override fun getWriteBatch(): WriteBatch {
73 | throw NotImplementedError()
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/src/nativeMain/kotlin/maryk/rocksdb/BackupEngineOptions.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | import platform.posix.access
4 | import platform.posix.W_OK
5 | import rocksdb.rocksdb_backup_engine_options_create
6 | import rocksdb.rocksdb_backup_engine_options_destroy
7 |
8 | actual class BackupEngineOptions
9 | actual constructor(private val path: String)
10 | : RocksObject() {
11 |
12 | init {
13 | val pathToCheck = if (!path.endsWith('/')) "$path/" else path
14 | // Use POSIX access function to check write permission
15 | require(access(pathToCheck, W_OK) == 0) { "Path $path is not writable" }
16 | }
17 |
18 | val native = rocksdb_backup_engine_options_create(path)
19 |
20 | actual fun backupDir(): String {
21 | return path
22 | }
23 |
24 | override fun close() {
25 | if (isOwningHandle()) {
26 | rocksdb_backup_engine_options_destroy(native)
27 | super.close()
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/nativeMain/kotlin/maryk/rocksdb/BackupInfo.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual class BackupInfo
4 | internal constructor(
5 | private val backupId: Int,
6 | private val timestamp: Long,
7 | private val size: Long,
8 | private val numberFiles: Int,
9 | private val appMetadata: String?
10 | )
11 | {
12 | actual fun backupId() = backupId
13 |
14 | actual fun timestamp() = timestamp
15 |
16 | actual fun size() = size
17 |
18 | actual fun numberFiles(): Int = numberFiles
19 |
20 | actual fun appMetadata() = appMetadata
21 | }
22 |
--------------------------------------------------------------------------------
/src/nativeMain/kotlin/maryk/rocksdb/BottommostLevelCompaction.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | import maryk.rocksdb.BottommostLevelCompaction.kForce
4 | import maryk.rocksdb.BottommostLevelCompaction.kForceOptimized
5 | import maryk.rocksdb.BottommostLevelCompaction.kIfHaveCompactionFilter
6 | import maryk.rocksdb.BottommostLevelCompaction.kSkip
7 |
8 | actual enum class BottommostLevelCompaction(
9 | internal val value: UByte
10 | ) {
11 | kSkip(0u),
12 | kIfHaveCompactionFilter(1u),
13 | kForce(2u),
14 | kForceOptimized(3u)
15 | }
16 |
17 | fun bottommostLevelCompactionFromByte(bottommostLevelCompaction: UByte): BottommostLevelCompaction? {
18 | return when (bottommostLevelCompaction.toUInt()) {
19 | 0u -> kSkip
20 | 1u -> kIfHaveCompactionFilter
21 | 2u -> kForce
22 | 3u -> kForceOptimized
23 | else -> null
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/nativeMain/kotlin/maryk/rocksdb/BuiltinComparator.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual enum class BuiltinComparator {
4 | BYTEWISE_COMPARATOR,
5 | REVERSE_BYTEWISE_COMPARATOR
6 | }
7 |
--------------------------------------------------------------------------------
/src/nativeMain/kotlin/maryk/rocksdb/Cache.kt:
--------------------------------------------------------------------------------
1 | @file:OptIn(ExperimentalNativeApi::class)
2 |
3 | package maryk.rocksdb
4 |
5 | import cnames.structs.rocksdb_cache_t
6 | import kotlinx.cinterop.CPointer
7 | import kotlin.experimental.ExperimentalNativeApi
8 |
9 | actual abstract class Cache() : RocksObject() {
10 | protected lateinit var native: CPointer
11 |
12 | actual fun getUsage(): Long {
13 | assert(isOwningHandle());
14 | return rocksdb.rocksdb_cache_get_usage(native).toLong()
15 | }
16 |
17 | actual fun getPinnedUsage(): Long {
18 | assert(isOwningHandle());
19 | return rocksdb.rocksdb_cache_get_pinned_usage(native).toLong()
20 | }
21 |
22 | override fun close() {
23 | if (isOwningHandle()) {
24 | rocksdb.rocksdb_free(native)
25 | }
26 | super.close()
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/nativeMain/kotlin/maryk/rocksdb/Checkpoint.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | import cnames.structs.rocksdb_checkpoint_t
4 | import kotlinx.cinterop.CPointer
5 | import maryk.wrapWithErrorThrower
6 | import rocksdb.rocksdb_checkpoint_create
7 | import rocksdb.rocksdb_checkpoint_object_create
8 |
9 | actual class Checkpoint
10 | internal constructor(private val native: CPointer?)
11 | : RocksObject() {
12 | actual fun createCheckpoint(checkpointPath: String) {
13 | wrapWithErrorThrower { error ->
14 | rocksdb_checkpoint_create(native, checkpointPath, 1024u, error)
15 | }
16 | }
17 | }
18 |
19 | actual fun createCheckpoint(db: RocksDB): Checkpoint {
20 | check(db.isOwningHandle()) { "RocksDB instance must be initialized." }
21 | return Unit.wrapWithErrorThrower { error ->
22 | Checkpoint(
23 | rocksdb_checkpoint_object_create(db.native, error)
24 | )
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/nativeMain/kotlin/maryk/rocksdb/ChecksumType.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual enum class ChecksumType(
4 | internal val value: Byte
5 | ) {
6 | kNoChecksum(0),
7 | kCRC32c(1),
8 | kxxHash(2);
9 | }
10 |
--------------------------------------------------------------------------------
/src/nativeMain/kotlin/maryk/rocksdb/ColumnFamilyDescriptor.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual class ColumnFamilyDescriptor actual constructor(
4 | private val columnFamilyName: ByteArray,
5 | private val columnFamilyOptions: ColumnFamilyOptions
6 | ) {
7 | actual constructor(columnFamilyName: ByteArray) : this(columnFamilyName, ColumnFamilyOptions())
8 |
9 | actual fun getName() = columnFamilyName
10 |
11 | actual fun getOptions() = columnFamilyOptions
12 | }
13 |
--------------------------------------------------------------------------------
/src/nativeMain/kotlin/maryk/rocksdb/ColumnFamilyHandle.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | import cnames.structs.rocksdb_column_family_handle_t
4 | import kotlinx.cinterop.CPointer
5 | import kotlinx.cinterop.alloc
6 | import kotlinx.cinterop.memScoped
7 | import kotlinx.cinterop.ptr
8 | import kotlinx.cinterop.value
9 | import maryk.toByteArray
10 | import platform.posix.uint64_tVar
11 | import rocksdb.rocksdb_column_family_handle_destroy
12 | import rocksdb.rocksdb_column_family_handle_get_id
13 | import rocksdb.rocksdb_column_family_handle_get_name
14 |
15 | actual class ColumnFamilyHandle
16 | internal constructor(
17 | val native: CPointer
18 | )
19 | : RocksObject() {
20 | override fun close() {
21 | if (isOwningHandle()) {
22 | rocksdb_column_family_handle_destroy(native)
23 | super.close()
24 | }
25 | }
26 |
27 | actual fun getName(): ByteArray = memScoped {
28 | val length = alloc()
29 | rocksdb_column_family_handle_get_name(native, length.ptr)?.let { name ->
30 | name.toByteArray(length.value).also {
31 | rocksdb.rocksdb_free(name)
32 | }
33 | } ?: throw RocksDBException("Missing Column Family Name")
34 | }
35 |
36 | actual fun getID(): Int =
37 | rocksdb_column_family_handle_get_id(native).toInt()
38 | }
39 |
--------------------------------------------------------------------------------
/src/nativeMain/kotlin/maryk/rocksdb/ColumnFamilyMetaData.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual class ColumnFamilyMetaData internal constructor(
4 | val size: ULong,
5 | val fileCount: ULong,
6 | val name: String,
7 | val levels: List,
8 | ) {
9 | actual fun size(): Long = size.toLong()
10 |
11 | actual fun fileCount(): Long = fileCount.toLong()
12 |
13 | actual fun name(): ByteArray = name.encodeToByteArray()
14 |
15 | actual fun levels(): List = levels
16 | }
17 |
--------------------------------------------------------------------------------
/src/nativeMain/kotlin/maryk/rocksdb/CompactionPriority.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual enum class CompactionPriority(
4 | internal val value: Byte
5 | ) {
6 | ByCompensatedSize(0x0),
7 | OldestLargestSeqFirst(0x1),
8 | OldestSmallestSeqFirst(0x2),
9 | MinOverlappingRatio(0x3);
10 | }
11 |
12 | fun getCompactionPriority(value: Byte) =
13 | CompactionPriority.entries.firstOrNull { it.value == value }
14 | ?: throw IllegalArgumentException("Illegal value provided for CompactionPriority.")
15 |
--------------------------------------------------------------------------------
/src/nativeMain/kotlin/maryk/rocksdb/CompactionReason.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual enum class CompactionReason(
4 | internal val value: Byte
5 | ) {
6 | kUnknown(0x0),
7 | kLevelL0FilesNum(0x1),
8 | kLevelMaxLevelSize(0x2),
9 | kUniversalSizeAmplification(0x3),
10 | kUniversalSizeRatio(0x4),
11 | kUniversalSortedRunNum(0x5),
12 | kFIFOMaxSize(0x6),
13 | kFIFOReduceNumFiles(0x7),
14 | kFIFOTtl(0x8),
15 | kManualCompaction(0x9),
16 | kFilesMarkedForCompaction(0x10),
17 | kBottommostFiles(0x0A),
18 | kTtl(0x0B),
19 | kFlush(0x0C),
20 | kExternalSstIngestion(0x0D);
21 | }
22 |
--------------------------------------------------------------------------------
/src/nativeMain/kotlin/maryk/rocksdb/CompactionStopStyle.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual enum class CompactionStopStyle(
4 | internal val value: Byte
5 | ) {
6 | CompactionStopStyleSimilarSize(0),
7 | CompactionStopStyleTotalSize(1);
8 | }
9 |
10 | fun getCompactionStopStyle(value: Byte): CompactionStopStyle {
11 | for (compactionStopStyle in CompactionStopStyle.entries) {
12 | if (compactionStopStyle.value == value) {
13 | return compactionStopStyle
14 | }
15 | }
16 | throw IllegalArgumentException("Illegal value provided for CompactionStopStyle.")
17 | }
18 |
--------------------------------------------------------------------------------
/src/nativeMain/kotlin/maryk/rocksdb/CompactionStyle.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual enum class CompactionStyle(
4 | internal val value: Byte
5 | ) {
6 | LEVEL(0),
7 | UNIVERSAL(1),
8 | FIFO(2),
9 | NONE(3);
10 | }
11 |
12 | fun getCompactionStyle(value: Byte): CompactionStyle {
13 | for (compactionStyle in CompactionStyle.entries) {
14 | if (compactionStyle.value == value) {
15 | return compactionStyle
16 | }
17 | }
18 | throw IllegalArgumentException("Illegal value provided for CompactionStyle.")
19 | }
20 |
--------------------------------------------------------------------------------
/src/nativeMain/kotlin/maryk/rocksdb/ComparatorOptions.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual class ComparatorOptions
4 | actual constructor()
5 | : RocksObject()
6 |
--------------------------------------------------------------------------------
/src/nativeMain/kotlin/maryk/rocksdb/CompressionType.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | import maryk.rocksdb.CompressionType.NO_COMPRESSION
4 |
5 | actual enum class CompressionType(
6 | internal val value: Byte,
7 | private val libraryName: String?
8 | ) {
9 | NO_COMPRESSION(0x0, null),
10 | SNAPPY_COMPRESSION(0x1, "snappy"),
11 | ZLIB_COMPRESSION(0x2, "z"),
12 | BZLIB2_COMPRESSION(0x3, "bzip2"),
13 | LZ4_COMPRESSION(0x4, "lz4"),
14 | LZ4HC_COMPRESSION(0x5, "lz4hc"),
15 | XPRESS_COMPRESSION(0x6, "xpress"),
16 | ZSTD_COMPRESSION(0x7, "zstd"),
17 | DISABLE_COMPRESSION_OPTION(0x7f, null);
18 |
19 | actual fun getLibraryName() = libraryName
20 | }
21 |
22 | actual fun getCompressionType(libraryName: String?): CompressionType {
23 | if (libraryName != null) {
24 | for (compressionType in CompressionType.entries) {
25 | if (compressionType.getLibraryName() != null && compressionType.getLibraryName() == libraryName) {
26 | return compressionType
27 | }
28 | }
29 | }
30 | return NO_COMPRESSION
31 | }
32 |
33 | actual fun getCompressionType(byteIdentifier: Byte): CompressionType {
34 | for (compressionType in CompressionType.entries) {
35 | if (compressionType.value == byteIdentifier) {
36 | return compressionType
37 | }
38 | }
39 |
40 | throw IllegalArgumentException("Illegal value provided for CompressionType.")
41 | }
42 |
--------------------------------------------------------------------------------
/src/nativeMain/kotlin/maryk/rocksdb/DataBlockIndexType.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual enum class DataBlockIndexType(
4 | private val value: Byte
5 | ) {
6 | kDataBlockBinarySearch(0),
7 | kDataBlockBinaryAndHash(1);
8 | }
9 |
--------------------------------------------------------------------------------
/src/nativeMain/kotlin/maryk/rocksdb/DirectSlice.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | import kotlinx.cinterop.Arena
4 | import kotlinx.cinterop.ByteVar
5 | import kotlinx.cinterop.alloc
6 | import kotlinx.cinterop.nativeHeap
7 | import kotlinx.cinterop.plus
8 | import kotlinx.cinterop.ptr
9 | import kotlinx.cinterop.toCValues
10 | import maryk.ByteBuffer
11 | import maryk.DirectByteBuffer
12 | import maryk.toByteArray
13 |
14 | actual class DirectSlice() : AbstractSlice() {
15 | private val scope = Arena()
16 | override lateinit var data: ByteBuffer
17 |
18 | override fun disposeInternal() {
19 | scope.clear()
20 | super.disposeInternal()
21 | }
22 | actual constructor(str: String) : this() {
23 | data = DirectByteBuffer(str.encodeToByteArray().toCValues().getPointer(scope), str.length)
24 | }
25 |
26 | actual constructor(data: ByteBuffer) : this() {
27 | this.data = data
28 | }
29 |
30 | actual constructor(data: ByteBuffer, length: Int) : this(
31 | DirectByteBuffer(data.nativePointer, length)
32 | )
33 |
34 | override fun getData(): ByteBuffer = data
35 |
36 | actual override operator fun get(offset: Int): Byte {
37 | return data[offset]
38 | }
39 |
40 | actual override fun clear() {
41 | data = DirectByteBuffer(emptyByte.ptr, 0)
42 | }
43 |
44 | actual override fun removePrefix(n: Int) {
45 | require(n < data.capacity)
46 | data = DirectByteBuffer(data.nativePointer.plus(n)!!, data.capacity - n)
47 | }
48 |
49 | override fun size(): Int = data.capacity
50 |
51 | override fun empty(): Boolean = data.capacity == 0
52 |
53 | @OptIn(ExperimentalStdlibApi::class)
54 | override fun toString(hex: Boolean): String {
55 | return data.nativePointer.toByteArray(data.capacity.toULong()).let { bytes ->
56 | if (hex) bytes.toHexString() else bytes.decodeToString().replace("\u0000", "")
57 | }
58 | }
59 | }
60 | private val emptyByte = nativeHeap.alloc()
61 | actual val DirectSliceNone = DirectSlice(DirectByteBuffer(emptyByte.ptr, 0))
62 |
--------------------------------------------------------------------------------
/src/nativeMain/kotlin/maryk/rocksdb/EncodingType.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | import maryk.rocksdb.EncodingType.kPlain
4 | import maryk.rocksdb.EncodingType.kPrefix
5 |
6 | actual enum class EncodingType(
7 | internal val value: Byte
8 | ) {
9 | kPlain(0),
10 | kPrefix(1);
11 | }
12 |
13 | internal fun toEncodingType(value: Byte) = when (value) {
14 | 0.toByte() -> kPlain
15 | 1.toByte() -> kPrefix
16 | else -> throw RocksDBException("Unrecognized $value for EncodingType")
17 | }
18 |
--------------------------------------------------------------------------------
/src/nativeMain/kotlin/maryk/rocksdb/Env.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | import cnames.structs.rocksdb_env_t
4 | import kotlinx.cinterop.CPointer
5 | import rocksdb.rocksdb_create_default_env
6 |
7 | actual abstract class Env
8 | protected constructor(internal val native: CPointer?)
9 | : RocksObject() {
10 | actual fun getBackgroundThreads(priority: Priority): Int =
11 | rocksdb.rocksdb_env_get_background_threads_with_priority(native, priority.value.toInt())
12 |
13 | actual fun setBackgroundThreads(number: Int, priority: Priority): Env {
14 | rocksdb.rocksdb_env_set_background_threads_with_priority(native, number, priority.value.toInt())
15 | return this
16 | }
17 |
18 | actual fun getThreadPoolQueueLen(priority: Priority): Int =
19 | rocksdb.rocksdb_env_get_thread_pool_queue_length(native)
20 |
21 | actual fun incBackgroundThreadsIfNeeded(number: Int, priority: Priority): Env {
22 | rocksdb.rocksdb_env_inc_background_threads_if_needed(native, number, priority.value.toInt())
23 | return this
24 | }
25 |
26 | actual fun lowerThreadPoolIOPriority(priority: Priority): Env {
27 | rocksdb.rocksdb_env_lower_with_priority_thread_pool_io_priority(native, priority.value.toInt())
28 | return this
29 | }
30 |
31 | actual fun lowerThreadPoolCPUPriority(priority: Priority): Env {
32 | rocksdb.rocksdb_env_lower_with_priority_thread_pool_cpu_priority(native, priority.value.toInt())
33 | return this
34 | }
35 |
36 | override fun close() {
37 | if (isOwningHandle()) {
38 | rocksdb.rocksdb_env_destroy(native)
39 | }
40 | super.close()
41 | }
42 | }
43 |
44 | actual fun getDefaultEnv(): Env = RocksEnv(rocksdb_create_default_env())
45 |
--------------------------------------------------------------------------------
/src/nativeMain/kotlin/maryk/rocksdb/FilterPolicy.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual abstract class FilterPolicy : RocksObject()
4 |
--------------------------------------------------------------------------------
/src/nativeMain/kotlin/maryk/rocksdb/GetStatus.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual class GetStatus internal constructor(
4 | internal val status: Status,
5 | internal val requiredSize: Int
6 | )
7 |
8 | actual fun GetStatus.getStatus(): Status = this.status
9 |
10 | actual fun GetStatus.getRequiredSize(): Int = this.requiredSize
11 |
--------------------------------------------------------------------------------
/src/nativeMain/kotlin/maryk/rocksdb/HistogramData.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | import cnames.structs.rocksdb_statistics_histogram_data_t
4 | import kotlinx.cinterop.CPointer
5 |
6 | actual class HistogramData(
7 | val median: Double,
8 | val p95: Double,
9 | val p99: Double,
10 | val average: Double,
11 | val stdDev: Double,
12 | val max: Double,
13 | val count: ULong,
14 | val sum: ULong,
15 | val min: Double,
16 | ) {
17 | actual fun getMedian(): Double = median
18 |
19 | actual fun getPercentile95(): Double = p95
20 |
21 | actual fun getPercentile99(): Double = p99
22 |
23 | actual fun getAverage(): Double = average
24 |
25 | actual fun getStandardDeviation(): Double = stdDev
26 |
27 | actual fun getMax(): Double = max
28 |
29 | actual fun getCount(): Long = count.toLong()
30 |
31 | actual fun getSum(): Long = sum.toLong()
32 |
33 | actual fun getMin(): Double = min
34 | }
35 |
--------------------------------------------------------------------------------
/src/nativeMain/kotlin/maryk/rocksdb/HistogramType.kt:
--------------------------------------------------------------------------------
1 | @file:Suppress("unused")
2 |
3 | package maryk.rocksdb
4 |
5 | actual enum class HistogramType(
6 | internal val value: UInt
7 | ) {
8 | DB_GET(0x0u),
9 | DB_WRITE(0x1u),
10 | COMPACTION_TIME(0x2u),
11 | COMPACTION_CPU_TIME(0x3u),
12 | SUBCOMPACTION_SETUP_TIME(0x4u),
13 | TABLE_SYNC_MICROS(0x5u),
14 | COMPACTION_OUTFILE_SYNC_MICROS(0x6u),
15 | WAL_FILE_SYNC_MICROS(0x7u),
16 | MANIFEST_FILE_SYNC_MICROS(0x8u),
17 | TABLE_OPEN_IO_MICROS(0x9u),
18 | DB_MULTIGET(0xAu),
19 | READ_BLOCK_COMPACTION_MICROS(0xBu),
20 | READ_BLOCK_GET_MICROS(0xCu),
21 | WRITE_RAW_BLOCK_MICROS(0xDu),
22 | NUM_FILES_IN_SINGLE_COMPACTION(0xEu),
23 | DB_SEEK(0xFu),
24 | WRITE_STALL(0x10u),
25 | SST_READ_MICROS(0x11u),
26 | FILE_READ_FLUSH_MICROS(0x12u),
27 | FILE_READ_COMPACTION_MICROS(0x13u),
28 | FILE_READ_DB_OPEN_MICROS(0x14u),
29 | FILE_READ_GET_MICROS(0x15u),
30 | FILE_READ_MULTIGET_MICROS(0x16u),
31 | FILE_READ_DB_ITERATOR_MICROS(0x17u),
32 | FILE_READ_VERIFY_DB_CHECKSUM_MICROS(0x18u),
33 | FILE_READ_VERIFY_FILE_CHECKSUMS_MICROS(0x19u),
34 | SST_WRITE_MICROS(0x1Au),
35 | FILE_WRITE_FLUSH_MICROS(0x1Bu),
36 | FILE_WRITE_COMPACTION_MICROS(0x1Cu),
37 | FILE_WRITE_DB_OPEN_MICROS(0x1Du),
38 | NUM_SUBCOMPACTIONS_SCHEDULED(0x1Eu),
39 | BYTES_PER_READ(0x1Fu),
40 | BYTES_PER_WRITE(0x20u),
41 | BYTES_PER_MULTIGET(0x21u),
42 | COMPRESSION_TIMES_NANOS(0x22u),
43 | DECOMPRESSION_TIMES_NANOS(0x23u),
44 | READ_NUM_MERGE_OPERANDS(0x24u),
45 | BLOB_DB_KEY_SIZE(0x25u),
46 | BLOB_DB_VALUE_SIZE(0x26u),
47 | BLOB_DB_WRITE_MICROS(0x27u),
48 | BLOB_DB_GET_MICROS(0x28u),
49 | BLOB_DB_MULTIGET_MICROS(0x29u),
50 | BLOB_DB_SEEK_MICROS(0x2Au),
51 | BLOB_DB_NEXT_MICROS(0x2Bu),
52 | BLOB_DB_PREV_MICROS(0x2Cu),
53 | BLOB_DB_BLOB_FILE_WRITE_MICROS(0x2Du),
54 | BLOB_DB_BLOB_FILE_READ_MICROS(0x2Eu),
55 | BLOB_DB_BLOB_FILE_SYNC_MICROS(0x2Fu),
56 | BLOB_DB_COMPRESSION_MICROS(0x30u),
57 | BLOB_DB_DECOMPRESSION_MICROS(0x31u),
58 | FLUSH_TIME(0x32u),
59 | SST_BATCH_SIZE(0x33u),
60 | MULTIGET_IO_BATCH_SIZE(0x34u),
61 | NUM_INDEX_AND_FILTER_BLOCKS_READ_PER_LEVEL(0x35u),
62 | NUM_SST_READ_PER_LEVEL(0x36u),
63 | NUM_LEVEL_READ_PER_MULTIGET(0x37u),
64 | ERROR_HANDLER_AUTORESUME_RETRY_COUNT(0x38u),
65 | ASYNC_READ_BYTES(0x39u),
66 | POLL_WAIT_MICROS(0x3Au),
67 | PREFETCHED_BYTES_DISCARDED(0x3Bu),
68 | ASYNC_PREFETCH_ABORT_MICROS(0x3Cu),
69 | TABLE_OPEN_PREFETCH_TAIL_READ_BYTES(0x3Du),
70 | HISTOGRAM_ENUM_MAX(0x3Eu);
71 | }
72 |
--------------------------------------------------------------------------------
/src/nativeMain/kotlin/maryk/rocksdb/Holder.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | /** Simple instance reference wrapper. */
4 | actual class Holder {
5 | private var value: T?
6 |
7 | /** Constructs a new Holder with null instance. */
8 | actual constructor() {
9 | this.value = null
10 | }
11 |
12 | /**
13 | * Constructs a new Holder.
14 | * [value] the instance or null
15 | */
16 | actual constructor(value: T?) {
17 | this.value = value
18 | }
19 |
20 | /** Get the instance reference. */
21 | actual fun getValue() = this.value
22 |
23 | /** Set the instance reference. */
24 | actual fun setValue(value: T?) {
25 | this.value = value
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/nativeMain/kotlin/maryk/rocksdb/IndexType.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual enum class IndexType(
4 | internal val value: Byte
5 | ) {
6 | kBinarySearch(0),
7 | kHashSearch(1),
8 | kTwoLevelIndexSearch(2);
9 | }
10 |
--------------------------------------------------------------------------------
/src/nativeMain/kotlin/maryk/rocksdb/InfoLogLevel.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual enum class InfoLogLevel(
4 | internal val value: UByte
5 | ) {
6 | DEBUG_LEVEL(0u),
7 | INFO_LEVEL(1u),
8 | WARN_LEVEL(2u),
9 | ERROR_LEVEL(3u),
10 | FATAL_LEVEL(4u),
11 | HEADER_LEVEL(5u),
12 | NUM_INFO_LOG_LEVELS(6u);
13 | }
14 |
15 | /**
16 | * Get InfoLogLevel by byte value.
17 | *
18 | * @param value byte representation of InfoLogLevel.
19 | *
20 | * @return [InfoLogLevel] instance.
21 | * @throws IllegalArgumentException if an invalid
22 | * value is provided.
23 | */
24 | fun getInfoLogLevel(value: UByte): InfoLogLevel {
25 | for (infoLogLevel in InfoLogLevel.entries) {
26 | if (infoLogLevel.value == value) {
27 | return infoLogLevel
28 | }
29 | }
30 | throw IllegalArgumentException("Illegal value provided for InfoLogLevel.")
31 | }
32 |
--------------------------------------------------------------------------------
/src/nativeMain/kotlin/maryk/rocksdb/LRUCache.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | import cnames.structs.rocksdb_lru_cache_options_t
4 | import kotlinx.cinterop.CPointer
5 |
6 | actual class LRUCache private constructor() : Cache() {
7 | lateinit var options: CPointer
8 |
9 | actual constructor(capacity: Long) : this(capacity, -1, false, 0.0, 0.0)
10 |
11 | actual constructor(capacity: Long, numShardBits: Int) : this(capacity, numShardBits, false, 0.0, 0.0)
12 |
13 | constructor(capacity: Long, numShardBits: Int, strictCapacityLimit: Boolean) : this(capacity, numShardBits, strictCapacityLimit, 0.0, 0.0)
14 |
15 | constructor(
16 | capacity: Long,
17 | numShardBits: Int,
18 | strictCapacityLimit: Boolean,
19 | highPriPoolRatio: Double
20 | ) : this(capacity, numShardBits, strictCapacityLimit, highPriPoolRatio, 0.0)
21 |
22 | constructor(
23 | capacity: Long,
24 | numShardBits: Int,
25 | strictCapacityLimit: Boolean,
26 | highPriPoolRatio: Double,
27 | lowPriPoolRatio: Double
28 | ) : this() {
29 | options = rocksdb.rocksdb_lru_cache_options_create()!!.apply {
30 | rocksdb.rocksdb_lru_cache_options_set_capacity(this, capacity.toULong())
31 | rocksdb.rocksdb_lru_cache_options_set_num_shard_bits(this, numShardBits)
32 | }
33 |
34 | native = rocksdb.rocksdb_cache_create_lru_opts(options)!!
35 | }
36 |
37 | override fun close() {
38 | if (isOwningHandle()) {
39 | rocksdb.rocksdb_free(options)
40 | }
41 | super.close()
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/nativeMain/kotlin/maryk/rocksdb/LevelMetaData.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual class LevelMetaData(
4 | val level: Int,
5 | val size: ULong,
6 | val files: List,
7 | ) {
8 | actual fun level() = level.toInt()
9 |
10 | actual fun size() = size.toLong()
11 |
12 | actual fun files() = files
13 | }
14 |
--------------------------------------------------------------------------------
/src/nativeMain/kotlin/maryk/rocksdb/MemTableConfig.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual abstract class MemTableConfig actual constructor()
4 |
--------------------------------------------------------------------------------
/src/nativeMain/kotlin/maryk/rocksdb/MemoryUsageType.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual enum class MemoryUsageType(
4 | private val value: Byte
5 | ) {
6 | kMemTableTotal(0),
7 | kMemTableUnFlushed(1),
8 | kTableReadersTotal(2),
9 | kCacheTotal(3),
10 | kNumUsageTypes(4);
11 |
12 | actual fun getValue() = value
13 | }
14 |
--------------------------------------------------------------------------------
/src/nativeMain/kotlin/maryk/rocksdb/OptimisticTransactionDB.kt:
--------------------------------------------------------------------------------
1 | @file:OptIn(ExperimentalNativeApi::class)
2 |
3 | package maryk.rocksdb
4 |
5 | import cnames.structs.rocksdb_optimistictransactiondb_t
6 | import kotlinx.cinterop.*
7 | import kotlin.experimental.ExperimentalNativeApi
8 |
9 | actual open class OptimisticTransactionDB
10 | internal constructor(
11 | internal val tnative: CPointer,
12 | ) : RocksDB(rocksdb.rocksdb_optimistictransactiondb_get_base_db(tnative)!!) {
13 | val defaultTransactionOptions: OptimisticTransactionOptions = OptimisticTransactionOptions()
14 |
15 | override fun close() {
16 | if (isOwningHandle()) {
17 | defaultTransactionOptions.close()
18 | super.close()
19 | }
20 | }
21 |
22 | actual fun beginTransaction(writeOptions: WriteOptions): Transaction {
23 | return rocksdb.rocksdb_optimistictransaction_begin(tnative, writeOptions.native, defaultTransactionOptions.native, null)!!.let(::Transaction)
24 | }
25 |
26 | actual fun beginTransaction(writeOptions: WriteOptions, transactionOptions: OptimisticTransactionOptions): Transaction {
27 | return rocksdb.rocksdb_optimistictransaction_begin(tnative, writeOptions.native, transactionOptions.native, null)!!.let(::Transaction)
28 | }
29 |
30 | actual fun beginTransaction(writeOptions: WriteOptions, oldTransaction: Transaction): Transaction {
31 | rocksdb.rocksdb_optimistictransaction_begin(tnative, writeOptions.native, defaultTransactionOptions.native, oldTransaction.native)
32 | return oldTransaction
33 | }
34 |
35 | actual fun beginTransaction(writeOptions: WriteOptions, transactionOptions: OptimisticTransactionOptions, oldTransaction: Transaction): Transaction {
36 | rocksdb.rocksdb_optimistictransaction_begin(tnative, writeOptions.native, transactionOptions.native, oldTransaction.native)
37 | return oldTransaction
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/src/nativeMain/kotlin/maryk/rocksdb/OptimisticTransactionOptions.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | import maryk.toBoolean
4 | import maryk.toUByte
5 |
6 | actual class OptimisticTransactionOptions actual constructor(): RocksObject() {
7 | val native = rocksdb.rocksdb_optimistictransaction_options_create()
8 |
9 | actual fun isSetSnapshot(): Boolean {
10 | return rocksdb.rocksdb_optimistictransaction_options_get_set_snapshot(native).toBoolean()
11 | }
12 |
13 | actual fun setSetSnapshot(setSnapshot: Boolean): OptimisticTransactionOptions {
14 | rocksdb.rocksdb_optimistictransaction_options_set_set_snapshot(native, setSnapshot.toUByte())
15 | return this
16 | }
17 |
18 | override fun close() {
19 | if (isOwningHandle()) {
20 | rocksdb.rocksdb_optimistictransaction_options_destroy(native)
21 | super.close()
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/nativeMain/kotlin/maryk/rocksdb/Priority.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual enum class Priority(
4 | internal val value: UByte
5 | ) {
6 | BOTTOM(0u),
7 | LOW(1u),
8 | HIGH(2u),
9 | USER(3u),
10 | TOTAL(4u);
11 | }
12 |
--------------------------------------------------------------------------------
/src/nativeMain/kotlin/maryk/rocksdb/Range.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual class Range actual constructor(start: Slice, limit: Slice)
4 |
--------------------------------------------------------------------------------
/src/nativeMain/kotlin/maryk/rocksdb/ReadOptions.kt:
--------------------------------------------------------------------------------
1 | @file:OptIn(ExperimentalNativeApi::class)
2 |
3 | package maryk.rocksdb
4 |
5 | import cnames.structs.rocksdb_readoptions_t
6 | import kotlinx.cinterop.CPointer
7 | import maryk.toBoolean
8 | import maryk.toUByte
9 | import rocksdb.rocksdb_readoptions_create
10 | import rocksdb.rocksdb_readoptions_destroy
11 | import rocksdb.rocksdb_readoptions_get_fill_cache
12 | import rocksdb.rocksdb_readoptions_get_prefix_same_as_start
13 | import rocksdb.rocksdb_readoptions_get_verify_checksums
14 | import rocksdb.rocksdb_readoptions_set_fill_cache
15 | import rocksdb.rocksdb_readoptions_set_prefix_same_as_start
16 | import rocksdb.rocksdb_readoptions_set_verify_checksums
17 | import kotlin.experimental.ExperimentalNativeApi
18 |
19 | actual class ReadOptions private constructor(val native: CPointer?) : RocksObject() {
20 | actual constructor() : this(rocksdb_readoptions_create())
21 |
22 | override fun close() {
23 | if (isOwningHandle()) {
24 | rocksdb_readoptions_destroy(native)
25 | super.close()
26 | }
27 | }
28 |
29 | actual fun verifyChecksums(): Boolean {
30 | assert(isOwningHandle())
31 | return rocksdb_readoptions_get_verify_checksums(native).toBoolean()
32 | }
33 |
34 | actual fun setVerifyChecksums(verifyChecksums: Boolean): ReadOptions {
35 | assert(isOwningHandle())
36 | rocksdb_readoptions_set_verify_checksums(native, verifyChecksums.toUByte())
37 | return this
38 | }
39 |
40 | actual fun fillCache(): Boolean {
41 | assert(isOwningHandle())
42 | return rocksdb_readoptions_get_fill_cache(native).toBoolean()
43 | }
44 |
45 | actual fun setFillCache(fillCache: Boolean): ReadOptions {
46 | assert(isOwningHandle())
47 | rocksdb_readoptions_set_fill_cache(native, fillCache.toUByte())
48 | return this
49 | }
50 |
51 | actual fun prefixSameAsStart(): Boolean {
52 | assert(isOwningHandle())
53 | return rocksdb_readoptions_get_prefix_same_as_start(native).toBoolean()
54 | }
55 |
56 | actual fun setPrefixSameAsStart(prefixSameAsStart: Boolean): ReadOptions {
57 | assert(isOwningHandle())
58 | rocksdb_readoptions_set_prefix_same_as_start(native, prefixSameAsStart.toUByte())
59 | return this;
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/src/nativeMain/kotlin/maryk/rocksdb/ReadTier.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual enum class ReadTier(
4 | private val value: Byte
5 | ) {
6 | READ_ALL_TIER(0),
7 | BLOCK_CACHE_TIER(1),
8 | PERSISTED_TIER(2),
9 | MEMTABLE_TIER(3);
10 |
11 | actual fun getValue() = value
12 | }
13 |
--------------------------------------------------------------------------------
/src/nativeMain/kotlin/maryk/rocksdb/RemoveEmptyValueCompactionFilter.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual class RemoveEmptyValueCompactionFilter actual constructor() : AbstractCompactionFilter()
4 |
--------------------------------------------------------------------------------
/src/nativeMain/kotlin/maryk/rocksdb/RestoreOptions.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | import rocksdb.rocksdb_restore_options_create
4 | import rocksdb.rocksdb_restore_options_destroy
5 | import rocksdb.rocksdb_restore_options_set_keep_log_files
6 |
7 | actual class RestoreOptions actual constructor(
8 | val keepLogFiles: Boolean
9 | ) : RocksObject() {
10 | val native = rocksdb_restore_options_create()
11 |
12 | init {
13 | rocksdb_restore_options_set_keep_log_files(native, if (keepLogFiles) 1 else 0)
14 | }
15 |
16 | override fun close() {
17 | if (isOwningHandle()) {
18 | rocksdb_restore_options_destroy(native)
19 | super.close()
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/nativeMain/kotlin/maryk/rocksdb/RocksCallbackObject.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual abstract class RocksCallbackObject : AbstractImmutableNativeReference()
4 |
--------------------------------------------------------------------------------
/src/nativeMain/kotlin/maryk/rocksdb/RocksDBException.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual class RocksDBException
4 | actual constructor(msg: String, private val status: Status?)
5 | : Exception(msg) {
6 | actual constructor(msg: String) : this(msg, null)
7 |
8 | actual constructor(status: Status) : this(
9 | status.getState() ?: status.getCodeString(),
10 | status
11 | )
12 |
13 | actual fun getStatus() = status
14 | }
15 |
--------------------------------------------------------------------------------
/src/nativeMain/kotlin/maryk/rocksdb/RocksEnv.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | import cnames.structs.rocksdb_env_t
4 | import kotlinx.cinterop.CPointer
5 |
6 | /**
7 | * A RocksEnv is an interface used by the rocksdb implementation to access
8 | * operating system functionality like the filesystem etc.
9 | *
10 | * All Env implementations are safe for concurrent access from
11 | * multiple threads without any external synchronization.
12 | */
13 | class RocksEnv
14 | /**
15 | * Internal constructor that uses the specified native handle
16 | * to construct a RocksEnv.
17 | *
18 | * Note that the ownership of the input handle
19 | * belongs to the caller, and the newly created RocksEnv will not take
20 | * the ownership of the input handle. As a result, calling
21 | * `dispose()` of the created RocksEnv will be no-op.
22 | */
23 | internal constructor(native: CPointer?) : Env(native) {
24 |
25 | override fun equals(other: Any?): Boolean {
26 | if (other !is RocksEnv) return false
27 | if (this.native === other.native) return true
28 | return true
29 | }
30 |
31 | override fun hashCode(): Int {
32 | return this.native.hashCode()
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/nativeMain/kotlin/maryk/rocksdb/RocksIterator.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | import cnames.structs.rocksdb_iterator_t
4 | import kotlinx.cinterop.*
5 | import maryk.toByteArray
6 | import platform.posix.size_tVar
7 | import rocksdb.rocksdb_iter_key
8 | import rocksdb.rocksdb_iter_value
9 |
10 | actual class RocksIterator internal constructor(
11 | native: CPointer
12 | ) : AbstractRocksIterator(native) {
13 | actual fun key(): ByteArray = memScoped {
14 | val length = alloc()
15 | rocksdb_iter_key(native, length.ptr)!!.toByteArray(length.value)
16 | }
17 |
18 | actual fun value(): ByteArray = memScoped {
19 | val length = alloc()
20 | rocksdb_iter_value(native, length.ptr)!!.toByteArray(length.value)
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/nativeMain/kotlin/maryk/rocksdb/RocksIteratorInterface.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual interface RocksIteratorInterface {
4 | actual fun isValid(): Boolean
5 |
6 | actual fun seekToFirst()
7 |
8 | actual fun seekToLast()
9 |
10 | actual fun seek(target: ByteArray)
11 |
12 | actual fun seekForPrev(target: ByteArray)
13 |
14 | actual fun next()
15 |
16 | actual fun prev()
17 |
18 | actual fun status()
19 | }
20 |
--------------------------------------------------------------------------------
/src/nativeMain/kotlin/maryk/rocksdb/RocksMutableObject.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual abstract class RocksMutableObject : AbstractNativeReference() {
4 | protected abstract fun disposeInternal()
5 | actual override final fun close() {
6 | disposeInternal()
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/src/nativeMain/kotlin/maryk/rocksdb/RocksObject.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual abstract class RocksObject: AbstractImmutableNativeReference()
4 |
--------------------------------------------------------------------------------
/src/nativeMain/kotlin/maryk/rocksdb/SizeApproximationFlag.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual enum class SizeApproximationFlag(
4 | internal val value: Byte
5 | ) {
6 | NONE(0x0),
7 | INCLUDE_MEMTABLES(0x1),
8 | INCLUDE_FILES(0x2)
9 | }
10 |
--------------------------------------------------------------------------------
/src/nativeMain/kotlin/maryk/rocksdb/Slice.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual class Slice actual constructor(
4 | override var data: ByteArray
5 | ) : AbstractSlice() {
6 | actual constructor(str: String) : this(str.encodeToByteArray())
7 |
8 | actual constructor(data: ByteArray, offset: Int) : this(data.copyOfRange(offset, data.size))
9 |
10 | override fun getData(): ByteArray {
11 | return data
12 | }
13 |
14 | actual override fun clear() {
15 | data = ByteArray(0)
16 | }
17 |
18 | actual override fun removePrefix(n: Int) {
19 | data = data.copyOfRange(n, data.size)
20 | }
21 |
22 | override fun size(): Int {
23 | return data.size.toInt()
24 | }
25 |
26 | override fun empty(): Boolean {
27 | return data.isEmpty()
28 | }
29 |
30 | @OptIn(ExperimentalStdlibApi::class)
31 | override fun toString(hex: Boolean): String {
32 | return if (hex) {
33 | data.toHexString()
34 | } else data.decodeToString()
35 | }
36 |
37 | override operator fun get(offset: Int): Byte {
38 | return data[offset]
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/nativeMain/kotlin/maryk/rocksdb/Snapshot.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | import cnames.structs.rocksdb_snapshot_t
4 | import kotlinx.cinterop.CPointer
5 |
6 | actual class Snapshot internal constructor(
7 | internal val native: CPointer
8 | ) : RocksObject() {
9 | actual fun getSequenceNumber() = rocksdb.rocksdb_snapshot_get_sequence_number(native).toLong()
10 |
11 | override fun close() {
12 | if (isOwningHandle()) {
13 | rocksdb.rocksdb_free(native)
14 | }
15 | super.close()
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/nativeMain/kotlin/maryk/rocksdb/SstFileMetaData.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual class SstFileMetaData(
4 | val fileName: String,
5 | val path: String,
6 | val size: ULong,
7 | val smallestKey: ByteArray,
8 | val largestKey: ByteArray,
9 | ) {
10 | actual fun fileName() = fileName
11 |
12 | actual fun path() = path
13 |
14 | actual fun size() = size.toLong()
15 |
16 | actual fun smallestKey(): ByteArray = smallestKey
17 |
18 | actual fun largestKey(): ByteArray = largestKey
19 | }
20 |
--------------------------------------------------------------------------------
/src/nativeMain/kotlin/maryk/rocksdb/StatsLevel.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual enum class StatsLevel(
4 | internal val value: UByte
5 | ) {
6 | DISABLE_ALL(0u),
7 | EXCEPT_TICKERS(1u),
8 | EXCEPT_HISTOGRAM_OR_TIMERS(2u),
9 | EXCEPT_TIMERS(3u),
10 | EXCEPT_DETAILED_TIMERS(4u),
11 | EXCEPT_TIME_FOR_MUTEX(5u),
12 | ALL(6u);
13 | }
14 |
15 | fun getStatsLevel(value: UByte): StatsLevel {
16 | for (level in StatsLevel.entries) {
17 | if (level.value == value) {
18 | return level
19 | }
20 | }
21 | throw IllegalArgumentException("Illegal value provided for StatsLevel.")
22 | }
23 |
--------------------------------------------------------------------------------
/src/nativeMain/kotlin/maryk/rocksdb/Status.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | import maryk.rocksdb.StatusSubCode.None
4 | import maryk.rocksdb.StatusSubCode.Undefined
5 |
6 | actual class Status actual constructor(
7 | private val code: StatusCode,
8 | private val subCode: StatusSubCode?,
9 | private val state: String?
10 | ) {
11 |
12 | actual fun getCode() = code
13 |
14 | actual fun getSubCode() = subCode
15 |
16 | actual fun getState() = state
17 |
18 | actual fun getCodeString() =
19 | code.name + if (subCode != null && subCode != None) {
20 | "(${subCode.name})"
21 | } else ""
22 | }
23 |
24 | actual enum class StatusCode(
25 | internal val value: Byte
26 | ) {
27 | Ok(0x0),
28 | NotFound(0x1),
29 | Corruption(0x2),
30 | NotSupported(0x3),
31 | InvalidArgument(0x4),
32 | IOError(0x5),
33 | MergeInProgress(0x6),
34 | Incomplete(0x7),
35 | ShutdownInProgress(0x8),
36 | TimedOut(0x9),
37 | Aborted(0xA),
38 | Busy(0xB),
39 | Expired(0xC),
40 | TryAgain(0xD),
41 | Undefined(0x7F)
42 | }
43 |
44 | fun getStatusCode(identifier: Byte): StatusCode {
45 | for (statusCode in StatusCode.entries) {
46 | if (statusCode.value == identifier) {
47 | return statusCode
48 | }
49 | }
50 |
51 | throw IllegalArgumentException("Illegal value provided for StatusCode.")
52 | }
53 |
54 | actual enum class StatusSubCode(
55 | internal val value: Byte
56 | ) {
57 | None(0x0),
58 | MutexTimeout(0x1),
59 | LockTimeout(0x2),
60 | LockLimit(0x3),
61 | NoSpace(0x4),
62 | Deadlock(0x5),
63 | StaleFile(0x6),
64 | MemoryLimit(0x7),
65 | SpaceLimit(0x8),
66 | PathNotFound(0x9),
67 | MaxSubCode(0x10),
68 | Undefined(0x7F)
69 | }
70 |
71 | fun getStatusSubCode(identifier: Byte): StatusSubCode {
72 | for (statusSubCode in StatusSubCode.entries) {
73 | if (statusSubCode.value == identifier) {
74 | return statusSubCode
75 | }
76 | }
77 | return Undefined
78 | }
79 |
--------------------------------------------------------------------------------
/src/nativeMain/kotlin/maryk/rocksdb/TableFormatConfig.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual abstract class TableFormatConfig
4 |
--------------------------------------------------------------------------------
/src/nativeMain/kotlin/maryk/rocksdb/TimedEnv.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual class TimedEnv actual constructor(baseEnv: Env)
4 | : Env(baseEnv.native)
5 |
--------------------------------------------------------------------------------
/src/nativeMain/kotlin/maryk/rocksdb/TraceOptions.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual class TraceOptions actual constructor(
4 | private val maxTraceFileSize: Long
5 | ) {
6 | // 64 GB
7 | actual constructor() : this(64 * 1024L * 1024L * 1024L)
8 |
9 | actual fun getMaxTraceFileSize() = maxTraceFileSize
10 | }
11 |
--------------------------------------------------------------------------------
/src/nativeMain/kotlin/maryk/rocksdb/TraceWriter.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual interface TraceWriter {
4 | actual fun write(data: Slice)
5 |
6 | actual fun closeWriter()
7 |
8 | actual fun getFileSize(): Long
9 | }
10 |
--------------------------------------------------------------------------------
/src/nativeMain/kotlin/maryk/rocksdb/TransactionDBOptions.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual class TransactionDBOptions actual constructor(): RocksObject() {
4 | val native = rocksdb.rocksdb_transactiondb_options_create()
5 |
6 | actual fun getMaxNumLocks(): Long {
7 | return rocksdb.rocksdb_transactiondb_options_get_max_num_locks(native)
8 | }
9 |
10 | actual fun setMaxNumLocks(maxNumLocks: Long): TransactionDBOptions {
11 | rocksdb.rocksdb_transactiondb_options_set_max_num_locks(native, maxNumLocks)
12 | return this
13 | }
14 |
15 | actual fun getNumStripes(): Long = rocksdb.rocksdb_transactiondb_options_get_num_stripes(native).toLong()
16 |
17 | actual fun setNumStripes(numStripes: Long): TransactionDBOptions {
18 | rocksdb.rocksdb_transactiondb_options_set_num_stripes(native, numStripes.toULong())
19 | return this
20 | }
21 |
22 | actual fun getTransactionLockTimeout(): Long = rocksdb.rocksdb_transactiondb_options_get_transaction_lock_timeout(native)
23 |
24 | actual fun setTransactionLockTimeout(transactionLockTimeout: Long): TransactionDBOptions {
25 | rocksdb.rocksdb_transactiondb_options_set_transaction_lock_timeout(native, transactionLockTimeout)
26 | return this
27 | }
28 |
29 | actual fun getDefaultLockTimeout(): Long = rocksdb.rocksdb_transactiondb_options_get_default_lock_timeout(native).toLong()
30 |
31 | actual fun setDefaultLockTimeout(defaultLockTimeout: Long): TransactionDBOptions {
32 | rocksdb.rocksdb_transactiondb_options_set_default_lock_timeout(native, defaultLockTimeout)
33 | return this
34 | }
35 |
36 | actual fun getWritePolicy(): TxnDBWritePolicy {
37 | return getTxnDBWritePolicy(rocksdb.rocksdb_transactiondb_options_get_write_policy(native).toByte())
38 | }
39 |
40 | actual fun setWritePolicy(writePolicy: TxnDBWritePolicy): TransactionDBOptions {
41 | rocksdb.rocksdb_transactiondb_options_set_write_policy(native, writePolicy.getValue().toInt())
42 | return this
43 | }
44 |
45 | override fun close() {
46 | if (isOwningHandle()) {
47 | rocksdb.rocksdb_transactiondb_options_destroy(native)
48 | super.close()
49 | }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/src/nativeMain/kotlin/maryk/rocksdb/TransactionOptions.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | import maryk.toBoolean
4 | import maryk.toUByte
5 |
6 | actual class TransactionOptions actual constructor(): RocksObject() {
7 | val native = rocksdb.rocksdb_transaction_options_create()
8 |
9 |
10 | actual fun isSetSnapshot(): Boolean {
11 | return rocksdb.rocksdb_transaction_options_get_set_snapshot(native).toBoolean()
12 | }
13 |
14 | actual fun setSetSnapshot(setSnapshot: Boolean): TransactionOptions {
15 | rocksdb.rocksdb_transaction_options_set_set_snapshot(native, setSnapshot.toUByte())
16 | return this
17 | }
18 |
19 | actual fun isDeadlockDetect(): Boolean {
20 | return rocksdb.rocksdb_transaction_options_get_deadlock_detect(native).toBoolean()
21 | }
22 |
23 | actual fun setDeadlockDetect(deadlockDetect: Boolean): TransactionOptions {
24 | rocksdb.rocksdb_transaction_options_set_deadlock_detect(native, deadlockDetect.toUByte())
25 | return this
26 | }
27 |
28 | actual fun getLockTimeout(): Long {
29 | return rocksdb.rocksdb_transaction_options_get_lock_timeout(native).toLong()
30 | }
31 |
32 | actual fun setLockTimeout(lockTimeout: Long): TransactionOptions {
33 | rocksdb.rocksdb_transaction_options_set_lock_timeout(native, lockTimeout)
34 | return this
35 | }
36 |
37 | actual fun getExpiration(): Long {
38 | return rocksdb.rocksdb_transaction_options_get_expiration(native).toLong()
39 | }
40 |
41 | actual fun setExpiration(expiration: Long): TransactionOptions {
42 | rocksdb.rocksdb_transaction_options_set_expiration(native, expiration)
43 | return this
44 | }
45 |
46 | actual fun getDeadlockDetectDepth(): Long {
47 | return rocksdb.rocksdb_transaction_options_get_deadlock_detect_depth(native).toLong()
48 | }
49 |
50 | actual fun setDeadlockDetectDepth(deadlockDetectDepth: Long): TransactionOptions {
51 | rocksdb.rocksdb_transaction_options_set_deadlock_detect_depth(native, deadlockDetectDepth)
52 | return this
53 | }
54 |
55 | actual fun getMaxWriteBatchSize(): Long {
56 | return rocksdb.rocksdb_transaction_options_get_max_write_batch_size(native).toLong()
57 | }
58 |
59 | actual fun setMaxWriteBatchSize(maxWriteBatchSize: Long): TransactionOptions {
60 | rocksdb.rocksdb_transaction_options_set_max_write_batch_size(native, maxWriteBatchSize.toULong())
61 | return this
62 | }
63 |
64 | override fun close() {
65 | if (isOwningHandle()) {
66 | rocksdb.rocksdb_transaction_options_destroy(native)
67 | super.close()
68 | }
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/src/nativeMain/kotlin/maryk/rocksdb/TransactionState.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual enum class TransactionState(
4 | val value: Byte
5 | ) {
6 | STARTED(0),
7 | AWAITING_PREPARE(1),
8 | PREPARED(2),
9 | AWAITING_COMMIT(3),
10 | COMMITTED(4),
11 | AWAITING_ROLLBACK(5),
12 | ROLLEDBACK(6),
13 | LOCKS_STOLEN(7);
14 | }
15 |
16 | fun getTransactionState(value: Byte): TransactionState {
17 | return TransactionState.entries.firstOrNull { it.value == value }
18 | ?: throw IllegalArgumentException("Illegal value provided for TransactionState.")
19 | }
20 |
--------------------------------------------------------------------------------
/src/nativeMain/kotlin/maryk/rocksdb/TxnDBWritePolicy.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual enum class TxnDBWritePolicy(val value: Byte) {
4 | WRITE_COMMITTED(0x00),
5 |
6 | /**
7 | * Write data after the prepare phase of 2pc.
8 | */
9 | WRITE_PREPARED(0x1),
10 |
11 | /**
12 | * Write data before the prepare phase of 2pc.
13 | */
14 | WRITE_UNPREPARED(0x2);
15 |
16 | actual fun getValue(): Byte = value
17 | }
18 |
19 |
20 | fun getTxnDBWritePolicy(value: Byte): TxnDBWritePolicy {
21 | for (level in TxnDBWritePolicy.entries) {
22 | if (level.value == value) {
23 | return level
24 | }
25 | }
26 | throw IllegalArgumentException("Illegal value provided for TxnDBWritePolicy.")
27 | }
28 |
--------------------------------------------------------------------------------
/src/nativeMain/kotlin/maryk/rocksdb/WBWIRocksIterator.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | import cnames.structs.rocksdb_iterator_t
4 | import kotlinx.cinterop.CPointer
5 |
6 | actual class WBWIRocksIterator internal constructor(
7 | native: CPointer
8 | ) : AbstractRocksIterator(native)
9 |
--------------------------------------------------------------------------------
/src/nativeMain/kotlin/maryk/rocksdb/WaitingTransactions.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual class WaitingTransactions(
4 | val columnFamilyId: Long,
5 | val key: String,
6 | val transactionIds: LongArray,
7 | ){
8 |
9 | actual fun getColumnFamilyId(): Long = columnFamilyId
10 | actual fun getKey(): String = key
11 | actual fun getTransactionIds(): LongArray = transactionIds
12 | }
13 |
--------------------------------------------------------------------------------
/src/nativeMain/kotlin/maryk/rocksdb/WalFileType.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual enum class WalFileType(
4 | private val value: Byte
5 | ) {
6 | kArchivedLogFile(0x0),
7 | kAliveLogFile(0x1)
8 | }
9 |
--------------------------------------------------------------------------------
/src/nativeMain/kotlin/maryk/rocksdb/WriteBatchInterface.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual interface WriteBatchInterface {
4 | actual fun count(): Int
5 |
6 | actual fun put(key: ByteArray, value: ByteArray)
7 |
8 | actual fun put(columnFamilyHandle: ColumnFamilyHandle, key: ByteArray, value: ByteArray)
9 |
10 | actual fun merge(key: ByteArray, value: ByteArray)
11 |
12 | actual fun merge(
13 | columnFamilyHandle: ColumnFamilyHandle,
14 | key: ByteArray,
15 | value: ByteArray
16 | )
17 |
18 | actual fun delete(key: ByteArray)
19 |
20 | actual fun delete(columnFamilyHandle: ColumnFamilyHandle, key: ByteArray)
21 |
22 | actual fun singleDelete(key: ByteArray)
23 |
24 | actual fun singleDelete(columnFamilyHandle: ColumnFamilyHandle, key: ByteArray)
25 |
26 | actual fun deleteRange(beginKey: ByteArray, endKey: ByteArray)
27 |
28 | actual fun deleteRange(
29 | columnFamilyHandle: ColumnFamilyHandle,
30 | beginKey: ByteArray,
31 | endKey: ByteArray
32 | )
33 |
34 | actual fun putLogData(blob: ByteArray)
35 |
36 | actual fun clear()
37 |
38 | actual fun setSavePoint()
39 |
40 | actual fun rollbackToSavePoint()
41 |
42 | actual fun popSavePoint()
43 |
44 | actual fun setMaxBytes(maxBytes: Long)
45 |
46 | actual fun getWriteBatch(): WriteBatch
47 | }
48 |
--------------------------------------------------------------------------------
/src/nativeMain/kotlin/maryk/rocksdb/WriteBatchSavePoint.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual class WriteBatchSavePoint actual constructor(
4 | private var size: Long,
5 | private var count: Long,
6 | private var contentFlags: Long
7 | ) {
8 | actual fun getSize() = size
9 |
10 | actual fun getCount() = count
11 |
12 | actual fun getContentFlags() = contentFlags
13 |
14 | actual fun isCleared() = size or count or contentFlags == 0L
15 |
16 | actual fun clear() {
17 | this.size = 0
18 | this.count = 0
19 | this.contentFlags = 0
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/nativeMain/kotlin/maryk/rocksdb/WriteEntry.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual class WriteEntry actual constructor(
4 | val type: WriteType,
5 | val key: DirectSlice,
6 | val value: DirectSlice?
7 | ) : AutoCloseable {
8 | actual fun getType() = type
9 |
10 | actual fun getKey() = key
11 |
12 | actual fun getValue() = value
13 |
14 | actual override fun close() {}
15 |
16 | override fun equals(other: Any?) = when {
17 | this === other -> true
18 | other !is WriteEntry -> false
19 | else -> type == other.type && key == other.key && value == other.value
20 | }
21 |
22 | override fun hashCode(): Int {
23 | var result = type.hashCode()
24 | result = 31 * result + key.hashCode()
25 | result = 31 * result + (value?.hashCode() ?: 0)
26 | return result
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/nativeMain/kotlin/maryk/rocksdb/WriteOptions.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | import cnames.structs.rocksdb_writeoptions_t
4 | import kotlinx.cinterop.CPointer
5 | import maryk.toBoolean
6 | import maryk.toUByte
7 | import rocksdb.rocksdb_writeoptions_create
8 | import rocksdb.rocksdb_writeoptions_destroy
9 | import rocksdb.rocksdb_writeoptions_disable_WAL
10 | import rocksdb.rocksdb_writeoptions_get_disable_WAL
11 | import rocksdb.rocksdb_writeoptions_get_ignore_missing_column_families
12 | import rocksdb.rocksdb_writeoptions_get_low_pri
13 | import rocksdb.rocksdb_writeoptions_get_no_slowdown
14 | import rocksdb.rocksdb_writeoptions_get_sync
15 | import rocksdb.rocksdb_writeoptions_set_ignore_missing_column_families
16 | import rocksdb.rocksdb_writeoptions_set_low_pri
17 | import rocksdb.rocksdb_writeoptions_set_no_slowdown
18 | import rocksdb.rocksdb_writeoptions_set_sync
19 |
20 | actual class WriteOptions internal constructor(
21 | internal val native: CPointer
22 | ) : RocksObject() {
23 | actual constructor() : this(rocksdb_writeoptions_create()!!)
24 |
25 | override fun close() {
26 | if (isOwningHandle()) {
27 | rocksdb_writeoptions_destroy(native)
28 | super.close()
29 | }
30 | }
31 |
32 | actual fun setSync(flag: Boolean): WriteOptions {
33 | rocksdb_writeoptions_set_sync(native, flag.toUByte())
34 | return this
35 | }
36 |
37 | actual fun sync() =
38 | rocksdb_writeoptions_get_sync(native).toBoolean()
39 |
40 | actual fun setDisableWAL(flag: Boolean): WriteOptions {
41 | rocksdb_writeoptions_disable_WAL(native, if (flag) 1 else 0)
42 | return this
43 | }
44 |
45 | actual fun disableWAL() = rocksdb_writeoptions_get_disable_WAL(native).toBoolean()
46 |
47 | actual fun setIgnoreMissingColumnFamilies(ignoreMissingColumnFamilies: Boolean): WriteOptions {
48 | rocksdb_writeoptions_set_ignore_missing_column_families(native, ignoreMissingColumnFamilies.toUByte())
49 | return this
50 | }
51 |
52 | actual fun ignoreMissingColumnFamilies() =
53 | rocksdb_writeoptions_get_ignore_missing_column_families(native).toBoolean()
54 |
55 | actual fun setNoSlowdown(noSlowdown: Boolean): WriteOptions {
56 | rocksdb_writeoptions_set_no_slowdown(native, noSlowdown.toUByte())
57 | return this
58 | }
59 |
60 | actual fun noSlowdown() =
61 | rocksdb_writeoptions_get_no_slowdown(native).toBoolean()
62 |
63 | actual fun setLowPri(lowPri: Boolean): WriteOptions {
64 | rocksdb_writeoptions_set_low_pri(native, lowPri.toUByte())
65 | return this
66 | }
67 |
68 | actual fun lowPri() =
69 | rocksdb_writeoptions_get_low_pri(native).toBoolean()
70 | }
71 |
--------------------------------------------------------------------------------
/src/nativeMain/kotlin/maryk/rocksdb/WriteType.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual enum class WriteType(
4 | internal val value: UInt
5 | ) {
6 | PUT(0u),
7 | MERGE(1u),
8 | DELETE(2u),
9 | SINGLE_DELETE(3u),
10 | DELETE_RANGE(4u),
11 | LOG(5u),
12 | XID(6u);
13 | }
14 |
15 | internal fun getWriteTypeByValue(value: UInt): WriteType =
16 | WriteType.entries.firstOrNull { it.value == value }
17 | ?: throw IllegalStateException("Unknown WriteType value: $value")
18 |
--------------------------------------------------------------------------------
/src/nativeMain/kotlin/maryk/rocksdb/loadRocksDBLibrary.kt:
--------------------------------------------------------------------------------
1 | package maryk.rocksdb
2 |
3 | actual fun loadRocksDBLibrary() {
4 | }
5 |
--------------------------------------------------------------------------------
/src/nativeMain/kotlin/maryk/toByteArray.kt:
--------------------------------------------------------------------------------
1 | package maryk
2 |
3 | import kotlinx.cinterop.ByteVar
4 | import kotlinx.cinterop.CPointer
5 | import kotlinx.cinterop.get
6 | import kotlinx.cinterop.readBytes
7 | import platform.posix.size_t
8 |
9 | fun CPointer.toByteArray(value: size_t) =
10 | this.readBytes(value.toInt())
11 |
--------------------------------------------------------------------------------
/src/nativeMain/kotlin/maryk/wrapWithErrorThrower.kt:
--------------------------------------------------------------------------------
1 | package maryk
2 |
3 | import kotlinx.cinterop.ByteVar
4 | import kotlinx.cinterop.CPointerVar
5 | import kotlinx.cinterop.CValuesRef
6 | import kotlinx.cinterop.alloc
7 | import kotlinx.cinterop.memScoped
8 | import kotlinx.cinterop.ptr
9 | import kotlinx.cinterop.toKString
10 | import kotlinx.cinterop.value
11 | import maryk.rocksdb.RocksDBException
12 | import maryk.rocksdb.Status
13 | import maryk.rocksdb.StatusCode
14 | import maryk.rocksdb.StatusSubCode
15 |
16 | private fun checkAndThrowError(errorRef: CPointerVar) {
17 | val error = errorRef.value?.toKString()
18 |
19 | if (error != null) {
20 | throw RocksDBException(error, convertToStatus(error))
21 | }
22 | }
23 |
24 | fun T.wrapWithErrorThrower(runnable: T.(CValuesRef>) -> R): R {
25 | memScoped {
26 | val errorRef = alloc>()
27 | try {
28 | val result = runnable(errorRef.ptr)
29 | checkAndThrowError(errorRef)
30 | return result
31 | } catch (e: Throwable) {
32 | checkAndThrowError(errorRef)
33 | throw RocksDBException(e.toString(), Status(StatusCode.Undefined, StatusSubCode.None, e.toString()))
34 | }
35 | }
36 | }
37 |
38 | fun T.wrapWithNullErrorThrower(runnable: T.(CValuesRef>) -> R?): R? {
39 | memScoped {
40 | val errorRef = alloc>()
41 | try {
42 | val result = runnable(errorRef.ptr)
43 | checkAndThrowError(errorRef)
44 | return result
45 | } catch (e: Throwable) {
46 | checkAndThrowError(errorRef)
47 | throw RocksDBException(e.toString(), Status(StatusCode.Undefined, StatusSubCode.None, e.toString()))
48 | }
49 | }
50 | }
51 |
52 |
--------------------------------------------------------------------------------
/src/nativeMain/kotlin/maryk/wrapWithMultiErrorThrower.kt:
--------------------------------------------------------------------------------
1 | package maryk
2 |
3 | import kotlinx.cinterop.ByteVar
4 | import kotlinx.cinterop.CArrayPointer
5 | import kotlinx.cinterop.CPointerVar
6 | import kotlinx.cinterop.allocArray
7 | import kotlinx.cinterop.get
8 | import kotlinx.cinterop.memScoped
9 | import kotlinx.cinterop.toKString
10 | import maryk.rocksdb.RocksDBException
11 |
12 | fun T.wrapWithMultiErrorThrower(
13 | numKeys: Int,
14 | runnable: T.(CArrayPointer>) -> R?
15 | ): R? = memScoped {
16 | // Allocate an array of pointers for `errs`
17 | val errsArray = allocArray>(numKeys)
18 |
19 | val result = runnable(errsArray)
20 |
21 | for (i in 0 until numKeys) {
22 | val singleErrorPtr = errsArray[i]
23 | if (singleErrorPtr != null) {
24 | val errMsg = singleErrorPtr.toKString()
25 |
26 | throw RocksDBException(
27 | errMsg,
28 | convertToStatus(errMsg)
29 | )
30 | }
31 | }
32 |
33 | return@memScoped result
34 | }
35 |
--------------------------------------------------------------------------------