Esempio n. 1
0
        private static MapReduceIndex CreateIndexInstance(int indexId, IndexDefinition definition)
        {
            var staticIndex = IndexAndTransformerCompilationCache.GetIndexInstance(definition);

            var staticMapIndexDefinition = new MapReduceIndexDefinition(definition, staticIndex.Maps.Keys.ToArray(), staticIndex.OutputFields, staticIndex.GroupByFields, staticIndex.HasDynamicFields);
            var instance = new MapReduceIndex(indexId, staticMapIndexDefinition, staticIndex);

            return(instance);
        }
Esempio n. 2
0
        public static Transformer CreateNew(int transformerId, TransformerDefinition definition,
                                            IndexingConfiguration configuration, Logger log)
        {
            var compiledTransformer = IndexAndTransformerCompilationCache.GetTransformerInstance(definition);
            var transformer         = new Transformer(transformerId, definition, compiledTransformer, log);

            transformer.Initialize(configuration, persist: true);

            return(transformer);
        }
Esempio n. 3
0
        public static Transformer Open(int transformerId, string fullPath, IndexingConfiguration configuration, Logger log)
        {
            if (File.Exists(fullPath) == false)
            {
                throw new InvalidOperationException($"Could not find transformer file at '{fullPath}'.");
            }

            var transformerDefinitionAsText = File.ReadAllText(fullPath);
            var transformerDefinition       = JsonConvert.DeserializeObject <TransformerDefinition>(transformerDefinitionAsText);

            if (transformerDefinition == null)
            {
                throw new InvalidOperationException($"Could not read transformer definition from '{fullPath}'.");
            }

            var compiledTransformer = IndexAndTransformerCompilationCache.GetTransformerInstance(transformerDefinition);
            var transformer         = new Transformer(transformerId, transformerDefinition, compiledTransformer, log);

            transformer.Initialize(configuration, persist: false);

            return(transformer);
        }