当前位置: 首页>>代码示例>>C#>>正文


C# EmbeddableDocumentStore.BulkInsert方法代码示例

本文整理汇总了C#中Raven.Client.Embedded.EmbeddableDocumentStore.BulkInsert方法的典型用法代码示例。如果您正苦于以下问题:C# EmbeddableDocumentStore.BulkInsert方法的具体用法?C# EmbeddableDocumentStore.BulkInsert怎么用?C# EmbeddableDocumentStore.BulkInsert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Raven.Client.Embedded.EmbeddableDocumentStore的用法示例。


在下文中一共展示了EmbeddableDocumentStore.BulkInsert方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: BulkInsertTrialDataEmbedded

        public long BulkInsertTrialDataEmbedded(RavenConnection ravenConnection, IEnumerable<TrialData> trialBatch)
        {
            var watch = new Stopwatch();
            watch.Start();

            var eds = new EmbeddableDocumentStore { DataDirectory = @"C:\Projects\EDSTest\EDSData" };
            eds.Initialize();
            using (var bulkInsert = eds.BulkInsert())
            {
                foreach (var item in trialBatch)
                    bulkInsert.Store(item);
            }

            watch.Stop();
            return watch.ElapsedMilliseconds;
        }
开发者ID:ColinCarson,项目名称:Scratch,代码行数:16,代码来源:RavenDB.cs

示例2: ConfigureRaven

        public static void ConfigureRaven(MvcApplication application)
        {
            var store = new EmbeddableDocumentStore
                                {
                                    DataDirectory = "~/App_Data/Database",
                                    UseEmbeddedHttpServer = true
                                };

            store.Initialize();
            MvcApplication.DocumentStore = store;

            IndexCreation.CreateIndexes(typeof(MvcApplication).Assembly, store);

            var statistics = store.DatabaseCommands.GetStatistics();

            if (statistics.CountOfDocuments < 5)
                using (var bulkInsert = store.BulkInsert())
                    LoadRestaurants(application.Server.MapPath("~/App_Data/Restaurants.csv"), bulkInsert);
        }
开发者ID:khalidabuhakmeh,项目名称:RavenBurgerCo,代码行数:19,代码来源:RavenConfig.cs

示例3: ConfigureRaven

        public static void ConfigureRaven(MvcApplication application)
        {
            var store = new EmbeddableDocumentStore
                                {
                                    DataDirectory = "~/App_Data/Database",
                                    UseEmbeddedHttpServer = true
                                };

            store.Conventions.CustomizeJsonSerializer = x => x.Converters.Add(new GeoJsonConverter());
            store.Initialize();
            MvcApplication.DocumentStore = store;

            store.ExecuteIndex(new RestaurantIndex());
            store.ExecuteTransformer(new RestaurantsTransformer());

            var statistics = store.DatabaseCommands.GetStatistics();

            if (statistics.CountOfDocuments < 5)
                using (var bulkInsert = store.BulkInsert())
                    LoadRestaurants(application.Server.MapPath("~/App_Data/Restaurants.csv"), bulkInsert);
        }
开发者ID:sibartlett,项目名称:RavenBurgerCo,代码行数:21,代码来源:RavenConfig.cs

示例4: CanStoreDocumentWithNonStringIdPropertyAndDefaultValue

        public void CanStoreDocumentWithNonStringIdPropertyAndDefaultValue()

        {
            using (var store = new EmbeddableDocumentStore
            {
                RunInMemory = true,
                Configuration =
                {
                    RunInUnreliableYetFastModeThatIsNotSuitableForProduction = true
                }

            })

            {
                store.Configuration.Storage.Voron.AllowOn32Bits = true;
                store.Initialize();

                using (var insert = store.BulkInsert())
                {
                    Assert.DoesNotThrow(() => insert.Store(new ExampleInt32()));
                    Assert.DoesNotThrow(() => insert.Store(new ExampleInt64()));
                }
            }
        }
开发者ID:j2jensen,项目名称:ravendb,代码行数:24,代码来源:RavenDB_3422.cs

