本文整理汇总了C#中Transaction.Insert方法的典型用法代码示例。如果您正苦于以下问题:C# Transaction.Insert方法的具体用法?C# Transaction.Insert怎么用?C# Transaction.Insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Transaction
的用法示例。
在下文中一共展示了Transaction.Insert方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InsertMurMur
public void InsertMurMur(Transaction tran, string filename, string hash)
{
try
{
tran.Insert("murmur", filename.ToLower(), hash);
}
catch (Exception ex)
{
this.log.Error("Hash (murmur) insert failed", ex);
throw;
}
}
示例2: InsertHash
public void InsertHash(Transaction tran, string murmur, ulong hash)
{
try
{
var pcData = tran.Select<string, ulong>("hash", murmur, true);
if (pcData.Exists)
{
tran.RemoveKey("hash", murmur);
}
tran.Insert("hash", murmur, hash);
}
catch (Exception ex)
{
this.log.Error("Hash insert failed", ex);
throw;
}
}
示例3: GetHash
private ulong GetHash(Transaction tran, string filename)
{
var pcData = tran.Select<string, ulong>("dhash", filename);
if (!pcData.Exists)
{
try
{
var hash = new DHash().Compute(filename);
tran.Insert("dhash", filename, hash);
return hash;
}
catch (Exception ex)
{
this.log.Warn("Hash calculation failed", ex);
}
}
return pcData.Value;
}
示例4: GetHistogram
private static ComparableImage GetHistogram(Transaction tran, string first)
{
ComparableImage pc = null;
var pcData = tran.Select<string, HistogramData>("hist", first);
if (!pcData.Exists)
{
pc = new ComparableImage(new FileInfo(first));
tran.Insert("hist", first, new HistogramData(pc.Projections.HorizontalProjection, pc.Projections.VerticalProjection));
}
else
{
pc = new ComparableImage(new FileInfo(first), pcData.Value.X, pcData.Value.Y);
}
return pc;
}
示例5: GetComparisonResult
private double GetComparisonResult(Transaction tran, string first, string second)
{
var value = 0.0;
var key = string.Join("|~|", new[] { first, second }.OrderBy(x => x)).GetInt64HashCode();
var compData = tran.Select<long, double>("comp", key);
if (!compData.Exists)
{
var pc = GetHistogram(tran, first);
var cc = GetHistogram(tran, second);
value = pc.CalculateSimilarity(cc);
tran.Insert("comp", key, value);
}
else
{
value = compData.Value;
}
return value;
}
示例6: DoIndexing
/// <summary>
/// itbls and transaction must be supplied, to make it working from outside
/// </summary>
internal void DoIndexing(Transaction itran, Dictionary<string, ITS> xitbls)
{
byte[] btUdtStart = DateTime.UtcNow.Ticks.To_8_bytes_array_BigEndian();
ITS its = null;
byte[] kA = null;
byte[] kZ = null;
byte[] newSrch = null;
Row<string, byte[]> rWord = null;
//Dictionary<string, WordInDocs> wds = new Dictionary<string, WordInDocs>();
WordInDocs wd = null;
uint iterBlockId = 0;
int iterBlockLen = 0;
int blockSize = 0;
byte[] btBlock = null;
Dictionary<uint, byte[]> block = new Dictionary<uint, byte[]>();
byte[] btWah = null;
byte[] tmp = null;
byte[] val = null;
WABI wah = null;
foreach (var tbl in xitbls)
{
its = tbl.Value;
if (its.srch == null) //Can be instantiated in insert procedure, depending how we use indexer
{
its.srch = itran.InsertTable<byte>(tbl.Key, 3, 0);
its.srch.ValuesLazyLoadingIsOn = false;
}
//Are instantiated only hear
its.blocks = itran.InsertTable<byte>(tbl.Key, 10, 0);
its.words = itran.InsertTable<byte>(tbl.Key, 20, 0);
its.currentBlock = itran.Select<int, uint>(tbl.Key, 11).Value;
its.numberInBlock = itran.Select<int, uint>(tbl.Key, 12).Value;
its.blocks.ValuesLazyLoadingIsOn = false;
its.words.ValuesLazyLoadingIsOn = false;
if (its.currentBlock == 0)
{
its.numberInBlock = 0;
its.currentBlock = 1;
}
//Getting latest indexing time for that table
var litRow = itran.Select<byte, byte[]>(tbl.Key, 4);
byte[] lastIndexed = DateTime.MinValue.Ticks.To_8_bytes_array_BigEndian();
if (litRow.Exists)
lastIndexed = litRow.Value;
kA = lastIndexed.Concat(int.MinValue.To_4_bytes_array_BigEndian());
kZ = DateTime.MaxValue.Ticks.To_8_bytes_array_BigEndian().Concat(int.MaxValue.To_4_bytes_array_BigEndian());
//Key is word, Value.Item1 is documents list from which this word must be removed, Value.Item2 is documents List where word must be added
Dictionary<string, Tuple<HashSet<int>, HashSet<int>, WordInDocs>> ds = new Dictionary<string, Tuple<HashSet<int>, HashSet<int>, WordInDocs>>();
Tuple<HashSet<int>, HashSet<int>, WordInDocs> tpl = null;
//Dictionary<string, byte[]> tmpWrds = new Dictionary<string, byte[]>(StringComparison.Ordinal);
var tmpWrds = new SortedDictionary<string, byte[]>(StringComparer.Ordinal);
foreach (var docId in its.ChangedDocIds)
{
//diff will return list of words to be removed and list of words to be added
newSrch = its.srch.Select<byte[], byte[]>(docId.To_4_bytes_array_BigEndian().Concat(new byte[] { 1 })).Value;
var diff = WordsDiff(
its.srch.Select<byte[], byte[]>(docId.To_4_bytes_array_BigEndian().Concat(new byte[] { 0 }), true).Value, //Current searchables
newSrch //new
);
//Copying new searchables to current searchables
its.srch.ChangeKey<byte[]>(docId.To_4_bytes_array_BigEndian().Concat(new byte[] { 1 }), docId.To_4_bytes_array_BigEndian().Concat(new byte[] { 0 }));
//its.srch.Insert<byte[], byte[]>(docId.To_4_bytes_array_BigEndian().Concat(new byte[] { 0 }), newSrch);
Action <string> createNew = (word) =>
{
if (!tmpWrds.ContainsKey(word))
{
rWord = its.words.Select<string, byte[]>(word, true);
wd = new WordInDocs();
if (rWord.Exists)
{
wd.BlockId = rWord.Value.Substring(0, 4).To_UInt32_BigEndian();
wd.NumberInBlock = rWord.Value.Substring(4, 4).To_UInt32_BigEndian();
}
else
{
its.numberInBlock++;
if (its.numberInBlock > itran._transactionUnit.TransactionsCoordinator._engine.Configuration.TextSearchConfig.QuantityOfWordsInBlock) //Quantity of words (WAHs) in block
{
its.currentBlock++;
its.numberInBlock = 1;
}
//.........这里部分代码省略.........