public TRecord GetRecord(uint position, KeyInfo key = null, LockBias lockBias = LockBias.None) { if (_positionBlock == null) { throw new InvalidOperationException(); } if (key != null && key.Record != this.RecordInfo) { throw new ArgumentException(); } var keyNumber = key == null ? (sbyte)-1 : key.KeyNumber; var record = this.CreateRecord(); if (record.DataBuffer.Length < 4) { Array.Copy(BitConverter.GetBytes(position), this.TemporaryBuffer, 4); var dataBufferLength = (ushort)this.TemporaryBuffer.Length; _nativeOperator.GetDirect(_positionBlock, this.TemporaryBuffer, ref dataBufferLength, _keyBuffer, keyNumber, lockBias); Array.Copy(this.TemporaryBuffer, record.DataBuffer, record.DataBuffer.Length); } else { Array.Copy(BitConverter.GetBytes(position), record.DataBuffer, 4); _nativeOperator.GetDirect(_positionBlock, record.DataBuffer, null, -1, lockBias); } return(record); }
public TRecord StepPrevious(LockBias lockBias = LockBias.None) { if (_positionBlock == null) { throw new InvalidOperationException(); } var record = this.CreateRecord(); _nativeOperator.StepPrevious(_positionBlock, record.DataBuffer, lockBias); return(record); }
public KeyValue GetLastKey(KeyInfo key, LockBias lockBias = LockBias.None) { if (_positionBlock == null) { throw new InvalidOperationException(); } if (key == null) { throw new ArgumentNullException(); } var keyBuffer = new byte[key.Length]; _nativeOperator.GetLastKey(_positionBlock, keyBuffer, key.KeyNumber, lockBias); return(new KeyValue(key, keyBuffer)); }
public TRecord GetLast(KeyInfo key, LockBias lockBias = LockBias.None) { if (_positionBlock == null) { throw new InvalidOperationException(); } if (key == null) { throw new ArgumentNullException(); } var record = this.CreateRecord(); _nativeOperator.GetLast(_positionBlock, record.DataBuffer, _keyBuffer, key.KeyNumber, lockBias); return(record); }
public void SetPosition(uint position, KeyInfo key = null, LockBias lockBias = LockBias.None) { if (_positionBlock == null) { throw new InvalidOperationException(); } if (key != null && key.Record != this.RecordInfo) { throw new ArgumentException(); } var keyNumber = key == null ? (sbyte)-1 : key.KeyNumber; Array.Copy(BitConverter.GetBytes(position), this.TemporaryBuffer, 4); var dataBufferLength = this.RecordInfo.DataBufferCapacity; _nativeOperator.GetDirect(_positionBlock, this.TemporaryBuffer, ref dataBufferLength, _keyBuffer, keyNumber, lockBias); }
public KeyValue GetLessThanOrEqualKey(KeyValue keyValue, LockBias lockBias = LockBias.None, bool overwrite = false) { if (_positionBlock == null) { throw new InvalidOperationException(); } if (keyValue == null) { throw new ArgumentNullException(); } if (!overwrite) { keyValue = keyValue.DeepCopy(); } _nativeOperator.GetLessThanOrEqualKey(_positionBlock, keyValue.KeyBuffer, keyValue.Key.KeyNumber, lockBias); keyValue.ComplementCount = 0; return(keyValue); }
public TRecord GetLessThanOrEqual(KeyValue keyValue, LockBias lockBias = LockBias.None, bool overwrite = false) { if (_positionBlock == null) { throw new InvalidOperationException(); } if (keyValue == null) { throw new ArgumentNullException(); } if (!overwrite) { keyValue = keyValue.DeepCopy(); } var record = this.CreateRecord(); _nativeOperator.GetLessThanOrEqual(_positionBlock, record.DataBuffer, keyValue.KeyBuffer, keyValue.Key.KeyNumber, lockBias); keyValue.ComplementCount = 0; return(record); }
public void GetDirect(PositionBlock positionBlock, byte[] dataBuffer, ref ushort dataBufferLength, byte[] keyBuffer, sbyte keyNumber, LockBias lockBias = LockBias.None) { if (positionBlock == null || dataBuffer == null) { throw new ArgumentNullException(); } this.Operate(Operation.GetDirect, positionBlock, dataBuffer, ref dataBufferLength, keyBuffer, keyNumber, (ushort)lockBias); }
public void GetLessThanOrEqualKey(PositionBlock positionBlock, byte[] keyBuffer, sbyte keyNumber, LockBias lockBias = LockBias.None) { if (positionBlock == null || keyBuffer == null) { throw new ArgumentNullException(); } this.Operate(Operation.GetLessThanOrEqualKey, positionBlock, null, keyBuffer, keyNumber, (ushort)lockBias); }
public void GetLessThanOrEqual(PositionBlock positionBlock, byte[] dataBuffer, byte[] keyBuffer, sbyte keyNumber, LockBias lockBias = LockBias.None) { var dataBufferLength = (ushort)dataBuffer.Length; this.GetLessThanOrEqual(positionBlock, dataBuffer, ref dataBufferLength, keyBuffer, keyNumber, lockBias); }
public void GetPreviousExtended(PositionBlock positionBlock, byte[] dataBuffer, byte[] keyBuffer, sbyte keyNumber, LockBias lockBias = LockBias.None) { var dataBufferLength = (ushort)dataBuffer.Length; this.GetPreviousExtended(positionBlock, dataBuffer, ref dataBufferLength, keyBuffer, keyNumber, lockBias); }
public void StepPreviousExtended(PositionBlock positionBlock, byte[] dataBuffer, ref ushort dataBufferLength, LockBias lockBias = LockBias.None) { if (positionBlock == null || dataBuffer == null) { throw new ArgumentNullException(); } var keyNumber = (sbyte)0; this.Operate(Operation.StepPreviousExtended, positionBlock, dataBuffer, ref dataBufferLength, null, keyNumber, (ushort)lockBias); }
public void StepPreviousExtended(PositionBlock positionBlock, byte[] dataBuffer, LockBias lockBias = LockBias.None) { var dataBufferLength = (ushort)dataBuffer.Length; this.StepPreviousExtended(positionBlock, dataBuffer, ref dataBufferLength, lockBias); }
public IEnumerable <TRecord> GetPreviousExtended(KeyValue keyValue, FilterAnd filter, bool skipCurrentPosition = true, int limit = 0, LockBias lockBias = LockBias.None, ushort rejectCount = 0, bool overwrite = false) { if (keyValue == null) { throw new ArgumentNullException(); } return(this.OperateExtended(Operation.GetPreviousExtended, keyValue, filter, skipCurrentPosition, limit, lockBias, rejectCount, overwrite)); }
public IEnumerable <TRecord> StepPreviousExtended(FilterAnd filter, bool skipCurrentPosition = true, int limit = 0, LockBias lockBias = LockBias.None, ushort rejectCount = 0) { return(this.OperateExtended(Operation.StepPreviousExtended, null, filter, skipCurrentPosition, limit, lockBias, rejectCount)); }
public void GetDirect(PositionBlock positionBlock, byte[] dataBuffer, byte[] keyBuffer, sbyte keyNumber, LockBias lockBias = LockBias.None) { if (positionBlock == null || dataBuffer == null) { throw new ArgumentNullException(); } var dataBufferLength = (ushort)dataBuffer.Length; this.GetDirect(positionBlock, dataBuffer, ref dataBufferLength, keyBuffer, keyNumber, lockBias); }
public void BeginTransaction(TransactionMode transactionMode = TransactionMode.Concurrency, LockBias lockBias = LockBias.None) { var keyNumber = (sbyte)0; var bias = (ushort)((ushort)transactionMode + (ushort)lockBias); this.Operate(Operation.BeginTransaction, null, null, null, keyNumber, bias); }
IEnumerable <TRecord> OperateExtended(Operation operation, KeyValue keyValue, FilterAnd filter, bool skipCurrentPosition, int limit, LockBias lockBias, ushort rejectCount, bool overwrite = false) { if (_positionBlock == null) { throw new InvalidOperationException(); } if (filter != null && !filter.Check(this.RecordInfo)) { throw new ArgumentException(); } if (keyValue != null && !overwrite) { keyValue = keyValue.DeepCopy(); } var useLimit = limit > 0; rejectCount = rejectCount == 0 ? this.RecordInfo.RejectCount : rejectCount; var isFirst = true; var bufferLength = Config.MaxBufferLength - Config.ExtendedOperationBufferMargin; for (; ;) { var dataBufferLength = (ushort)(filter == null ? 16 : filter.Length + 16); Array.Copy(BitConverter.GetBytes(dataBufferLength), 0, this.TemporaryBuffer, 0, 2); Array.Copy(Encoding.ASCII.GetBytes(!isFirst || skipCurrentPosition ? "EG" : "UC"), 0, this.TemporaryBuffer, 2, 2); isFirst = false; skipCurrentPosition = true; Array.Copy(BitConverter.GetBytes(rejectCount), 0, this.TemporaryBuffer, 4, 2); Array.Copy(BitConverter.GetBytes(filter == null ? 0 : filter.Count), 0, this.TemporaryBuffer, 6, 2); if (filter != null) { filter.SetDataBuffer(this.TemporaryBuffer); } var position = (ushort)(filter == null ? 8 : filter.Length + 8); var count = (ushort)(bufferLength / (this.RecordInfo.DataBufferCapacity + 6)); if (useLimit && count > limit) { count = (ushort)limit; } if (count == 0) { throw new InvalidOperationException(); } Array.Copy(BitConverter.GetBytes(count), 0, this.TemporaryBuffer, position, 2); position += 2; Array.Copy(BitConverter.GetBytes((ushort)(1)), 0, this.TemporaryBuffer, position, 2); position += 2; Array.Copy(BitConverter.GetBytes(this.RecordInfo.DataBufferCapacity), 0, this.TemporaryBuffer, position, 2); position += 2; Array.Copy(BitConverter.GetBytes((ushort)(0)), 0, this.TemporaryBuffer, position, 2); var isBreak = false; try { if (keyValue == null) { _nativeOperator.Operate(operation, _positionBlock, this.TemporaryBuffer, null, (sbyte)0, (ushort)lockBias); } else { _nativeOperator.Operate(operation, _positionBlock, this.TemporaryBuffer, keyValue.KeyBuffer, keyValue.Key.KeyNumber, (ushort)lockBias); } } catch (OperationException e) { if (e.StatusCode == 9 || e.StatusCode == 64) { isBreak = true; } else if (e.StatusCode != 60) { throw; } } if (keyValue != null) { keyValue.ComplementCount = 0; } count = BitConverter.ToUInt16(this.TemporaryBuffer, 0); position = 2; ushort length; TRecord record; for (var i = 0; i < count; i++) { length = BitConverter.ToUInt16(this.TemporaryBuffer, position); record = this.CreateRecord(); Array.Copy(this.TemporaryBuffer, position + 6, record.DataBuffer, 0, this.RecordInfo.DataBufferCapacity); record.HasPhysicalPosition = true; record.PhysicalPosition = BitConverter.ToUInt32(this.TemporaryBuffer, position + 2); yield return(record); position += (ushort)(length + 6); } if (isBreak) { yield break; } if (useLimit) { limit -= count; if (limit <= 0) { yield break; } } } }