예제 #1
0
        public string PutIndex(string name, IndexDefinition definition)
        {
            switch (IndexDefinitionStorage.FindIndexCreationOptionsOptions(name, definition))
            {
            case IndexCreationOptions.Noop:
                return(name);

            case IndexCreationOptions.Update:
                // ensure that the code can compile
                new DynamicViewCompiler(name, definition).GenerateInstance();
                DeleteIndex(name);
                break;
            }
            IndexDefinitionStorage.AddIndex(name, definition);
            IndexStorage.CreateIndexImplementation(name, definition);
            TransactionalStorage.Batch(actions =>
            {
                actions.AddIndex(name);
                var firstAndLast = actions.FirstAndLastDocumentIds();
                if (firstAndLast.Item1 != 0 && firstAndLast.Item2 != 0)
                {
                    for (var i = firstAndLast.Item1; i <= firstAndLast.Item2; i += Configuration.IndexingBatchSize)
                    {
                        actions.AddTask(new IndexDocumentRangeTask
                        {
                            FromId = i,
                            ToId   = Math.Min(i + Configuration.IndexingBatchSize, firstAndLast.Item2),
                            Index  = name
                        });
                    }
                }
                workContext.ShouldNotifyAboutWork();
            });
            return(name);
        }
예제 #2
0
        public void ResetIndex(string index)
        {
            var indexDefinition = IndexDefinitionStorage.GetIndexDefinition(index);

            if (indexDefinition == null)
            {
                throw new InvalidOperationException("There is no index named: " + index);
            }
            IndexStorage.DeleteIndex(index);
            IndexStorage.CreateIndexImplementation(index, indexDefinition);
            TransactionalStorage.Batch(actions =>
            {
                actions.Indexing.DeleteIndex(index);
                AddIndexAndEnqueueIndexingTasks(actions, index);
            });
        }
예제 #3
0
        public string PutIndex(string name, IndexDefinition definition)
        {
            switch (IndexDefinitionStorage.FindIndexCreationOptionsOptions(name, definition))
            {
            case IndexCreationOptions.Noop:
                return(name);

            case IndexCreationOptions.Update:
                // ensure that the code can compile
                new DynamicViewCompiler(name, definition, Extensions).GenerateInstance();
                DeleteIndex(name);
                break;
            }
            IndexDefinitionStorage.AddIndex(name, definition);
            IndexStorage.CreateIndexImplementation(name, definition);
            TransactionalStorage.Batch(actions => AddIndexAndEnqueueIndexingTasks(actions, name));
            return(name);
        }
예제 #4
0
        public void ResetIndex(string index)
        {
            index = IndexDefinitionStorage.FixupIndexName(index);
            var indexDefinition = IndexDefinitionStorage.GetIndexDefinition(index);

            if (indexDefinition == null)
            {
                throw new InvalidOperationException("There is no index named: " + index);
            }
            IndexStorage.DeleteIndex(index);
            IndexStorage.CreateIndexImplementation(indexDefinition);
            TransactionalStorage.Batch(actions =>
            {
                actions.Indexing.DeleteIndex(index);
                actions.Indexing.AddIndex(index, indexDefinition.IsMapReduce);
                workContext.ShouldNotifyAboutWork();
            });
        }
예제 #5
0
        public string PutIndex(string name, IndexDefinition definition)
        {
            definition.Name = name = IndexDefinitionStorage.FixupIndexName(name);
            switch (IndexDefinitionStorage.FindIndexCreationOptions(definition))
            {
            case IndexCreationOptions.Noop:
                return(name);

            case IndexCreationOptions.Update:
                // ensure that the code can compile
                new DynamicViewCompiler(name, definition, Extensions, IndexDefinitionStorage.IndexDefinitionsPath, Configuration).GenerateInstance();
                DeleteIndex(name);
                break;
            }
            IndexDefinitionStorage.AddIndex(definition);
            IndexStorage.CreateIndexImplementation(definition);
            TransactionalStorage.Batch(actions =>
            {
                actions.Indexing.AddIndex(name, definition.IsMapReduce);
                workContext.ShouldNotifyAboutWork();
            });
            return(name);
        }