コード例 #1
0
        /// <summary>
        /// Store by cursor.
        /// This function stores key/data pairs into the database.
        /// If the function fails for any reason, the state of the cursor will be unchanged.
        /// If the function succeeds and an item is inserted into the database, the cursor is always positioned to refer to the newly inserted item.
        /// </summary>
        /// <param name="key">The key operated on.</param>
        /// <param name="value">The data operated on.</param>
        /// <param name="options">
        /// Options for this operation. This parameter must be set to 0 or one of the values described here.
        ///     CursorPutOptions.Current - overwrite the data of the key/data pair to which the cursor refers with the specified data item. The key parameter is ignored.
        ///     CursorPutOptions.NoDuplicateData - enter the new key/data pair only if it does not already appear in the database. This flag may only be specified if the database was opened with MDB_DUPSORT. The function will return MDB_KEYEXIST if the key/data pair already appears in the database.
        ///     CursorPutOptions.NoOverwrite - enter the new key/data pair only if the key does not already appear in the database. The function will return MDB_KEYEXIST if the key already appears in the database, even if the database supports duplicates (MDB_DUPSORT).
        ///     CursorPutOptions.ReserveSpace - reserve space for data of the given size, but don't copy the given data. Instead, return a pointer to the reserved space, which the caller can fill in later. This saves an extra memcpy if the data is being generated later.
        ///     CursorPutOptions.AppendData - append the given key/data pair to the end of the database. No key comparisons are performed. This option allows fast bulk loading when keys are already known to be in the correct order. Loading unsorted keys with this flag will cause data corruption.
        ///     CursorPutOptions.AppendDuplicateData - as above, but for sorted dup data.
        /// </param>
        public void Put(byte[] key, byte[] value, CursorPutOptions options)
        {
            using (var keyMarshalStruct = new MarshalValueStructure(key))
                using (var valueMarshalStruct = new MarshalValueStructure(value))
                {
                    var keyStruct   = keyMarshalStruct.ValueStructure;
                    var valueStruct = valueMarshalStruct.ValueStructure;

                    NativeMethods.Execute(lib => lib.mdb_cursor_put(_handle, ref keyStruct, ref valueStruct, options));
                }
        }
コード例 #2
0
 /// <summary>
 /// Store by cursor.
 /// This function stores key/data pairs into the database. The cursor is positioned at the new item, or on failure usually near it.
 /// Note: Earlier documentation incorrectly said errors would leave the state of the cursor unchanged.
 /// If the function fails for any reason, the state of the cursor will be unchanged.
 /// If the function succeeds and an item is inserted into the database, the cursor is always positioned to refer to the newly inserted item.
 /// </summary>
 /// <param name="key">The key operated on.</param>
 /// <param name="value">The data operated on.</param>
 /// <param name="options">
 /// Options for this operation. This parameter must be set to 0 or one of the values described here.
 ///     CursorPutOptions.Current - overwrite the data of the key/data pair to which the cursor refers with the specified data item. The key parameter is ignored.
 ///     CursorPutOptions.NoDuplicateData - enter the new key/data pair only if it does not already appear in the database. This flag may only be specified if the database was opened with MDB_DUPSORT. The function will return MDB_KEYEXIST if the key/data pair already appears in the database.
 ///     CursorPutOptions.NoOverwrite - enter the new key/data pair only if the key does not already appear in the database. The function will return MDB_KEYEXIST if the key already appears in the database, even if the database supports duplicates (MDB_DUPSORT).
 ///     CursorPutOptions.ReserveSpace - reserve space for data of the given size, but don't copy the given data. Instead, return a pointer to the reserved space, which the caller can fill in later. This saves an extra memcpy if the data is being generated later.
 ///     CursorPutOptions.AppendData - append the given key/data pair to the end of the database. No key comparisons are performed. This option allows fast bulk loading when keys are already known to be in the correct order. Loading unsorted keys with this flag will cause data corruption.
 ///     CursorPutOptions.AppendDuplicateData - as above, but for sorted dup data.
 /// </param>
 /// <returns>Returns <see cref="MDBResultCode"/></returns>
 public MDBResultCode Put(byte[] key, byte[] value, CursorPutOptions options)
 {
     return(Put(key.AsSpan(), value.AsSpan(), options));
 }
