本文整理汇总了C#中Voron.Impl.Transaction类的典型用法代码示例。如果您正苦于以下问题:C# Transaction类的具体用法?C# Transaction怎么用?C# Transaction使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Transaction类属于Voron.Impl命名空间,在下文中一共展示了Transaction类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Searcher
public Searcher(FullTextIndex index)
{
_index = index;
_tx = _index.StorageEnvironment.NewTransaction(TransactionFlags.Read);
_docs = _tx.ReadTree("Docs");
}
示例2: TransactionActivityEntry
public TransactionActivityEntry(Transaction tx, DebugActionType actionType)
{
TransactionId = tx.Id;
Flags = tx.Flags;
ActionType = actionType;
CreatedByJournalApplicator = tx.CreatedByJournalApplicator;
}
示例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;
}
示例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();
}
示例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));
}
示例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;
}
示例7: Initialize
public void Initialize(FullTextIndex index, Transaction tx, IndexingConventions.ScorerCalc score)
{
Index = index;
Transaction = tx;
Score = score;
Init();
}
示例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();
}
}
}
}
示例9: ParentPageAction
public ParentPageAction(Page parentPage, Page currentPage, Tree tree, Cursor cursor, Transaction tx)
{
_parentPage = parentPage;
_currentPage = currentPage;
_tree = tree;
_cursor = cursor;
_tx = tx;
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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
};
}