示例#1
0
 public override void SetConfig(Config config, ContentSource source)
 {
     base.SetConfig(config, source);
     if (!spatialStrategyCache.TryGetValue(config.RoundNumber, out SpatialStrategy existing) || existing == null)
     {
         //new round; we need to re-initialize
         strategy = MakeSpatialStrategy(config);
         spatialStrategyCache[config.RoundNumber] = strategy;
         //TODO remove previous round config?
         shapeConverter = MakeShapeConverter(strategy, config, "doc.spatial.");
         Console.WriteLine("Spatial Strategy: " + strategy);
     }
 }
示例#2
0
        /// <summary>Set the configuration parameters of this doc maker.</summary>
        public virtual void SetConfig(Config config, ContentSource source)
        {
            this.m_config = config;
            this.m_source = source;

            bool stored           = config.Get("doc.stored", false);
            bool bodyStored       = config.Get("doc.body.stored", stored);
            bool tokenized        = config.Get("doc.tokenized", true);
            bool bodyTokenized    = config.Get("doc.body.tokenized", tokenized);
            bool norms            = config.Get("doc.tokenized.norms", false);
            bool bodyNorms        = config.Get("doc.body.tokenized.norms", true);
            bool termVec          = config.Get("doc.term.vector", false);
            bool termVecPositions = config.Get("doc.term.vector.positions", false);
            bool termVecOffsets   = config.Get("doc.term.vector.offsets", false);

            m_valType                          = new FieldType(TextField.TYPE_NOT_STORED);
            m_valType.IsStored                 = stored;
            m_valType.IsTokenized              = tokenized;
            m_valType.OmitNorms                = !norms;
            m_valType.StoreTermVectors         = termVec;
            m_valType.StoreTermVectorPositions = termVecPositions;
            m_valType.StoreTermVectorOffsets   = termVecOffsets;
            m_valType.Freeze();

            m_bodyValType                          = new FieldType(TextField.TYPE_NOT_STORED);
            m_bodyValType.IsStored                 = bodyStored;
            m_bodyValType.IsTokenized              = bodyTokenized;
            m_bodyValType.OmitNorms                = !bodyNorms;
            m_bodyValType.StoreTermVectors         = termVec;
            m_bodyValType.StoreTermVectorPositions = termVecPositions;
            m_bodyValType.StoreTermVectorOffsets   = termVecOffsets;
            m_bodyValType.Freeze();

            storeBytes = config.Get("doc.store.body.bytes", false);

            m_reuseFields = config.Get("doc.reuse.fields", true);

            // In a multi-rounds run, it is important to reset DocState since settings
            // of fields may change between rounds, and this is the only way to reset
            // the cache of all threads.
            docState = new ThreadLocal <DocState>();

            m_indexProperties = config.Get("doc.index.props", false);

            updateDocIDLimit = config.Get("doc.random.id.limit", -1);
            if (updateDocIDLimit != -1)
            {
                r = new Random(179);
            }
        }