讓我們有很多這樣的類(百萬)數據庫選擇快速更新
class WordInfo
{
string Value;
string SomeOtherFeatures;
List<Point> Points;
}
而下面的代碼
private Dictionary<string, WordInfo> _dict;
public void ProcessData(IEnumerable<Tuple<string,int,int> words)
{
foreach(var word in words)
{
if(_dict.ContainsKey(word.Item1))
{
_dict[word.Item1].Points.Add(new Point(word.Item2,word.Item3));
}
else
{
_dict.Add(word.Item1, new WordInfo(....))
}
}
}
Main()
{
while(true)
{
IEnumerable<Tuple<string,int,int> data = GetDataSomewhere();
ProcessData(data);
}
}
正如你可以看到這個代碼必須工作24 \ 7。主要問題是我不知道如何在數據庫中表示_dict(我存儲信息的地方)。我需要每秒處理1000-5000個字。關係數據庫不適合我的任務,對吧?那麼NoSQL呢?我需要快速的UPDATE和INSERT操作。另外我需要快速檢查是存在(SELECT)在分貝。因爲我有數百萬條記錄,這也不是微不足道的。你可以建議什麼?可能是基於文件寫我的自定義解決方案?
如果你想持久;你將需要某種DBMS。如果你想要原始速度,你可以使用核心散列表。在這種情況下,幾Mword/s的速度是可能的。要實現一種持久性,您需要記錄添加/刪除操作,並定期將語料庫轉儲到磁盤。這將花費時間。 – wildplasser