本文整理汇总了C#中IIndex.Add方法的典型用法代码示例。如果您正苦于以下问题:C# IIndex.Add方法的具体用法?C# IIndex.Add怎么用?C# IIndex.Add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IIndex
的用法示例。
在下文中一共展示了IIndex.Add方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InitGroups
public void InitGroups(QueryProcessor processor, IIndex<long> emptyIndexContainer)
{
Debug.Assert(emptyIndexContainer.Count == 0);
ITable child = BaseTable;
// No groups, so make the entire child table the group,
if (aggregateComposite == null || child.RowCount <= 1) {
emptyIndexContainer.Add(0);
emptyIndexContainer.Add(child.RowCount);
}
// Populate the index by the aggregate composite,
else {
// Create a resolver for the composite function
IndexResolver resolver = processor.CreateResolver(child, aggregateComposite);
// The groups state
long groupPos = 0;
long groupSize = 0;
SqlObject[] lastComposite = null;
// Scan over the child
IRowCursor cursor = child.GetRowCursor();
while (cursor.MoveNext()) {
RowId rowid = cursor.Current;
// Get the group term
SqlObject[] groupValue = resolver.GetValue(rowid);
if (lastComposite == null) {
lastComposite = groupValue;
} else {
int c = SqlObject.Compare(groupValue, lastComposite);
// If group_val > the last composite, we are on a new group
if (c > 0) {
// New group,
emptyIndexContainer.Add(groupPos);
emptyIndexContainer.Add(groupSize);
lastComposite = groupValue;
groupPos = groupPos + groupSize;
groupSize = 0;
} else if (c < 0) {
// This will happen if the child table is not sorted by the
// composite expression.
throw new ApplicationException("Aggregate child is not sorted correctly.");
}
}
++groupSize;
}
// Final group
// (the below check probably not necessary since we already check for the
// empty child so group size will always be >1 at this point).
if (groupSize > 0) {
emptyIndexContainer.Add(groupPos);
emptyIndexContainer.Add(groupSize);
}
}
// Set the group index
childGroupsIndex = emptyIndexContainer;
lookupCursor = BaseTable.GetRowCursor();
}
示例2: Import
public void Import(IIndex index, int count)
{
var reader = new DataDumpReader<Post>();
var xml = Path.Combine(path, "posts.xml");
index.Add(reader.Read(xml)
.Where(p => p.PostTypeId == PostTypeId.Question)
.Take(count));
}
示例3: SetUp
public void SetUp()
{
FullTextSearchIndex index = new FullTextSearchIndex();
index.Fields.Add("Title");
FullTextSearchIndex multipleFieldIndex = new FullTextSearchIndex();
multipleFieldIndex.Fields.Add("Title");
multipleFieldIndex.Fields.Add("Ingredients");
_index = index;
_multipleFieldIndex = multipleFieldIndex;
_record1 = new HashtableRecord();
_record1["Title"] = "Bolo de Chocolate";
_record1["Calories"] = 300;
_record1["Ingredients"] = "3 colheres de açucar\n1 lata de nescau\nfermento";
_index.Add(_record1);
_multipleFieldIndex.Add(_record1);
DumpPostings(index.Postings);
_record2 = new HashtableRecord();
_record2["Title"] = "Bolo de Açafrão";
_record2["Calories"] = 100;
_record2["Ingredients"] = "10 folhas de açafrão\n1 colher de fermento em pó";
_index.Add(_record2);
_multipleFieldIndex.Add(_record2);
DumpPostings(index.Postings);
_record3 = new HashtableRecord();
_record3["Title"] = "Torta de Chocolate";
_record3["Calories"] = 400;
_record3["Ingredients"] = "1 lata de nescau\nchocolate granulado\naçucar";
_index.Add(_record3);
_multipleFieldIndex.Add(_record3);
DumpPostings(index.Postings);
}