示例5: Update

        public static void Update()
        {
            using (Siaqodb siaqodb = new Siaqodb())
            {
                siaqodb.Open(siaqodbPath, 300 * OneMB, 200);

                Console.WriteLine("Siaqodb UPDATE...");
                var stopwatch = new Stopwatch();
                stopwatch.Start();
                var trans = siaqodb.BeginTransaction();
                for (int i = 0; i < ENTITY_COUNT; i++)
                {
                    Document doc = new Document();
                    doc.Key = entities[i].Id;
                    entities[i].StringValue += i.ToString();
                    entities[i].IntValue++;
                    //set document content
                    doc.SetContent<MyEntity>(entities[i]);
                   //update the index too
                    doc.SetTag("myint", entities[i].IntValue);

                    //store the doc within the Bucket called 'myentities'
                    siaqodb.Documents["myentities"].Store(doc, trans);
                }
                trans.Commit();

                stopwatch.Stop();
                Console.WriteLine("Siaqodb UPDATE took:" + stopwatch.Elapsed);

            }
            using (EmbeddableDocumentStore store = new EmbeddableDocumentStore
            {
                DataDirectory = ravenDBPath

            })
            {
                store.Configuration.DefaultStorageTypeName = "voron";
                store.Initialize(); // initializes document store, by connecting to server and downloading various configurations
                Raven.Abstractions.Data.BulkInsertOptions opt = new Raven.Abstractions.Data.BulkInsertOptions()
                { OverwriteExisting = true };
                using (BulkInsertOperation bulkInsert = store.BulkInsert(null,opt ))
                {
                    Console.WriteLine("RavenDB UPDATE...");
                    var stopwatch = new Stopwatch();
                    stopwatch.Start();

                    for (int i = 0; i < ENTITY_COUNT; i++)
                    {
                        entities[i].StringValue += i.ToString();
                        entities[i].IntValue++;
                        bulkInsert.Store(entities[i], entities[i].Id);
                    }

                    stopwatch.Stop();
                    Console.WriteLine("RavenDB UPDATE took:" + stopwatch.Elapsed);

                }
            }
        }
开发者ID:Dotissi,项目名称:SiaqodbBenchmark,代码行数:59,代码来源:Program.cs

示例6: Insert

        public static void Insert()
        {
            GenerateEntities();

            using (Siaqodb siaqodb = new Siaqodb())
            {
                siaqodb.Open(siaqodbPath, 300 * OneMB, 200);

                Console.WriteLine("Siaqodb INSERT...");
                var stopwatch = new Stopwatch();
                stopwatch.Start();
                var trans = siaqodb.BeginTransaction();
                for (int i = 0; i < ENTITY_COUNT; i++)
                {
                    Document doc = new Document();
                    doc.Key = entities[i].Id;
                    //set document content
                    doc.SetContent<MyEntity>(entities[i]);
                    //set tags(indexes)
                    doc.SetTag("myint", entities[i].IntValue);

                    //store the doc within the Bucket called 'myentities'
                    siaqodb.Documents["myentities"].Store(doc, trans);
                }
                trans.Commit();
                stopwatch.Stop();
                Console.WriteLine("Siaqodb INSERT took:" + stopwatch.Elapsed);

            }
            using (EmbeddableDocumentStore store = new EmbeddableDocumentStore
            {
                DataDirectory = ravenDBPath

            })
            {
                store.Configuration.DefaultStorageTypeName = "voron";
                store.Initialize(); // initializes document store, by connecting to server and downloading various configurations

                store.DatabaseCommands.PutIndex("MyEntity/IntValue",
                      new IndexDefinitionBuilder<MyEntity>()
                      {
                          Map = myints => from mi in myints
                                          select new { IntValue = mi.IntValue }
                      }, true);

                using (BulkInsertOperation bulkInsert = store.BulkInsert())
                {
                    Console.WriteLine("RavenDB INSERT...");
                    var stopwatch = new Stopwatch();
                    stopwatch.Start();

                    for (int i = 0; i < ENTITY_COUNT; i++)
                    {
                        bulkInsert.Store(entities[i], entities[i].Id);

                    }

                    stopwatch.Stop();
                    Console.WriteLine("RavenDB INSERT took:" + stopwatch.Elapsed);

                }
                using (IDocumentSession session = store.OpenSession()) // opens a session that will work in context of 'DefaultDatabase'
                {
                    //waiting for index to finish write operations
                    int temp = entities[0].IntValue;
                    var qq = (from myentity in session.Query<MyEntity>("MyEntity/IntValue").Customize(a => a.WaitForNonStaleResults())
                              where myentity.IntValue == temp
                              select myentity).ToList();
                }

            }
        }
开发者ID:Dotissi,项目名称:SiaqodbBenchmark,代码行数:72,代码来源:Program.cs

