本文整理汇总了C#中Record.BuildIndex方法的典型用法代码示例。如果您正苦于以下问题:C# Record.BuildIndex方法的具体用法?C# Record.BuildIndex怎么用?C# Record.BuildIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Record
的用法示例。
在下文中一共展示了Record.BuildIndex方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuildIndex
public static void BuildIndex( string db_name, string container_name )
{
var db1 = DataBase.LoadFrom( db_name, null );
var dc1 = new DataContainer( db1, container_name );
var rec1 = new Record( dc1 );
rec1.Id = 102;
rec1.BuildIndex();
var hash_expected = "2D8C1282A16592B40656F06F80D75172";
Assert.AreEqual( hash_expected, rec1.GetIndex().DwarfHashCode );
}
示例2: CreateRecord
public static void CreateRecord( string db_name, string container_name )
{
UnitTests.DataBaseTest.Create();
UnitTests.DataBaseTest.CreateContainer();
var user = User.User.New( "root", "12345678");
var cm = new ChunkManager.ChunkManager();
var db = DataBase.LoadFrom( db_name, cm );
var dc = db.GetDataContainer( container_name, user );
// Creating a new record
var rec = new Record(dc);
rec["col1"].Value = "AAABBBCCC";
rec["col2"].Value = 20.390494;
rec.BuildIndex();
dc.AddRecordToDataStorage(rec);
dc.Save();
Assert.IsTrue( dc.GetRecordsInternal().Count >= 1 );
}
示例3: DataTableChunkCreationBin
public static void DataTableChunkCreationBin()
{
string test_binary = String.Empty;
var user = User.User.New( "root", "12345678");
if (!File.Exists ("./testdata/binary.jpg")) {
Errors.Messages.DisplayError ("No file : ./testdata/binary.jpg", String.Empty, String.Empty, DateTime.Now);
}
var bts = File.ReadAllBytes( "./testdata/binary.jpg");
test_binary = System.Text.Encoding.Default.GetString( bts );
Console.WriteLine ("Create or use an existing db (0/1)?: ");
string choise = Console.ReadLine ();
Console.WriteLine ("Enter db name: ");
string db_name = Console.ReadLine ();
var indexes = new List<Index> ();
var chunk_manager = new ChunkManager.ChunkManager ();
if (choise.Trim () == "0") {
Console.WriteLine ("Enter rows count: ");
int rows_count = Int32.Parse (Console.ReadLine ());
Console.WriteLine ("Enter cols count: ");
int cols_count = Int32.Parse (Console.ReadLine ());
Console.WriteLine ("Enter chunk size: ");
Console.WriteLine ("Creating DB...");
var db = DataBase.Create (db_name,
chunk_manager);
Console.WriteLine ("Creating DC...");
var dc = new DataContainer (db, "DCBin");
for (int i = 0; i < cols_count; ++i) {
var column = new Column ();
column.Name = "col" + i.ToString ();
column.Type = DataType.BINARY;
dc.AddColumn (column, user);
}
for (int k = 0; k < rows_count; ++k) {
var rec1 = new Record (dc);
rec1.Id = dc.NextId ();
foreach (var col in dc.Columns) {
rec1 [col.Name].Value = test_binary;
rec1 [col.Name].Type = DataType.BINARY;
rec1.BuildIndex ();
}
dc.AddRecordToDataStorage (rec1);
indexes.Add (rec1.GetIndex ());
}
dc.Save ();
} else {
Console.WriteLine ("Trying to get data from db \"" + db_name + "\"");
var db2 = DataBase.LoadFrom (db_name, chunk_manager);
var dc = chunk_manager.GetDataContainer ("DCBin");
dc.AssignOwnerDB (db2);
//Console.WriteLine("Preloading DC1...");
dc.PreLoad ( user );
// Getting a record
Record rc = null;
Record rc1 = null;
Record rc2 = null;
Record rc3 = null;
Record rc4 = null;
var get_time = Checks.ExecutionTimeCheck.DoCheck (() => {
rc = dc.GetRecord (2030, user);
});
var get_time2 = Checks.ExecutionTimeCheck.DoCheck (() => {
rc1 = dc.GetRecord (10, user);
});
var get_time3 = Checks.ExecutionTimeCheck.DoCheck (() => {
rc = dc.GetRecord (30, user);
});
var get_time4 = Checks.ExecutionTimeCheck.DoCheck (() => {
rc3 = dc.GetRecord (20, user);
});
var get_time2s = Checks.ExecutionTimeCheck.DoCheck (() => {
rc4 = dc.GetRecord (7900, user);
});
Console.WriteLine ("Getting value time1, ms: " + get_time.ToString ());
Console.WriteLine ("Getting value time2, ms: " + get_time2.ToString ());
Console.WriteLine ("Getting value time3, ms: " + get_time3.ToString ());
Console.WriteLine ("Getting value time4, ms: " + get_time4.ToString ());
Console.WriteLine ("Getting value time2s, ms: " + get_time2s.ToString ());
if (rc1 != null && !(rc is DummyRecord)) {
var binval = System.Text.Encoding.Default.GetBytes(rc1.Fields [0].Value.ToString ());
Console.WriteLine ("Val: " + binval.ToString());
using ( var fl = File.Create( "./testdata/binary_1.jpg" ) ) {
//.........这里部分代码省略.........
示例4: DataTableChunkCreation
//.........这里部分代码省略.........
if ( k % 2 == 0 ) {
rec1[col.Name].Value = "съешь ещё этих мягких французских булок да выпей чаю "+col.Name+" "+k.ToString();
rec1[col.Name].Type = DataType.STRING;
} else {
rec1[col.Name].Value = k*100;
rec1[col.Name].Type = DataType.INT;
}
if ( k % 2 == 0 ) {
rec2[col.Name].Value = "Цитрус "+col.Name+" "+k.ToString()+":::"+db.Name;
rec2[col.Name].Type = DataType.STRING;
} else {
rec2[col.Name].Value = k*555;
rec2[col.Name].Type = DataType.INT;
}
}
dc.AddRecordToDataStorage( rec1 );
indexes.Add(rec1.GetIndex());
dc2.AddRecordToDataStorage( rec2 );
indexes.Add(rec2.GetIndex());
}
dc.Save();
dc2.Save();
} else {
Console.WriteLine("Trying to get data from db \""+db_name+"\"");
var db2 = DataBase.LoadFrom( db_name , chunk_manager );
var dc2 = chunk_manager.GetDataContainer( "DataC1" );
var dc = chunk_manager.GetDataContainer( "DataC2" );
dc2.AssignOwnerDB(db2);
dc.AssignOwnerDB(db2);
Console.WriteLine("DC2 reccount: "+dc2.AllRecordsCount);
Console.WriteLine("DC reccount: "+dc.AllRecordsCount);
// Getting a record
Console.WriteLine("DCs preloading... ");
//dc.PreLoad( user );
//dc2.PreLoad( user );
// Additional records
Console.WriteLine("Adding some new records... ");
for ( int i =0; i < 10; ++i ) {
var rec = new Record( dc );
rec.Id = dc.NextId();
foreach ( var col in dc.Columns) {
rec[col.Name].Value = "Цитрус "+col.Name+" "+i.ToString()+"AAAAAAAAA";
rec[col.Name].Type = DataType.STRING;
}
rec.BuildIndex();
indexes.Add(rec.GetIndex());
dc.AddRecordToDataStorage(rec);
}
chunk_manager.RebuildIndexes( dc.GetOwnerDB() );
dc.Save();
dc.PreLoad( user );
Console.WriteLine("Trying LINQ #1...");
var aa1 = dc.Select((x,y)=>x);
foreach ( var rec in aa1) {
Console.WriteLine("Rec:"+rec.Fields[0].Type+" : "+rec.Fields[0].Value+" $$"+aa1.Count()+
":"+rec.Fields[1].Type+" : "+rec.Fields[1].Value+" $$"+aa1.Count());
}
Console.WriteLine("Trying LINQ #2...");
var aa2 = dc.Select((x,y)=>x).Where( (x) => {
return x.Fields[1].Type == DataType.INT &&
(int.Parse(x.Fields[1].Value.ToString()) % 5 == 0);
}).ToArray();
foreach ( var rec in aa2) {
Console.WriteLine("Rec:"+rec.Fields[0].Type+" : "+rec.Fields[0].Value+" $$"+aa2.Count()+
":"+rec.Fields[1].Type+" : "+rec.Fields[1].Value+" $$"+aa2.Count());
}
Console.WriteLine("Trying LINQ #3 (dc & dc2)...");
var aa3 = (from rec in dc
join recb in dc2 on
rec.Fields[1].Value.ToString() equals recb.Fields[1].Value.ToString()
where rec.Fields[1].Type == DataType.INT && recb.Fields[1].Type == DataType.INT
select rec).ToArray();
foreach ( var rec in aa3 ) {
Console.WriteLine("Rec:"+rec.Fields[0].Type+" : "+rec.Fields[0].Value+" $$"+aa3.Count()+
":"+rec.Fields[1].Type+" : "+rec.Fields[1].Value+" $$"+aa3.Count());
}
Console.WriteLine("DO YOU WANT TO DROP THIS DB (Y/N)?");
if ( Console.ReadLine() == "Y" ) {
db2.Drop( user );
}
}
}