コード例 #3
0
ファイル: Lmdb.cs プロジェクト: skalinets/Lightning.NET
 /// <summary>
 /// store multiple contiguous data elements in a single request.
 /// May only be used with MDB_DUPFIXED.
 /// </summary>
 /// <param name="data">This span must be pinned or stackalloc memory</param>
 public static MDBResultCode mdb_cursor_put(IntPtr cursor, ref MDBValue key, ref Span <MDBValue> data,
                                            CursorPutOptions flags)
 {
     ref var dataRef = ref MemoryMarshal.GetReference(data);
コード例 #4
0
ファイル: Lmdb.cs プロジェクト: skalinets/Lightning.NET
 public static MDBResultCode mdb_cursor_put(IntPtr cursor, MDBValue key, MDBValue value, CursorPutOptions flags)
 {
     return(mdb_cursor_put(cursor, ref key, ref value, flags));
 }
コード例 #5
0
 private static extern int mdb_cursor_put(IntPtr cursor, ref ValueStructure key, ref ValueStructure data, CursorPutOptions flags);
コード例 #6
0
ファイル: Lmdb.cs プロジェクト: xiongyingjie/Lightning.NET
 public static int mdb_cursor_put(IntPtr cursor, ref ValueStructure key, ValueStructure[] data, CursorPutOptions flags)
 {
     return(check(LmdbMethods.mdb_cursor_put(cursor, ref key, data, flags)));
 }
コード例 #7
0
 int INativeLibraryFacade.mdb_cursor_put(IntPtr cursor, ref ValueStructure key, ValueStructure[] data, CursorPutOptions flags)
 {
     return FallbackLibraryFacade.mdb_cursor_put(cursor, ref key, data, flags);
 }
コード例 #8
0
 int INativeLibraryFacade.mdb_cursor_put(IntPtr cursor, ref ValueStructure key, ref ValueStructure data, CursorPutOptions flags)
 {
     return Native64BitLibraryFacade.mdb_cursor_put(cursor, ref key, ref data, flags);
 }
コード例 #9
0
ファイル: Cursor.cs プロジェクト: Spreads/Spreads.LMDB
 public bool TryPut(ref DirectBuffer key, ref DirectBuffer value, CursorPutOptions options)
 {
     return(_impl.TryPut(ref key, ref value, options));
 }
コード例 #10
0
ファイル: Cursor.cs プロジェクト: Spreads/Spreads.LMDB
 public bool TryPut <TKey, TValue>(ref TKey key, ref TValue value, CursorPutOptions options) where TKey : struct where TValue : struct
 {
     return(_impl.TryPut(ref key, ref value, options));
 }
コード例 #11
0
ファイル: LmdbMethods.cs プロジェクト: lanicon/Lightning.NET
 public static extern MDBResultCode mdb_cursor_put(IntPtr cursor, ref MDBValue key, MDBValue[] value, CursorPutOptions flags);
コード例 #12
0
        /// <summary>
        /// Store by cursor.
        /// This function stores key/data pairs into the database. 
        /// If the function fails for any reason, the state of the cursor will be unchanged. 
        /// If the function succeeds and an item is inserted into the database, the cursor is always positioned to refer to the newly inserted item.
        /// </summary>
        /// <param name="key">The key operated on.</param>
        /// <param name="value">The data operated on.</param>
        /// <param name="options">
        /// Options for this operation. This parameter must be set to 0 or one of the values described here.
        ///     CursorPutOptions.Current - overwrite the data of the key/data pair to which the cursor refers with the specified data item. The key parameter is ignored.
        ///     CursorPutOptions.NoDuplicateData - enter the new key/data pair only if it does not already appear in the database. This flag may only be specified if the database was opened with MDB_DUPSORT. The function will return MDB_KEYEXIST if the key/data pair already appears in the database.
        ///     CursorPutOptions.NoOverwrite - enter the new key/data pair only if the key does not already appear in the database. The function will return MDB_KEYEXIST if the key already appears in the database, even if the database supports duplicates (MDB_DUPSORT).
        ///     CursorPutOptions.ReserveSpace - reserve space for data of the given size, but don't copy the given data. Instead, return a pointer to the reserved space, which the caller can fill in later. This saves an extra memcpy if the data is being generated later.
        ///     CursorPutOptions.AppendData - append the given key/data pair to the end of the database. No key comparisons are performed. This option allows fast bulk loading when keys are already known to be in the correct order. Loading unsorted keys with this flag will cause data corruption.
        ///     CursorPutOptions.AppendDuplicateData - as above, but for sorted dup data.
        /// </param>
        public void Put(byte[] key, byte[] value, CursorPutOptions options)
        {
            using(var keyMarshalStruct = new MarshalValueStructure(key))
            using (var valueMarshalStruct = new MarshalValueStructure(value))
            {
                var keyStruct = keyMarshalStruct.ValueStructure;
                var valueStruct = valueMarshalStruct.ValueStructure;

                NativeMethods.Execute(lib => lib.mdb_cursor_put(_handle, ref keyStruct, ref valueStruct, options));
            }
        }
コード例 #13
0
        /// <summary>
        /// Store by cursor.
        /// This function stores key/data pairs into the database.
        /// If the function fails for any reason, the state of the cursor will be unchanged.
        /// If the function succeeds and an item is inserted into the database, the cursor is always positioned to refer to the newly inserted item.
        /// </summary>
        /// <param name="cur">A cursor.</param>
        /// <param name="key">The key operated on.</param>
        /// <param name="value">The data operated on.</param>
        /// <param name="options">
        /// Options for this operation. This parameter must be set to 0 or one of the values described here. (optional)
        ///     CursorPutOptions.Current - overwrite the data of the key/data pair to which the cursor refers with the specified data item. The key parameter is ignored.
        ///     CursorPutOptions.NoDuplicateData - enter the new key/data pair only if it does not already appear in the database. This flag may only be specified if the database was opened with MDB_DUPSORT. The function will return MDB_KEYEXIST if the key/data pair already appears in the database.
        ///     CursorPutOptions.NoOverwrite - enter the new key/data pair only if the key does not already appear in the database. The function will return MDB_KEYEXIST if the key already appears in the database, even if the database supports duplicates (MDB_DUPSORT).
        ///     CursorPutOptions.ReserveSpace - reserve space for data of the given size, but don't copy the given data. Instead, return a pointer to the reserved space, which the caller can fill in later. This saves an extra memcpy if the data is being generated later.
        ///     CursorPutOptions.AppendData - append the given key/data pair to the end of the database. No key comparisons are performed. This option allows fast bulk loading when keys are already known to be in the correct order. Loading unsorted keys with this flag will cause data corruption.
        ///     CursorPutOptions.AppendDuplicateData - as above, but for sorted dup data.
        /// </param>
        public static void Put <TKey, TValue>(this LightningCursor cur, TKey key, TValue value, CursorPutOptions options = CursorPutOptions.None)
        {
            var keyBytes   = cur.ToBytes(key);
            var valueBytes = cur.ToBytes(value);

            cur.Put(keyBytes, valueBytes, options);
        }
コード例 #14
0
        /// <summary>
        /// Store by cursor.
        /// This function stores key/data pairs into the database. The cursor is positioned at the new item, or on failure usually near it.
        /// Note: Earlier documentation incorrectly said errors would leave the state of the cursor unchanged.
        /// If the function fails for any reason, the state of the cursor will be unchanged.
        /// If the function succeeds and an item is inserted into the database, the cursor is always positioned to refer to the newly inserted item.
        /// </summary>
        /// <param name="key">The key operated on.</param>
        /// <param name="value">The data operated on.</param>
        /// <param name="options">
        /// Options for this operation. This parameter must be set to 0 or one of the values described here.
        ///     CursorPutOptions.Current - overwrite the data of the key/data pair to which the cursor refers with the specified data item. The key parameter is ignored.
        ///     CursorPutOptions.NoDuplicateData - enter the new key/data pair only if it does not already appear in the database. This flag may only be specified if the database was opened with MDB_DUPSORT. The function will return MDB_KEYEXIST if the key/data pair already appears in the database.
        ///     CursorPutOptions.NoOverwrite - enter the new key/data pair only if the key does not already appear in the database. The function will return MDB_KEYEXIST if the key already appears in the database, even if the database supports duplicates (MDB_DUPSORT).
        ///     CursorPutOptions.ReserveSpace - reserve space for data of the given size, but don't copy the given data. Instead, return a pointer to the reserved space, which the caller can fill in later. This saves an extra memcpy if the data is being generated later.
        ///     CursorPutOptions.AppendData - append the given key/data pair to the end of the database. No key comparisons are performed. This option allows fast bulk loading when keys are already known to be in the correct order. Loading unsorted keys with this flag will cause data corruption.
        ///     CursorPutOptions.AppendDuplicateData - as above, but for sorted dup data.
        /// </param>
        /// <returns>Returns <see cref="MDBResultCode"/></returns>
        public unsafe MDBResultCode Put(ReadOnlySpan <byte> key, ReadOnlySpan <byte> value, CursorPutOptions options)
        {
            fixed(byte *keyPtr = key)
            fixed(byte *valPtr = value)
            {
                var mdbKey   = new MDBValue(key.Length, keyPtr);
                var mdbValue = new MDBValue(value.Length, valPtr);

                return(mdb_cursor_put(_handle, mdbKey, mdbValue, options));
            }
        }
コード例 #15
0
ファイル: Cursor.cs プロジェクト: Spreads/Spreads.LMDB
 public void Put <TKey, TValue>(ref TKey key, ref TValue value, CursorPutOptions options) where TKey : struct where TValue : struct
 {
     _impl.Put(ref key, ref value, options);
 }
コード例 #16
0
 public static extern int mdb_cursor_put(IntPtr cursor, ref ValueStructure key, ref ValueStructure value, CursorPutOptions flags);
コード例 #17
0
ファイル: Cursor.cs プロジェクト: Spreads/Spreads.LMDB
 public void Put(ref DirectBuffer key, ref DirectBuffer value, CursorPutOptions options)
 {
     _impl.Put(ref key, ref value, options);
 }
コード例 #18
0
 private static extern int mdb_cursor_put(IntPtr cursor, ref ValueStructure key, ValueStructure[] data, CursorPutOptions flags);
コード例 #19
0
ファイル: Lmdb.cs プロジェクト: sebastienros/Lightning.NET
 public static int mdb_cursor_put(IntPtr cursor, byte[] key, byte[] value, CursorPutOptions flags)
 {
     using(var marshal = new MarshalValueStructure(key, value))
         return check(LmdbMethods.mdb_cursor_put(cursor, ref marshal.Key, ref marshal.Value, flags));
 }
コード例 #20
0
ファイル: Lmdb.cs プロジェクト: xiongyingjie/Lightning.NET
 public static int mdb_cursor_put(IntPtr cursor, byte[] key, byte[] value, CursorPutOptions flags)
 {
     using (var marshal = new MarshalValueStructure(key, value))
         return(check(LmdbMethods.mdb_cursor_put(cursor, ref marshal.Key, ref marshal.Value, flags)));
 }
コード例 #21
0
ファイル: Lmdb.cs プロジェクト: sebastienros/Lightning.NET
 public static int mdb_cursor_put(IntPtr cursor, ref ValueStructure key, ValueStructure[] data, CursorPutOptions flags)
 {
     return check(LmdbMethods.Overloads.mdb_cursor_put(cursor, ref key, data, flags));
 }
コード例 #22
0
 /// <summary>
 /// Store by cursor.
 /// This function stores key/data pairs into the database. The cursor is positioned at the new item, or on failure usually near it.
 /// Note: Earlier documentation incorrectly said errors would leave the state of the cursor unchanged.
 /// If the function fails for any reason, the state of the cursor will be unchanged.
 /// If the function succeeds and an item is inserted into the database, the cursor is always positioned to refer to the newly inserted item.
 /// </summary>
 /// <param name="key">The key operated on.</param>
 /// <param name="value">The data operated on.</param>
 /// <param name="options">
 /// Options for this operation. This parameter must be set to 0 or one of the values described here.
 ///     CursorPutOptions.Current - overwrite the data of the key/data pair to which the cursor refers with the specified data item. The key parameter is ignored.
 ///     CursorPutOptions.NoDuplicateData - enter the new key/data pair only if it does not already appear in the database. This flag may only be specified if the database was opened with MDB_DUPSORT. The function will return MDB_KEYEXIST if the key/data pair already appears in the database.
 ///     CursorPutOptions.NoOverwrite - enter the new key/data pair only if the key does not already appear in the database. The function will return MDB_KEYEXIST if the key already appears in the database, even if the database supports duplicates (MDB_DUPSORT).
 ///     CursorPutOptions.ReserveSpace - reserve space for data of the given size, but don't copy the given data. Instead, return a pointer to the reserved space, which the caller can fill in later. This saves an extra memcpy if the data is being generated later.
 ///     CursorPutOptions.AppendData - append the given key/data pair to the end of the database. No key comparisons are performed. This option allows fast bulk loading when keys are already known to be in the correct order. Loading unsorted keys with this flag will cause data corruption.
 ///     CursorPutOptions.AppendDuplicateData - as above, but for sorted dup data.
 /// </param>
 public void Put(byte[] key, byte[] value, CursorPutOptions options)
 {
     Lmdb.mdb_cursor_put(_handle, key, value, options);
 }
コード例 #23
0
 int INativeLibraryFacade.mdb_cursor_put(IntPtr cursor, ref ValueStructure key, ref ValueStructure data, CursorPutOptions flags)
 {
     return(FallbackLibraryFacade.mdb_cursor_put(cursor, ref key, ref data, flags));
 }