示例7: Main

        static void Main(string[] args)
        {
            Metrics.EnableConsoleReporting(10, TimeUnit.Seconds);
            var dataDir = GetDbPath();
            //Directory.Delete(dataDir);

            // Initialize RavenDB
            using (
                var documentStore = new EmbeddableDocumentStore
                                    {
                                        DataDirectory = dataDir,
                                        UseEmbeddedHttpServer = true,
                                        EnlistInDistributedTransactions = false
                                    })
            {

                documentStore.Configuration.Port = 33333;
                documentStore.Configuration.HostName = "localhost";
                documentStore.Configuration.CompiledIndexCacheDirectory = dataDir;
                documentStore.Configuration.VirtualDirectory = "/storage";

                documentStore.Conventions.SaveEnumsAsIntegers = true;

                documentStore.Initialize();

                new MessagesViewIndex().Execute(documentStore);
                documentStore.DatabaseCommands.PutIndex("Raven/DocumentsByEntityName", new IndexDefinition
                {
                    Map =
                        @"from doc in docs
            let Tag = doc[""@metadata""][""Raven-Entity-Name""]
            select new { Tag, LastModified = (DateTime)doc[""@metadata""][""Last-Modified""] };",
                    Indexes =
                    {
                        {"Tag", FieldIndexing.NotAnalyzed},
                        {"LastModified", FieldIndexing.NotAnalyzed},
                    },
                    Stores =
                    {
                        {"Tag", FieldStorage.No},
                        {"LastModified", FieldStorage.No}
                    },
                    TermVectors =
                    {
                        {"Tag", FieldTermVector.No},
                        {"LastModified", FieldTermVector.No}
                    },
                    DisableInMemoryIndexing = true,
                });

                const int documentsPerThread = 50000;
                const bool doBulk = true;
                const int bulkSize = 100;
                Console.WriteLine("Pushing documents...");
                if (doBulk)
                {
                    Console.WriteLine("(using bulk size of {0})", bulkSize);
                }

                var stopwatch = new Stopwatch();
                stopwatch.Start();

                Parallel.For(0, 10, l =>
                                    {
                                        using (var session = documentStore.BulkInsert())
                                        {
                                        for (int i = 0; i < documentsPerThread; i++)
                                              {
                                                      var msgGuid = Guid.NewGuid().ToString();
                                                      var msg = new ProcessedMessage
                                                            {
                                                                Id = "ProcessedMessage/" + msgGuid,
                                                                MessageMetadata = new Dictionary<string, object>
                                                                {
                                                                    {"MessageId", Guid.NewGuid().ToString()},
                                                                    {"MessageIntent", "1"},
                                                                    {"HeadersForSearching", "967cfa52-d114-4958-940a-a2d100053f8f 967cfa52-d114-4958-940a-a2d100053f8f MyClient USER-PC Send 4.3.4 2014-02-12 22:19:06:505614 Z 102ade9ea86c452da6394e4ba7e2900c text/xml MyMessages.RequestDataMessage, MyMessages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null 967cfa52-d114-4958-940a-a2d100053f8f\\0  316b2439-21b4-4b45-8989-a2d100053f8f MyServer USER-PC 2014-02-12 22:19:06:509614 Z 2014-02-12 22:19:06:510615 Z [email protected]" + Guid.NewGuid()},
                                                                    {"TimeSent", DateTime.UtcNow},
                                                                    {"CriticalTime", TimeSpan.FromMinutes(1)},
                                                                    {"ProcessingTime", TimeSpan.FromMinutes(2)},
                                                                    {"DeliveryTime", TimeSpan.FromSeconds(2)},
                                                                    {"ContentLength", 213},
                                                                    {"ContentType", "text/xml"},
                                                                    {"SearchableBody", "<?xml version=\"1.0\" ?>\r\n<Messages xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns=\"http://tempuri.net/MyMessages\">\n<RequestDataMessage>\n<DataId>102ade9e-a86c-452d-a639-4e4ba7e2900c</DataId>\n<String>&lt;node&gt;it&apos;s my &quot;node&quot; &amp; i like it&lt;node&gt;</String>\n</RequestDataMessage>\n</Messages>\r\n"},
                                                                    {"BodyUrl", "/messages/6d004d6f-56c2-fe71-15d1-27199b59484b/body"},
                                                                    {"BodySize", 369},
                                                                    {"IsSystemMessage", false},
                                                                    {"MessageType", "MyMessages.RequestDataMessage"},
                                                                    {"SearchableMessageType", "MyMessages RequestDataMessage"},
                                                                    {"SendingEndpoint", new EndpointDetails {Name = "MyClient", Machine = "USER-PC"}},
                                                                    {"ReceivingEndpoint", new EndpointDetails {Name = "MyClient", Machine = "USER-PC"}},
                                                                    {"ConversationId", Guid.NewGuid().ToString()},
                                                                },
                                                                Headers = new Dictionary<string, string>
                                                                {
                                                                    {"NServiceBus.MessageId", msgGuid},
                                                                    {"NServiceBus.CorrelationId", msgGuid},
                                                                    {"NServiceBus.OriginatingEndpoint", "MyClient"},
                                                                    {"NServiceBus.OriginatingMachine", "USER-PC"},
                                                                    {"NServiceBus.MessageIntent", "Send"},
//.........这里部分代码省略.........
开发者ID:synhershko,项目名称:RavenDB-tryouts,代码行数:101,代码来源:Program.cs


注:本文中的Raven.Client.Embedded.EmbeddableDocumentStore.BulkInsert方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。