コード例 #1
0
        /// <summary>
        /// Creates new instance of LightningCursor
        /// </summary>
        /// <param name="db">Database</param>
        /// <param name="txn">Transaction</param>
        internal LightningCursor(LightningDatabase db, LightningTransaction txn)
        {
            if (db == null)
            {
                throw new ArgumentNullException(nameof(db));
            }

            if (txn == null)
            {
                throw new ArgumentNullException(nameof(txn));
            }

            _currentWithOptimizedPair = () => _currentPair;
            _currentDefault           = () =>
            {
                if (_currentKeyStructure.size == IntPtr.Zero)
                {
                    return(default(KeyValuePair <byte[], byte[]>));
                }

                return(new KeyValuePair <byte[], byte[]>(_currentKeyStructure.GetBytes(),
                                                         _currentValueStructure.GetBytes()));
            };

            _getCurrent = _currentDefault;

            mdb_cursor_open(txn.Handle(), db.Handle(), out _handle);

            Database               = db;
            Transaction            = txn;
            Transaction.Disposing += Dispose;
        }
コード例 #2
0
 private int IsDuplicate(ref ValueStructure left, ref ValueStructure right)
 {
     return(_duplicatesComparer.Compare(left.GetBytes(), right.GetBytes()));
 }
コード例 #3
0
 private int Compare(ref ValueStructure left, ref ValueStructure right)
 {
     return(_comparer.Compare(left.GetBytes(), right.GetBytes()));
 }