我发现了这个名为 TeaFiles.NET 的引人注目的库。
我正在编写一个非常简单的控制台应用程序来测试它。
这是代码:
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Starting....");
string filename = String.Format("History_{0}.{1}.{2}.tea",
DateTime.Now.Year,
DateTime.Now.Month,
DateTime.Now.Day);
File.Delete(filename);
using (var tf = TeaFile<HistoryRow>.Create(filename))
{
var items = new List<HistoryRow>();
for (int i = 0; i < 1000; i++)
{
for (int k = 0; k < 100000; k++)
{
items.Add(new HistoryRow()
{
Flags = 192,
Name = "Name_" + i.ToString(CultureInfo.InvariantCulture),
Value = k,
Timestamp = DateTime.Now.AddTicks((long)i)
});
}
}
var sw = Stopwatch.StartNew();
Console.WriteLine("Initiate write...");
tf.Write(items);
sw.Stop();
Console.WriteLine("...completed write in {0} ms.", sw.ElapsedMilliseconds);
}
Console.ReadLine();
}
}
struct HistoryRow
{
public string Name;
public dynamic Value;
public Time Timestamp;
public int Flags;
}
这应该很简单。相反,它在 Create() 调用中出错,并出现以下错误:
"The specified Type must be a struct containing no references".
我真的不知道从哪里开始故障排除....