protected override void InternalClose() { while (_sourceTables.Count > 0) { PopSourceTable(); } if (_sourceRow != null) { _sourceRow.Dispose(); _sourceRow = null; } if (_targetRow != null) { _targetRow.Dispose(); _targetRow = null; } if (_scan != null) { _scan.Dispose(); _scan = null; } if (_buffer != null) { _buffer.Drop(Manager); _buffer = null; } _tableType = null; _sequenceColumnIndex = -1; }
protected override void InternalFindNearest(IRow row) { IRow localRow = EnsurePartialKeyRow(row); try { if (localRow != null) { BrowseTableItem item = GetTable(localRow, true, true); _tables.Add(item); EnterTableContext(item); try { TopTable.MoveCrack(); } finally { ExitTableContext(item); } } else { _tables.Add(GetTable()); } } finally { if ((localRow != null) && !Object.ReferenceEquals(row, localRow)) { localRow.Dispose(); } } }
public void LoadTable(ServerProcess process, Schema.TableVar tableVar) { lock (_loadedTables) { if (!IsLoaded(tableVar)) { _loadedTables.Add(tableVar); if (File.Exists(GetTableVarFileName(tableVar))) { using (FileStream stream = new FileStream(GetTableVarFileName(tableVar), FileMode.Open, FileAccess.Read)) { NativeTable nativeTable = Tables[tableVar]; while (stream.Position < stream.Length) { int length = StreamUtility.ReadInteger(stream); byte[] rowValue = new byte[length]; stream.Read(rowValue, 0, rowValue.Length); IRow row = (IRow)DataValue.FromPhysical(process.ValueManager, nativeTable.RowType, rowValue, 0); try { nativeTable.Insert(process.ValueManager, row); } finally { row.Dispose(); } } } } } } }
protected override void InternalClose() { if (_scan != null) { _scan.Dispose(); _scan = null; } if (_buffer != null) { _buffer.Drop(Manager); _buffer = null; } if (_leftTable != null) { _leftTable.Dispose(); _leftTable = null; } if (_rightTable != null) { _rightTable.Dispose(); _rightTable = null; } if (_sourceRow != null) { _sourceRow.Dispose(); _sourceRow = null; } }
public override void WriteToPhysical(byte[] buffer, int offset, bool expandStreams) { if (IsNil) { buffer[offset] = 0; } else { buffer[offset] = 1; offset++; int rowSize; Streams.IConveyor int32Conveyor = Manager.GetConveyor(Manager.DataTypes.SystemInteger); int32Conveyor.Write(_rowList.Count, buffer, offset); offset += sizeof(int); for (int index = 0; index < _rowList.Count; index++) { rowSize = (int)_sizeList[index]; int32Conveyor.Write(rowSize, buffer, offset); offset += sizeof(int); IRow row = _rowList[index]; row.WriteToPhysical(buffer, offset, expandStreams); offset += rowSize; row.ValuesOwned = false; row.Dispose(); } } }
// Must be called with the original stack protected void SwapReader(bool forward) { IRow origin = null; try { EnterTableContext(TopTable); try { origin = TopTable.Origin != null ? (IRow)TopTable.Origin.Copy() : null; } finally { ExitTableContext(TopTable); } SwapReader(origin, forward, !TopTable.Inclusive); } finally { if (origin != null) { origin.Dispose(); } } }
protected override IRow InternalGetKey() { IRow key = _sourceTable.GetKey(); try { if (_keyRowType == null) { _keyRowType = new Schema.RowType(); for (int index = 0; index < key.DataType.Columns.Count; index++) { _keyRowType.Columns.Add(DataType.Columns[_sourceTable.DataType.Columns.IndexOfName(key.DataType.Columns[index].Name)].Copy()); } } Row row = new Row(Manager, _keyRowType); for (int index = 0; index < key.DataType.Columns.Count; index++) { if (key.HasValue(index)) { row[index] = key[index]; } } return(row); } finally { key.Dispose(); } }
public override object InternalExecute(Program program) { object result; IRow sourceRow = (IRow)Nodes[0].Execute(program); #if NILPROPOGATION if ((sourceRow == null) || sourceRow.IsNil) { return(null); } #endif try { Row newRow = new Row(program.ValueManager, DataType); try { program.Stack.Push(sourceRow); try { sourceRow.CopyTo(newRow); for (int index = _extendColumnOffset; index < newRow.DataType.Columns.Count; index++) { result = Nodes[index - _extendColumnOffset + 1].Execute(program); if (result != null) { try { newRow[index] = result; } finally { DataValue.DisposeValue(program.ValueManager, result); } } } } finally { program.Stack.Pop(); } return(newRow); } catch { newRow.Dispose(); throw; } } finally { sourceRow.Dispose(); } }
protected void InternalDisposeBookmark(Guid bookmark) { IRow internalBookmark = null; _bookmarks.TryGetValue(bookmark, out internalBookmark); _bookmarks.Remove(bookmark); if (internalBookmark != null) { internalBookmark.Dispose(); } }
protected override bool InternalFindKey(IRow row, bool forward) { IRow localRow = EnsureKeyRow(row); try { bool tableCreated = false; BrowseTableItem table = FindTable(localRow, forward, true); if (table == null) { table = CreateTable(localRow, forward, true); tableCreated = true; } try { EnterTableContext(table); try { table.MoveCrack(); bool result = (table.UniqueKey != null) && (CompareKeys(localRow, table.UniqueKey) == 0); if (result) { _tables.Add(table); } else if (tableCreated) { table.Dispose(); } return(result); } finally { ExitTableContext(table); } } catch { if (tableCreated) { table.Dispose(); } throw; } } finally { if (!Object.ReferenceEquals(row, localRow)) { localRow.Dispose(); } } }
public bool HasRow(IValueManager manager, IRow row) { IRow key = GetIndexData(manager, Index.KeyRowType, new IRow[] { row }); try { return(Index.ContainsKey(manager, (NativeRow)key.AsNative)); } finally { key.Dispose(); } }
protected override bool InternalRefresh(IRow key) { IRow row = BuildSourceKey(key); try { return(_sourceTable.Refresh(row)); } finally { row.Dispose(); } }
protected override bool InternalFindKey(IRow key, bool forward) { IRow localKey = BuildSourceKey(key); try { return(_sourceTable.FindKey(localKey, forward)); } finally { localKey.Dispose(); } }
protected override void InternalFindNearest(IRow key) { IRow localKey = BuildSourceKey(key); try { _sourceTable.FindNearest(localKey); } finally { localKey.Dispose(); } }
public bool FindKey(IRow key) { #if SAFETABLES CheckActive(); #endif int entryNumber; RowTreeNode indexNode; IRow localKey = EnsureKeyRow(key); try { if (_firstKey != null) { int compareResult = _accessPath.Compare(_manager, _firstKey.DataType, (NativeRow)_firstKey.AsNative, localKey.DataType, (NativeRow)localKey.AsNative); if (((_direction == ScanDirection.Forward) && (compareResult > 0)) || ((_direction == ScanDirection.Backward) && (compareResult < 0))) { return(false); } } if (_lastKey != null) { int compareResult = _accessPath.Compare(_manager, _lastKey.DataType, (NativeRow)_lastKey.AsNative, localKey.DataType, (NativeRow)localKey.AsNative); if (((_direction == ScanDirection.Forward) && (compareResult < 0)) || ((_direction == ScanDirection.Backward) && (compareResult < 0))) { return(false); } } bool result = FindIndexKey(localKey.DataType, (NativeRow)localKey.AsNative, out indexNode, out entryNumber); if (result) { SetIndexNode(indexNode); _entryNumber = entryNumber; _bOF = false; _eOF = false; } else { indexNode.Dispose(); } return(result); } finally { if (!ReferenceEquals(key, localKey)) { localKey.Dispose(); } } }
protected override void InternalClose() { if (_sourceTable != null) { _sourceTable.Dispose(); _sourceTable = null; } if (_sourceRow != null) { _sourceRow.Dispose(); _sourceRow = null; } }
protected void CheckEOF() { if (!_eOF && (_lastKey != null) && !_sourceTable.BOF()) { IRow key = _sourceTable.GetKey(); try { _eOF = IsGreater(key, _lastKey, _isLastKeyExclusive); } finally { key.Dispose(); } } }
protected override void InternalClose() { if (_firstKey != null) { _firstKey.Dispose(); _firstKey = null; } if (_lastKey != null) { _lastKey.Dispose(); _lastKey = null; } base.InternalClose(); }
protected void CheckBOF() { if (!_bOF && (_firstKey != null) && !_sourceTable.EOF()) { IRow key = _sourceTable.GetKey(); try { _bOF = IsLess(key, _firstKey, _isFirstKeyExclusive); } finally { key.Dispose(); } } }
public bool HasRow(IValueManager manager, IRow row) { IRow key = GetIndexData(manager, ClusteredIndex.KeyRowType, new IRow[] { row }); try { using (RowTreeSearchPath searchPath = new RowTreeSearchPath()) { int entryNumber; return(ClusteredIndex.FindKey(manager, ClusteredIndex.KeyRowType, (NativeRow)key.AsNative, searchPath, out entryNumber)); } } finally { key.Dispose(); } }
protected void PushSourceTable(IRow currentRow) { if (currentRow == null) { // Open the root expression, if it is not empty, save it on the cursor stack _rootTable = (ITable)Node.Nodes[1].Execute(Program); if (!_rootTable.IsEmpty()) { _sourceTables.Push(_rootTable); } else { _rootTable.Dispose(); } } else { // Otherwise, use the given row to build a parent row and open a new cursor for the child expression with that row to parameterize it IRow parentRow = NewParentRow(currentRow); Program.Stack.Push(parentRow); try { ITable table = (ITable)Node.Nodes[2].Execute(Program); // If it is not empty, save it on the cursor stack, and save the parent row on the parent row stack if (!table.IsEmpty()) { _sourceTables.Push(table); _parentRows.Push(parentRow); } else { table.Dispose(); parentRow.Dispose(); } } finally { Program.Stack.Pop(); } } }
protected override bool InternalFindKey(IRow key, bool forward) { if (!_isContradiction) { IRow localKey = EnsureKeyRow(key); try { if ((_firstKey != null) && IsLess(localKey, _firstKey, _isFirstKeyExclusive)) { return(false); } else if ((_lastKey != null) && IsGreater(localKey, _lastKey, _isLastKeyExclusive)) { return(false); } else { if (_sourceTable.FindKey(localKey, forward)) { _bOF = false; _eOF = false; return(true); } else { return(false); } } } finally { if (!Object.ReferenceEquals(localKey, key)) { localKey.Dispose(); } } } else { return(false); } }
public override object InternalExecute(Program program) { ITable table = (ITable)Nodes[0].Execute(program); #if NILPROPOGATION if ((table == null)) { return(null); } #endif try { table.Open(); if (table.Next()) { IRow row = table.Select(); try { if (table.Next()) { throw new RuntimeException(RuntimeException.Codes.InvalidRowExtractorExpression); } return(row); } catch { row.Dispose(); throw; } } else #if NILPROPOGATION { return(null); } #else { throw new RuntimeException(RuntimeException.Codes.RowTableEmpty); } #endif } finally { table.Dispose(); } }
protected void FindUniqueKey() { if (!(_table.BOF() || _table.EOF())) { if (_uniqueKey == null) { _uniqueKey = BuildUniqueKeyRow(); } else { _uniqueKey.ClearValues(); } _table.Select(_uniqueKey); } else if (_uniqueKey != null) { _uniqueKey.Dispose(); _uniqueKey = null; } }
public override object InternalExecute(Program program, object argument) { IRow sourceRow = (IRow)argument; #if NILPROPOGATION if ((sourceRow == null) || sourceRow.IsNil) { return(null); } #endif try { Row newRow = new Row(program.ValueManager, DataType); try { for (int index = 0; index < sourceRow.DataType.Columns.Count; index++) { if (sourceRow.HasValue(index) && (index < newRow.DataType.Columns.Count)) { newRow[index] = sourceRow[index]; } } return(newRow); } catch { newRow.Dispose(); throw; } } finally { sourceRow.Dispose(); } }
public void ReleaseRow(IRow row) { row.Dispose(); }
public void ReleaseRow(IRow row) { CheckCompiled(); row.Dispose(); }
protected override void InternalFindNearest(IRow key) { if (!_isContradiction) { IRow localKey = EnsurePartialKeyRow(key); try { if (localKey != null) { if (Direction == ScanDirection.Forward) { if ((_firstKey != null) && IsLess(localKey, _firstKey, _isFirstKeyExclusive)) { InternalFirst(); InternalNext(); } else if ((_lastKey != null) && IsGreater(localKey, _lastKey, _isLastKeyExclusive)) { InternalLast(); InternalPrior(); } else { _sourceTable.FindNearest(localKey); _bOF = _sourceTable.BOF(); _eOF = _sourceTable.EOF(); } } else { if ((_firstKey != null) && IsLess(localKey, _firstKey, _isFirstKeyExclusive)) { InternalLast(); InternalPrior(); } else if ((_lastKey != null) && IsGreater(localKey, _lastKey, _isLastKeyExclusive)) { InternalFirst(); InternalNext(); } else { if (IsKeyRow(localKey) && _sourceTable.FindKey(localKey)) { _bOF = false; _eOF = false; } else { _sourceTable.FindNearest(localKey); _sourceTable.Prior(); _bOF = _sourceTable.BOF(); _eOF = _sourceTable.EOF(); } } } } } finally { if (!Object.ReferenceEquals(key, localKey)) { localKey.Dispose(); } } } }
protected override void InternalLast() { if (!_isContradiction) { _eOF = true; if (Direction == ScanDirection.Forward) { if (_lastKey != null) { if (!_sourceTable.FindKey(_lastKey)) { _sourceTable.FindNearest(_lastKey); _sourceTable.Prior(); } if (_isLastKeyExclusive) { while (!_sourceTable.BOF()) { IRow currentKey = _sourceTable.GetKey(); try { if (CompareKeys(currentKey, _lastKey) < 0) { _sourceTable.Next(); break; } else { _sourceTable.Prior(); } } finally { currentKey.Dispose(); } } } else { if (_sourceTable.BOF()) { _sourceTable.Next(); } while (!_sourceTable.EOF()) { IRow currentKey = _sourceTable.GetKey(); try { if (CompareKeys(currentKey, _lastKey) > 0) { break; } else { _sourceTable.Next(); } } finally { currentKey.Dispose(); } } } } else { _sourceTable.Last(); } _bOF = _sourceTable.BOF(); } else { if (_lastKey != null) { _sourceTable.FindNearest(_lastKey); if (_isLastKeyExclusive) { while (!_sourceTable.EOF()) { IRow currentKey = _sourceTable.GetKey(); try { if (CompareKeys(currentKey, _lastKey) < 0) { _sourceTable.Prior(); break; } else { _sourceTable.Next(); } } finally { currentKey.Dispose(); } } } else { if (_sourceTable.EOF()) { _sourceTable.Prior(); } while (!_sourceTable.BOF()) { IRow currentKey = _sourceTable.GetKey(); try { if (CompareKeys(currentKey, _lastKey) > 0) { break; } else { _sourceTable.Prior(); } } finally { currentKey.Dispose(); } } } } else { _sourceTable.First(); } _bOF = _sourceTable.EOF(); } InternalPrior(); if (Direction == ScanDirection.Forward) { _sourceTable.Next(); } else { _sourceTable.Prior(); } _eOF = true; } }
public override object InternalExecute(Program program) { object objectValue = Nodes[0].Execute(program); #if NILPROPOGATION if (objectValue == null) { return(null); } #endif ITable table = objectValue as ITable; if (table != null) { try { table.Open(); if (table.Next()) { IRow row = table.Select(); try { if (table.Next()) { throw new RuntimeException(RuntimeException.Codes.InvalidRowExtractorExpression); } #if USECOLUMNLOCATIONBINDING if (row.HasValue(Location)) { return(row[Location].AsNative); } else { return(null); } #else int columnIndex = row.DataType.Columns.IndexOf(Identifier); if (row.HasValue(columnIndex)) { return(row[columnIndex]); } else { return(null); } #endif } finally { row.Dispose(); } } else #if NILPROPOGATION { return(null); } #else { throw new RuntimeException(RuntimeException.Codes.ColumnTableEmpty); } #endif } finally { if (_shouldDisposeSource) { table.Dispose(); } } } else { IRow row = (IRow)objectValue; try { #if USECOLUMNLOCATIONBINDING if (row.HasValue(Location)) { return(row[Location].AsNative); } else { return(null); } #else int columnIndex = row.DataType.Columns.IndexOf(Identifier); if (!row.IsNil && row.HasValue(columnIndex)) { return(row[columnIndex]); } else { return(null); } #endif } finally { if (_shouldDisposeSource) { row.Dispose(); } } } }