forked from ravendb/ravendb
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Modifying the way we are handling index updates on delete - will now …
…record the updates in a separate internal table, not subject to write locks from the index.
- Loading branch information
Showing
12 changed files
with
179 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using Microsoft.Isam.Esent.Interop; | ||
using Raven.Database.Impl; | ||
|
||
namespace Raven.Storage.Esent.SchemaUpdates | ||
{ | ||
public class From35To36 : ISchemaUpdate | ||
{ | ||
#region ISchemaUpdate Members | ||
|
||
public string FromSchemaVersion | ||
{ | ||
get { return "3.5"; } | ||
} | ||
|
||
public void Init(IUuidGenerator generator) | ||
{ | ||
} | ||
|
||
public void Update(Session session, JET_DBID dbid) | ||
{ | ||
Transaction tx; | ||
using (tx = new Transaction(session)) | ||
{ | ||
CreateIndexingEtagsTable(dbid, session); | ||
|
||
using (var stats = new Table(session, dbid, "indexes_stats",OpenTableGrbit.None)) | ||
using (var reduce = new Table(session, dbid, "indexes_etag", OpenTableGrbit.None)) | ||
{ | ||
var tblKeyColumn = Api.GetColumnDictionary(session, stats)["key"]; | ||
var reduceKeyCol = Api.GetColumnDictionary(session, reduce)["key"]; | ||
|
||
Api.MoveBeforeFirst(session, stats); | ||
while (Api.TryMoveNext(session, stats)) | ||
{ | ||
using(var update = new Update(session, reduce, JET_prep.Insert)) | ||
{ | ||
var indexName = Api.RetrieveColumnAsString(session, stats, tblKeyColumn, Encoding.Unicode); | ||
Api.SetColumn(session, reduce, reduceKeyCol, indexName, Encoding.Unicode); | ||
update.Save(); | ||
} | ||
} | ||
} | ||
|
||
tx.Commit(CommitTransactionGrbit.LazyFlush); | ||
tx.Dispose(); | ||
tx = new Transaction(session); | ||
} | ||
|
||
using (var details = new Table(session, dbid, "details", OpenTableGrbit.None)) | ||
{ | ||
Api.JetMove(session, details, JET_Move.First, MoveGrbit.None); | ||
var columnids = Api.GetColumnDictionary(session, details); | ||
|
||
using (var update = new Update(session, details, JET_prep.Replace)) | ||
{ | ||
Api.SetColumn(session, details, columnids["schema_version"], "3.6", Encoding.Unicode); | ||
|
||
update.Save(); | ||
} | ||
} | ||
tx.Commit(CommitTransactionGrbit.None); | ||
tx.Dispose(); | ||
} | ||
|
||
private static void CreateIndexingEtagsTable(JET_DBID dbid, JET_SESID session) | ||
{ | ||
JET_TABLEID tableid; | ||
Api.JetCreateTable(session, dbid, "indexes_etag", 16, 100, out tableid); | ||
JET_COLUMNID columnid; | ||
|
||
Api.JetAddColumn(session, tableid, "key", new JET_COLUMNDEF | ||
{ | ||
cbMax = 255, | ||
coltyp = JET_coltyp.Text, | ||
cp = JET_CP.Unicode, | ||
grbit = ColumndefGrbit.ColumnTagged | ||
}, null, 0, out columnid); | ||
|
||
var defaultValue = BitConverter.GetBytes(0); | ||
Api.JetAddColumn(session, tableid, "touches", new JET_COLUMNDEF | ||
{ | ||
coltyp = JET_coltyp.Long, | ||
grbit = ColumndefGrbit.ColumnFixed | ColumndefGrbit.ColumnNotNULL | ColumndefGrbit.ColumnEscrowUpdate | ||
}, defaultValue, defaultValue.Length, out columnid); | ||
|
||
const string indexDef = "+key\0\0"; | ||
Api.JetCreateIndex(session, tableid, "by_key", CreateIndexGrbit.IndexPrimary, indexDef, indexDef.Length, | ||
100); | ||
} | ||
|
||
|
||
#endregion | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters