public bool Get(byte[] key, out string val, Transaction txn) { IntPtr valptr = IntPtr.Zero; int vallen = 0; val = null; if (BangDBNative.Get_TranW(_wconnection, key, key.Length, ref valptr, ref vallen, txn.GetTranPtr()) < 0) { return(false); } val = Marshal.PtrToStringAnsi(valptr, vallen); BangDBNative.FreeBytes(valptr); return(true); }
public bool Get(string key, out string val) { IntPtr valptr = IntPtr.Zero; int vallen = 0; val = null; if (BangDBNative.GetW(_wconnection, key, key.Length, ref valptr, ref vallen) < 0) { return(false); } val = Marshal.PtrToStringAnsi(valptr, vallen); BangDBNative.FreeBytes(valptr); return(true); }
public bool Get(long key, out string vout) { IntPtr valptr = IntPtr.Zero; int vlen = 0; vout = null; if (BangDBNative.Get_Long_Str(_connection, key, ref valptr, ref vlen) < 0) { return(false); } vout = Marshal.PtrToStringAnsi(valptr, vlen); BangDBNative.FreeBytes(valptr); return(true); }
public bool LastEvaluatedKey(out string key) { IntPtr kptr; int klen; BangDBNative.LastEvaluatedKey(_rs, out kptr, out klen); if (kptr == IntPtr.Zero || klen == 0) { key = null; return(false); } key = Marshal.PtrToStringAnsi(kptr, klen); BangDBNative.FreeBytes(kptr); return(true); }
public bool Get(byte[] key, out byte[] val, Transaction txn) { IntPtr valptr = IntPtr.Zero; int vallen = 0; val = null; if (BangDBNative.Get_TranW(_wconnection, key, key.Length, ref valptr, ref vallen, txn.GetTranPtr()) < 0) { return(false); } val = new byte[vallen]; System.Runtime.InteropServices.Marshal.Copy(valptr, val, 0, vallen); BangDBNative.FreeBytes(valptr); return(true); }
public bool Get(long key, out byte[] val) { IntPtr valptr = IntPtr.Zero; int vallen = 0; val = null; if (BangDBNative.Get_LongW(_wconnection, key, ref valptr, ref vallen) < 0) { return(false); } val = new byte[vallen]; System.Runtime.InteropServices.Marshal.Copy(valptr, val, 0, vallen); BangDBNative.FreeBytes(valptr); return(true); }
public bool LastEvaluatedKey(out byte[] key) { IntPtr kptr; int klen; BangDBNative.LastEvaluatedKey(_rs, out kptr, out klen); if (kptr == IntPtr.Zero || klen == 0) { key = null; return(false); } key = new byte[klen]; System.Runtime.InteropServices.Marshal.Copy(kptr, key, 0, klen); BangDBNative.FreeBytes(kptr); return(true); }
public bool Get(string key, out string val, Transaction txn) { if (key == null) { throw new Exception("key can't be null"); } IntPtr valptr; int vlen; val = null; if (BangDBNative.Get_Tran(_connection, key, key.Length, out valptr, out vlen, txn.GetTranPtr()) < 0) { return(false); } val = Marshal.PtrToStringAnsi(valptr, vlen); BangDBNative.FreeBytes(valptr); return(true); }
/* * public bool Get(long key, out byte[] val) * { * byte[] k = BitConverter.GetBytes(key); * val = Get(k); * return (val == null) ? false : true; * } * * public bool Get(long key, out byte[] val, Transaction txn) * { * byte[] k = BitConverter.GetBytes(key); * val = Get(k, txn); * return (val == null) ? false : true; * } * * public bool Get(long key, out string val) * { * byte[] k = BitConverter.GetBytes(key); * * IntPtr valptr; * int vlen; * if (BangDBNative.Get(_connection, k, k.Length, out valptr, out vlen) < 0) * val = null; * else * { * val = Marshal.PtrToStringAnsi(valptr, vlen); * BangDBNative.FreeBytes(valptr); * } * return (val == null) ? false : true; * } * * public bool Get(long key, out string val, Transaction txn) * { * byte[] k = BitConverter.GetBytes(key); * * IntPtr valptr; * int vlen; * if (BangDBNative.Get_Tran(_connection, k, k.Length, out valptr, out vlen, txn.GetTranPtr()) < 0) * val = null; * else * { * val = Marshal.PtrToStringAnsi(valptr, vlen); * BangDBNative.FreeBytes(valptr); * } * return (val == null) ? false : true; * } */ public bool Get(string key, out byte[] val) { if (key == null) { throw new Exception("key can't be null"); } IntPtr valptr; int vlen; val = null; if (BangDBNative.Get(_connection, key, key.Length, out valptr, out vlen) < 0) { return(false); } val = new byte[vlen]; System.Runtime.InteropServices.Marshal.Copy(valptr, val, 0, vlen); BangDBNative.FreeBytes(valptr); return(true); }
public bool Get(byte[] key, out byte[] val, Transaction txn) { if (key == null) { throw new Exception("key can't be null"); } //string k = System.Text.Encoding.UTF8.GetString(key); IntPtr valptr; int vlen; val = null; if (BangDBNative.Get_Tran(_connection, key, key.Length, out valptr, out vlen, txn.GetTranPtr()) < 0) { return(false); } val = new byte[vlen]; System.Runtime.InteropServices.Marshal.Copy(valptr, val, 0, vlen); BangDBNative.FreeBytes(valptr); return(true); }