本文整理汇总了C#中Voron.Impl.Transaction类的典型用法代码示例。如果您正苦于以下问题:C# Transaction类的具体用法?C# Transaction怎么用?C# Transaction使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Transaction类属于Voron.Impl命名空间,在下文中一共展示了Transaction类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Searcher
public Searcher(FullTextIndex index)
{
_index = index;
_tx = _index.StorageEnvironment.NewTransaction(TransactionFlags.Read);
_docs = _tx.ReadTree("Docs");
}
开发者ID:votrongdao,项目名称:Corax,代码行数:7,代码来源:Searcher.cs
示例2: TransactionActivityEntry
public TransactionActivityEntry(Transaction tx, DebugActionType actionType)
{
TransactionId = tx.Id;
Flags = tx.Flags;
ActionType = actionType;
CreatedByJournalApplicator = tx.CreatedByJournalApplicator;
}
开发者ID:felixmm,项目名称:ravendb,代码行数:7,代码来源:DebugJournal.cs
示例3: TryGetValue
public bool TryGetValue(Transaction tx, long page, out PagePosition value)
{
ImmutableAppendOnlyList<PagePosition> list;
if (_values.TryGetValue(page, out list) == false)
{
value = null;
return false;
}
for (int i = list.Count - 1; i >= 0; i--)
{
var it = list[i];
if (it.TransactionId > tx.Id)
continue;
if (it.IsFreedPageMarker)
break;
value = it;
Debug.Assert(value != null);
return true;
}
// all the current values are _after_ this transaction started, so it sees nothing
value = null;
return false;
}
开发者ID:GorelH,项目名称:ravendb,代码行数:27,代码来源:PageTable.cs
示例4: PageSplitter
public PageSplitter(Transaction tx,
Tree tree,
SliceComparer cmp,
Slice newKey,
int len,
long pageNumber,
NodeFlags nodeType,
ushort nodeVersion,
Cursor cursor,
TreeMutableState treeState)
{
_tx = tx;
_tree = tree;
_cmp = cmp;
_newKey = newKey;
_len = len;
_pageNumber = pageNumber;
_nodeType = nodeType;
_nodeVersion = nodeVersion;
_cursor = cursor;
_treeState = treeState;
Page page = _cursor.Pages.First.Value;
_page = tx.ModifyPage(page.PageNumber, page);
_cursor.Pop();
}
开发者ID:WimVergouwe,项目名称:ravendb,代码行数:25,代码来源:PageSplitter.cs
示例5: DumpHumanReadable
public static void DumpHumanReadable(Transaction tx, long startPageNumber,string filenamePrefix = null)
{
if (Debugger.IsAttached == false)
return;
var path = Path.Combine(Environment.CurrentDirectory, String.Format("{0}tree.hdump", filenamePrefix ?? String.Empty));
TreeDumper.DumpHumanReadable(tx, path, tx.GetReadOnlyPage(startPageNumber));
}
开发者ID:mattwarren,项目名称:LinqToMemory,代码行数:7,代码来源:DebugStuff.cs
示例6: AllocateMorePages
public override void AllocateMorePages(Transaction tx, long newLength)
{
ThrowObjectDisposedIfNeeded();
var newLengthAfterAdjustment = NearestSizeToPageSize(newLength);
if (newLengthAfterAdjustment <= _totalAllocationSize)
return;
var allocationSize = newLengthAfterAdjustment - _totalAllocationSize;
PosixHelper.AllocateFileSpace(_fd, (ulong) (_totalAllocationSize + allocationSize));
PagerState newPagerState = CreatePagerState();
if (newPagerState == null)
{
var errorMessage = string.Format(
"Unable to allocate more pages - unsuccessfully tried to allocate continuous block of virtual memory with size = {0:##,###;;0} bytes",
(_totalAllocationSize + allocationSize));
throw new OutOfMemoryException(errorMessage);
}
newPagerState.DebugVerify(newLengthAfterAdjustment);
if (tx != null)
{
tx.EnsurePagerStateReference(newPagerState);
}
var tmp = PagerState;
PagerState = newPagerState;
tmp.Release(); //replacing the pager state --> so one less reference for it
_totalAllocationSize += allocationSize;
NumberOfAllocatedPages = _totalAllocationSize/PageSize;
}
开发者ID:IdanHaim,项目名称:ravendb,代码行数:35,代码来源:PosixMemoryMapPager.cs
示例7: Initialize
public void Initialize(FullTextIndex index, Transaction tx, IndexingConventions.ScorerCalc score)
{
Index = index;
Transaction = tx;
Score = score;
Init();
}
开发者ID:josephdecock,项目名称:Corax,代码行数:7,代码来源:Query.cs
示例8: DumpHumanReadable
public static void DumpHumanReadable(Transaction tx, string path, Page start)
{
using (var writer = File.CreateText(path))
{
var stack = new Stack<Page>();
stack.Push(start);
writer.WriteLine("Root page #{0}",start.PageNumber);
while (stack.Count > 0)
{
var currentPage = stack.Pop();
if (currentPage.IsLeaf)
{
writer.WriteLine();
writer.WriteLine("Page #{0}, NumberOfEntries = {1}, Flags = {2} (Leaf), Used: {3} : {4}", currentPage.PageNumber,currentPage.NumberOfEntries,currentPage.Flags, currentPage.SizeUsed, currentPage.CalcSizeUsed());
if(currentPage.NumberOfEntries <= 0)
writer.WriteLine("Empty page (tree corrupted?)");
for (int nodeIndex = 0; nodeIndex < currentPage.NumberOfEntries;nodeIndex++)
{
var node = currentPage.GetNode(nodeIndex);
var key = currentPage.GetNodeKey(node);
writer.WriteLine("Node #{0}, Flags = {1}, {4} = {2}, Key = {3}, Entry Size: {5}", nodeIndex, node->Flags, node->DataSize, MaxString(key.ToString(), 25), node->Flags == NodeFlags.Data ? "Size" : "Page",
SizeOf.NodeEntry(node));
}
writer.WriteLine();
}
else if(currentPage.IsBranch)
{
writer.WriteLine();
writer.WriteLine("Page #{0}, NumberOfEntries = {1}, Flags = {2} (Branch), Used: {3} : {4}", currentPage.PageNumber, currentPage.NumberOfEntries, currentPage.Flags, currentPage.SizeUsed, currentPage.SizeUsed);
var key = new Slice(SliceOptions.Key);
for (int nodeIndex = 0; nodeIndex < currentPage.NumberOfEntries; nodeIndex++)
{
var node = currentPage.GetNode(nodeIndex);
writer.WriteLine("Node #{2}, {0} / to page #{1}, Entry Size: {3}", GetBranchNodeString(nodeIndex, key, currentPage, node), node->PageNumber, nodeIndex,
SizeOf.NodeEntry(node));
}
for (int nodeIndex = 0; nodeIndex < currentPage.NumberOfEntries; nodeIndex++)
{
var node = currentPage.GetNode(nodeIndex);
if (node->PageNumber < 0 || node->PageNumber > tx.State.NextPageNumber)
{
writer.Write("Found invalid reference to page #{0}", currentPage.PageNumber);
stack.Clear();
break;
}
var child = tx.GetReadOnlyPage(node->PageNumber);
stack.Push(child);
}
writer.WriteLine();
}
}
}
}
开发者ID:cocytus,项目名称:ravendb,代码行数:60,代码来源:TreeDumper.cs
示例9: ParentPageAction
public ParentPageAction(Page parentPage, Page currentPage, Tree tree, Cursor cursor, Transaction tx)
{
_parentPage = parentPage;
_currentPage = currentPage;
_tree = tree;
_cursor = cursor;
_tx = tx;
}
开发者ID:IdanHaim,项目名称:ravendb,代码行数:8,代码来源:ParentPageAction.cs
示例10: CopyTo
public static void CopyTo(Transaction tx, NodeHeader* node, byte* dest)
{
if (node->Flags == (NodeFlags.PageRef))
{
var overFlowPage = tx.GetReadOnlyPage(node->PageNumber);
Memory.Copy(dest, overFlowPage.Base + Constants.PageHeaderSize, overFlowPage.OverflowSize);
}
Memory.Copy(dest, (byte*)node + node->KeySize + Constants.NodeHeaderSize, node->DataSize);
}
开发者ID:mattwarren,项目名称:LinqToMemory,代码行数:9,代码来源:NodeHeader.cs
示例11: DirectAccess
public static byte* DirectAccess(Transaction tx, NodeHeader* node)
{
if (node->Flags == (NodeFlags.PageRef))
{
var overFlowPage = tx.GetReadOnlyPage(node->PageNumber);
return overFlowPage.Base + Constants.PageHeaderSize;
}
return (byte*) node + node->KeySize + Constants.NodeHeaderSize;
}
开发者ID:mattwarren,项目名称:LinqToMemory,代码行数:9,代码来源:NodeHeader.cs
示例12: GetDataSize
public static int GetDataSize(Transaction tx, NodeHeader* node)
{
if (node->Flags == (NodeFlags.PageRef))
{
var overFlowPage = tx.GetReadOnlyPage(node->PageNumber);
return overFlowPage.OverflowSize;
}
return node->DataSize;
}
开发者ID:mattwarren,项目名称:LinqToMemory,代码行数:9,代码来源:NodeHeader.cs
示例13: Reader
public unsafe static ValueReader Reader(Transaction tx, NodeHeader* node)
{
if (node->Flags == (NodeFlags.PageRef))
{
var overFlowPage = tx.GetReadOnlyPage(node->PageNumber);
return new ValueReader(overFlowPage.Base + Constants.PageHeaderSize, overFlowPage.OverflowSize);
}
return new ValueReader((byte*)node + node->KeySize + Constants.NodeHeaderSize, node->DataSize);
}
开发者ID:randacc,项目名称:ravendb,代码行数:9,代码来源:NodeHeader.cs
示例14: UpdateMaxSeenTxId
private void UpdateMaxSeenTxId(Transaction tx)
{
if (_maxSeenTransaction > tx.Id)
{
throw new InvalidOperationException("Transaction ids has to always increment, but got " + tx.Id +
" when already seen tx " + _maxSeenTransaction);
}
_maxSeenTransaction = tx.Id;
}
开发者ID:GorelH,项目名称:ravendb,代码行数:9,代码来源:PageTable.cs
示例15: Clone
public StorageEnvironmentState Clone(Transaction tx)
{
return new StorageEnvironmentState
{
Root = Root != null ? Root.Clone(tx) : null,
FreeSpaceRoot = FreeSpaceRoot != null ? FreeSpaceRoot.Clone(tx) : null,
NextPageNumber = NextPageNumber
};
}
开发者ID:WimVergouwe,项目名称:ravendb,代码行数:9,代码来源:StorageEnvironmentState.cs
示例16: HasDuplicateBranchReferences
public static unsafe bool HasDuplicateBranchReferences(Transaction tx, Page start,out long pageNumberWithDuplicates)
{
var stack = new Stack<Page>();
var existingTreeReferences = new ConcurrentDictionary<long, List<long>>();
stack.Push(start);
while (stack.Count > 0)
{
var currentPage = stack.Pop();
if (currentPage.IsBranch)
{
for (int nodeIndex = 0; nodeIndex < currentPage.NumberOfEntries; nodeIndex++)
{
var node = currentPage.GetNode(nodeIndex);
existingTreeReferences.AddOrUpdate(currentPage.PageNumber, new List<long> { node->PageNumber },
(branchPageNumber, pageNumberReferences) =>
{
pageNumberReferences.Add(node->PageNumber);
return pageNumberReferences;
});
}
for (int nodeIndex = 0; nodeIndex < currentPage.NumberOfEntries; nodeIndex++)
{
var node = currentPage.GetNode(nodeIndex);
if (node->PageNumber < 0 || node->PageNumber > tx.State.NextPageNumber)
{
throw new InvalidDataException("found invalid reference on branch - tree is corrupted");
}
var child = tx.GetReadOnlyPage(node->PageNumber);
stack.Push(child);
}
}
}
Func<long, HashSet<long>> relevantPageReferences =
branchPageNumber => new HashSet<long>(existingTreeReferences
.Where(kvp => kvp.Key != branchPageNumber)
.SelectMany(kvp => kvp.Value));
// ReSharper disable once LoopCanBeConvertedToQuery
foreach (var branchReferences in existingTreeReferences)
{
if (
branchReferences.Value.Any(
referencePageNumber => relevantPageReferences(branchReferences.Key).Contains(referencePageNumber)))
{
pageNumberWithDuplicates = branchReferences.Key;
return true;
}
}
pageNumberWithDuplicates = -1;
return false;
}
开发者ID:mattwarren,项目名称:LinqToMemory,代码行数:56,代码来源:DebugStuff.cs
示例17: Allocate
public PageFromScratchBuffer Allocate(Transaction tx, int numberOfPages)
{
if (tx == null) throw new ArgumentNullException("tx");
var size = Utils.NearestPowerOfTwo(numberOfPages);
PageFromScratchBuffer result;
if (TryGettingFromAllocatedBuffer(tx, numberOfPages, size, out result))
return result;
if ((_lastUsedPage + size)*AbstractPager.PageSize > _sizeLimit)
{
var sp = Stopwatch.StartNew();
// Our problem is that we don't have any available free pages, probably because
// there are read transactions that are holding things open. We are going to see if
// there are any free pages that _might_ be freed for us if we wait for a bit. The idea
// is that we let the read transactions time to complete and do their work, at which point
// we can continue running.
// We start this by forcing a flush, then we are waiting up to the timeout for we are waiting
// for the read transactions to complete. It is possible that a long running read transaction
// would in fact generate enough work for us to timeout, but hopefully we can avoid that.
tx.Environment.ForceLogFlushToDataFile(tx);
while (sp.ElapsedMilliseconds < tx.Environment.Options.ScratchBufferOverflowTimeout)
{
if (TryGettingFromAllocatedBuffer(tx, numberOfPages, size, out result))
return result;
Thread.Sleep(32);
}
string message = string.Format("Cannot allocate more space for the scratch buffer.\r\n" +
"Current size is:\t{0:#,#;;0} kb.\r\n" +
"Limit:\t\t\t{1:#,#;;0} kb.\r\n" +
"Requested Size:\t{2:#,#;;0} kb.\r\n" +
"Already flushed and waited for {3:#,#;;0} ms for read transactions to complete.\r\n" +
"Do you have a long running read transaction executing?",
(_scratchPager.NumberOfAllocatedPages*AbstractPager.PageSize)/1024,
_sizeLimit/1024,
((_lastUsedPage + size)*AbstractPager.PageSize)/1024,
sp.ElapsedMilliseconds);
throw new ScratchBufferSizeLimitException(message);
}
// we don't have free pages to give out, need to allocate some
_scratchPager.EnsureContinuous(tx, _lastUsedPage, (int)size);
result = new PageFromScratchBuffer
{
PositionInScratchBuffer = _lastUsedPage,
Size = size,
NumberOfPages = numberOfPages
};
_allocatedPages.Add(_lastUsedPage, result);
_lastUsedPage += size;
return result;
}
开发者ID:cocytus,项目名称:ravendb,代码行数:56,代码来源:ScratchBufferPool.cs
示例18: TreeIterator
public TreeIterator(Tree tree, Transaction tx)
{
_tree = tree;
_tx = tx;
if (tree.KeysPrefixing)
_currentInternalKey = new PrefixedSlice(SliceOptions.Key);
else
_currentInternalKey = new Slice(SliceOptions.Key);
}
开发者ID:bbqchickenrobot,项目名称:ravendb,代码行数:10,代码来源:TreeIterator.cs
示例19: GetData
public static Slice GetData(Transaction tx, NodeHeader* node)
{
if (node->Flags == (NodeFlags.PageRef))
{
var overFlowPage = tx.GetReadOnlyPage(node->PageNumber);
if (overFlowPage.OverflowSize > ushort.MaxValue)
throw new InvalidOperationException("Cannot convert big data to a slice, too big");
return new Slice(overFlowPage.Base + Constants.PageHeaderSize, (ushort)overFlowPage.OverflowSize);
}
return new Slice((byte*)node + node->KeySize + Constants.NodeHeaderSize, (ushort) node->DataSize);
}
开发者ID:mattwarren,项目名称:LinqToMemory,代码行数:11,代码来源:NodeHeader.cs
示例20: SetItems
public void SetItems(Transaction tx, Dictionary<long, PagePosition> items)
{
UpdateMaxSeenTxId(tx);
foreach (var item in items)
{
var copy = item;
_values.AddOrUpdate(copy.Key, l => ImmutableAppendOnlyList<PagePosition>.Empty.Append(copy.Value),
(l, list) => list.Append(copy.Value));
}
}
开发者ID:GorelH,项目名称:ravendb,代码行数:11,代码来源:PageTable.cs
注:本文中的Voron.Impl.Transaction类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论