|
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using Newtonsoft.Json.Linq;
using Raven.Database;
namespace Raven.Importer
{
internal class Program
{
private static void Main(string[] args)
{
if (args.Length != 2)
{
Console.WriteLine("Usage: importer.exe db-dir docs-dir");
return;
}
var files = Directory.GetFiles(args[1]);
Console.WriteLine("Parsing {0:#,#} docs", files.Length);
var array = files.Select(x => JObject.Parse(File.ReadAllText(x))).ToArray();
Console.WriteLine("Inserting {0:#,#} docs", files.Length);
var sw = Stopwatch.StartNew();
var count = 0;
using (var db = new DocumentDatabase(new RavenConfiguration {DataDirectory = args[0]}))
{
foreach (var doc in array)
{
count++;
db.Put(null, Guid.Empty, doc, new JObject(), null);
}
}
Console.WriteLine("{0} doc inserts in {1}", count, sw.Elapsed);
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I've been a software developer since 1996 and have enjoyed C# since 2003. I have a Bachelor's degree in Computer Science and for some reason, a Master's degree in Business Administration. I currently do software development contracting/consulting.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.