public int Delete(IEnumerator <DbRow> rows) { int deleteCount = 0; while (rows.MoveNext()) { DbRow row = rows.Current; if (row == null) { continue; } long rowid = row.RowId; IDataFile df = GetDataFile(rowIndexKey); SortedIndex rowsIndex = new SortedIndex(df); if (rowsIndex.ContainsSortKey(rowid)) { // Remove the row from the main index, RemoveRowFromRowSet(rowid); // Remove the row from any indexes defined on the table, RemoveRowFromIndexSet(rowid); // Delete the row file IDataFile rowFile = GetDataFile(GetRowIdKey(rowid)); rowFile.Delete(); // Add this event to the transaction log, AddTransactionEvent("deleteRow", rowid); deleteCount++; } } ++currentVersion; return(deleteCount); }
public void ReplicateTo(IDataFile destFile) { // TODO: Placeholder implementation, destFile.Position = 0; destFile.Delete(); Position = 0; CopyTo(destFile, Length); }
internal static void WriteForcedTransactionIntroduction(ITransaction transaction) { // Output the change log to the proposed transaction to commit, IDataFile transactionLog = transaction.GetFile(TransactionLogKey, FileAccess.ReadWrite); transactionLog.Delete(); StringData logFile = new StringData(transactionLog); // Record that there is no base root for this transaction, logFile.Append("no base root"); logFile.Append("\n"); }
internal void PrepareForCommit() { // Write the transaction log for this table, IDataFile df = GetDataFile(AddLog); df.Delete(); SortedIndex addlist = new SortedIndex(df); foreach (long v in addRowList) { addlist.InsertSortKey(v); } df = GetDataFile(RemoveLog); df.Delete(); SortedIndex deletelist = new SortedIndex(df); foreach (long v in deleteRowList) { if (addlist.ContainsSortKey(v)) { addlist.RemoveSortKey(v); } else { deletelist.InsertSortKey(v); } } // Set the id gen key if (currentIdGen != -1) { StringDictionary p = TableProperties; p.SetValue("k", currentIdGen); } }
internal void RefreshTransactionLog() { // Output the change log to the proposed transaction to commit, IDataFile transactionLog = transaction.GetFile(TransactionLogKey, FileAccess.ReadWrite); transactionLog.Delete(); StringData logFile = new StringData(transactionLog); // Record the base root in the log, logFile.Append(baseRoot.ToString()); logFile.Append("\n"); // Write out every log entry, foreach (string entry in log) { logFile.Append(entry); logFile.Append("\n"); } }
public void RemoveIndex(string columnName) { CheckColumnNameValid(columnName); StringDictionary p = TableProperties; // Check the column name index property, if (!p.GetValue(columnName + ".index", false)) { throw new ApplicationException("Column " + columnName + " not indexed"); } long columnid = p.GetValue(columnName + ".id", -1); if (columnid == -1) { // For this error to occur here would indicate some sort of data model // corruption. throw new ApplicationException("Column " + columnName + " not found"); } // Remove from the index column list string columnList = p.GetValue("index_column_list", ""); columnList = RemoveFromColumnSet(columnName, columnList); p.SetValue("index_column_list", columnList); // Remove the index property, p.SetValue(columnName + ".index", null); p.SetValue(columnName + ".collator", null); // Delete the index file, IDataFile indexFile = GetDataFile(GetIndexIdKey(columnid)); indexFile.Delete(); cachedIndexList = null; // Add this event to the transaction log, AddTransactionEvent("removeIndex", columnName); ++currentVersion; }
public void Delete(DbRow row) { long rowid = row.RowId; IDataFile df = GetDataFile(rowIndexKey); SortedIndex rows = new SortedIndex(df); if (!rows.ContainsSortKey(rowid)) { throw new ApplicationException("Row being deleted is not in the table"); } // Remove the row from the main index, RemoveRowFromRowSet(rowid); // Remove the row from any indexes defined on the table, RemoveRowFromIndexSet(rowid); // Delete the row file IDataFile rowFile = GetDataFile(GetRowIdKey(rowid)); rowFile.Delete(); // Add this event to the transaction log, AddTransactionEvent("deleteRow", rowid); ++currentVersion; }