protected void Test(Action<PropertyMap<Sample>> setIndexMode, IndexMode expectedIndexMode, Type expectedAnalyzerType = null)
            {
                setIndexMode(map.Property(x => x.Name));
                var mapper = GetMappingInfo("Name");

                Assert.That(mapper.IndexMode, Is.EqualTo(expectedIndexMode));

                Assert.That(mapper.Analyzer, Is.TypeOf(expectedAnalyzerType ?? typeof(CaseInsensitiveKeywordAnalyzer)));
            }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="indexPath">Path where you wish to create the index</param>
        /// <param name="mode">One of Create, Append or Search</param>
        public Indexer(string indexPath, IndexMode mode)
        {
            m_indexMode = mode;
            m_bSucess = false;
            m_analyzer = new StandardAnalyzer();

            if (mode == IndexMode.CREATE)
            {
                try
                {
                    m_indexWriter = new IndexWriter(indexPath, m_analyzer, true);
                    m_indexWriter.SetUseCompoundFile(true);
                    m_bSucess = true;
                }
                catch (Exception e)
                {
                    Logger.Instance.LogException(e);
                    m_bSucess = false;
                }
            }
            else if (mode == IndexMode.APPEND)
            {
                try
                {
                    m_indexWriter = new IndexWriter(indexPath, m_analyzer, false);
                    m_indexWriter.SetUseCompoundFile(true);
                    m_bSucess = true;
                }
                catch (Exception e)
                {
                    Logger.Instance.LogException(e);
                    m_bSucess = false;
                }
            }
            else if (mode == IndexMode.SEARCH)
            {
                try
                {
                    m_indexSearcher = new IndexSearcher(indexPath);
                    m_bSucess = true;
                }
                catch (Exception e)
                {
                    Logger.Instance.LogException(e);
                    m_bSucess = false;
                }
            }
        }
Example #3
0
        public Field(string name, DataType dataType, int dataLength, bool store, Index indexType, IndexMode mode, string analyzerName)
        {
            _Name         = name;
            _DataType     = dataType;
            _DataLength   = dataLength;
            _Store        = store;
            _AnalyzerName = analyzerName;
            _IndexMode    = mode;

            switch (indexType)
            {
            case Index.None:
                break;

            case Index.Tokenized:
                _IndexType = (DataType >= DataType.Varchar && DataType <= DataType.NChar) ? Index.Tokenized : Index.None;
                break;

            case Index.Untokenized:
                _IndexType = DataType == DataType.Data ? Index.None : Index.Untokenized;
                break;
            }
        }
Example #4
0
 public Field(string name, DataType dataType, bool store, Index indexType, IndexMode mode, string analyzerName) :
     this(name, dataType, 0, store, indexType, mode, analyzerName)
 {
 }
Example #5
0
 /// <param name="indexMode">How the field should be indexed for searching and sorting.</param>
 public FieldAttribute(IndexMode indexMode)
     : this(null, indexMode)
 {
 }
 public static extern UInt32 SigGenFrequencyToPhase(
     short handle,
     double frequency,
     IndexMode indexMode,
     uint bufferLength,
     ref uint phase);
 /// <param name="indexMode">How the field should be indexed for searching and sorting.</param>
 public FieldAttribute(IndexMode indexMode)
     : this(null, indexMode)
 {
 }
Example #8
0
 /// <summary>
 /// 索引前需要重新初始化
 /// </summary>
 public Index(FileFinder _form, IndexMode type)
 {
     this.form      = _form;
     this.indexType = type;
 }
Example #9
0
 public void Register(CommandLine commandLine, CommandQueue commandQueue)
 {
     commandLine
     .AddHandler("-print-files", (e) =>
     {
         string group = DEFAULT_GROUP;
         if (e.MoveNext())
         {
             group = (string)e.Current;
         }
         else
         {
             commandLine.NoMoreArg = true;
         }
         commandQueue.Add(() =>
         {
             var fi = file.GetFiles(group);
             foreach (var entry in fi.OrderBy(x => x.Fid))
             {
                 Console.WriteLine("[{0}] {1}", entry.Fid, entry.Path);
             }
         });
     })
     .AddHandler("-print-file-stats", (e) =>
     {
         string group = DEFAULT_GROUP;
         if (e.MoveNext())
         {
             group = (string)e.Current;
         }
         else
         {
             commandLine.NoMoreArg = true;
         }
         commandQueue.Add(() =>
         {
             var stats = file.GetFileStats(group);
             Console.WriteLine("{0}", stats);
         });
     })
     .AddHandler("-print-file", (e) =>
     {
         if (!e.MoveNext())
         {
             throw new Exception("Group name is not specified.");
         }
         var group = (string)e.Current;
         if (!e.MoveNext())
         {
             throw new Exception("Path is not specified.");
         }
         var path = (string)e.Current;
         commandQueue.Add(() =>
         {
             var info     = file.GetFile(group, path);
             var contents = FileContents.Find(info.Fid);
             if (contents == null)
             {
                 contents = file.DownloadFile(info.Fid);
             }
             foreach (var line in contents.Lines)
             {
                 Console.WriteLine(line);
             }
         });
     })
     .AddHandler("-index-files", (e) =>
     {
         var forceIndexing = false;
         var commandLine2  = new CommandLine();
         commandLine2
         .AddHandler("-force", (ee) =>
         {
             forceIndexing = true;
         })
         .AddHandler("-concurrency", (ee) =>
         {
             if (!e.MoveNext())
             {
                 throw new Exception("Concurrency level number is not specified.");
             }
             concurrencyLevel = int.Parse((string)ee.Current);
             if (concurrencyLevel < 1 || 255 < concurrencyLevel)
             {
                 throw new Exception("Concurrency level number is out of the valid range.");
             }
         })
         .AddHandler("-immediate", (ee) =>
         {
             indexMode = IndexMode.Immediate;
         })
         .AddTranslation("-f", "-force")
         .AddTranslation("-c", "-concurrency")
         .AddTranslation("-i", "-immediate");
         e = commandLine2.Parse(e);
         if (e == null)
         {
             throw new Exception("Group name is not specified.");
         }
         var group = (string)e.Current;
         if (!e.MoveNext())
         {
             throw new Exception("Path is not specified.");
         }
         List <string> paths = new List <string>()
         {
             (string)e.Current
         };
         while (e.MoveNext())
         {
             paths.Add((string)e.Current);
         }
         commandLine.NoMoreArg = true;
         commandQueue.Add(() =>
         {
             IndexFiles(group, paths, forceIndexing);
         });
     })
     .AddHandler("-delete-files", (e) =>
     {
         string group = DEFAULT_GROUP;
         if (e.MoveNext())
         {
             group = (string)e.Current;
         }
         else
         {
             commandLine.NoMoreArg = true;
         }
         commandQueue.Add(() =>
         {
             Console.WriteLine("Started deleting files...");
             var t1 = DateTime.Now;
             file.DeleteFiles(group);
             var t2 = DateTime.Now;
             Console.WriteLine("Done. Elapsed time: {0}", t2 - t1);
         });
     })
     .AddHandler("-delete-stale-files", (e) =>
     {
         string group = DEFAULT_GROUP;
         if (e.MoveNext())
         {
             group = (string)e.Current;
         }
         else
         {
             commandLine.NoMoreArg = true;
         }
         commandQueue.Add(() =>
         {
             Console.WriteLine("Started deleting stale files...");
             var t1 = DateTime.Now;
             file.DeleteStaleFiles(group);
             var t2 = DateTime.Now;
             Console.WriteLine("Done. Elapsed time: {0}", t2 - t1);
         });
     })
     .AddTranslation("-pf", "-print-files")
     .AddTranslation("-pfs", "-print-file-stats")
     .AddTranslation("-i", "-index-files")
     .AddTranslation("-index", "-index-files")
     .AddUsageHeader("Usage <file>:")
     .AddUsage("{0} -print-files [GROUPNAME]", Program.Name)
     .AddUsage("{0} -print-file-stats [GROUPNAME]", Program.Name)
     .AddUsage("{0} -print-file GROUPNAME PATH", Program.Name)
     .AddUsage("{0} -index-files [-force] [-concurrency NUMBER] [-immediate] GROUPNAME PATH...", Program.Name)
     .AddUsage("{0} -delete-files [GROUPNAME]", Program.Name)
     .AddUsage("{0} -delete-stale-files [GROUPNAME]", Program.Name);
 }
Example #10
0
        /// <summary>
        /// 开始索引,根据传入的索引类型设置索引,并设置相关属性。
        /// </summary>
        /// <param name="type">索引模式</param>
        private void StartIndex(IndexMode mode)
        {
            //在开始索引前判断搜索是否结束,保存结果是否结束,如果未结束,尝试关闭线程。
            if (this.isSearch == true)
            {
                try
                {
                    this.threadSearch.Abort();
                    this.threadSearch.Join(500);
                    this.isSearch = false;
                }
                catch
                { }
            }

            //如果搜索器不为空就先关闭搜索器
            if (this.search.IsSearcherNull == false)
            {
                this.search.CloseSearcher();
            }

            this.btnUpdate.Visible = true;
            this.isIndex = true;
            this.orginalStatusText = "正在扫描";
            this.tsslStatus.Text = Deal.LimitStringLength(this.orginalStatusText, this.tsslLength);
            this.保存结果ToolStripMenuItem.Enabled = false;
            this.索引ToolStripMenuItem.Enabled = false;
            this.停止更新ToolStripMenuItem.Enabled = true;
            this.index = new Index(this, mode);
            //this.index.Reset(mode);
            Thread thread;
            switch (mode)
            {
                case IndexMode.MP3:
                    {
                        index.MP3ScanPath = Static.MP3IndexPath;
                        thread = new Thread(new ThreadStart(index.StartIndexMP3));
                        break;
                    }
                case IndexMode.File:
                    {
                        index.FileScanPath = Static.FileIndexPath;
                        thread = new Thread(new ThreadStart(index.StartIndexFile));
                        break;
                    }
                default:
                    {
                        index.FileScanPath = Static.FileIndexPath;
                        index.MP3ScanPath = Static.MP3IndexPath;
                        thread = new Thread(new ThreadStart(index.StartIndexAll));
                        break;
                    }
            }

            thread.Start();
            this.tmrIndexStatus.Enabled = true;//启动定时器,定时显示正在扫描的文件夹。
        }
Example #11
0
        /// <summary>
        /// 初始化设置
        /// </summary>
        private void InitSettings()
        {
            //初始化设置信息
            Static.Settings.ReadSettings();
            Static.FileIndexPath = Static.Settings.FileIndexPath;
            Static.MP3IndexPath = Static.Settings.MP3IndexPath;
            IndexInfoDB indexInfo = new IndexInfoDB();
            indexInfo.ReadIndexInfoDB();
            Static.MP3Artist = indexInfo.MP3Artist;
            Static.MP3SongNums = indexInfo.MFileNums;

            this.停止更新ToolStripMenuItem.Enabled = false;
            this.保存结果ToolStripMenuItem.Enabled = false;
            this.tsslLength = this.statusStrip.Width - 120;
            this.orginalStatusText = "永远别说永远,凡事都有可能。";
            this.tsslStatus.Text = Deal.LimitStringLength(this.orginalStatusText, this.tsslLength);

            this.modeStatus = ModeStatus.FILE;
            this.magicMirrorStatus = MagicMirrorStatus.Close;
            this.lvStatus = ListViewStatus.File;

            this.isSearchWithResult = false;
            this.indexMode = IndexMode.All;//默认索引模式为所有
            this.searchMode = SearchMode.File;//默认搜索模式为文件
            //this.index = new Index(this, this.indexMode);
            this.search = new Search(this, this.searchMode);
            this.magicMirror = new MagicMirror();
            this.magicMirror.SetProperties(MagicMode.None, null);
            this.pnlMagicMirror.Controls.Add(this.magicMirror);
            this.magicMirror.Dock = DockStyle.Fill;

            this.btnNext.Visible = false;
            this.btnPrevious.Visible = false;
            this.tsslPages.Visible = false;

            //加入文件夹图标,未知文件的图标,mp3图标,jpg图标。
            this.imgIcon.Images.Add("f", GetSystemIcon.GetFolderIcon(false));
            this.imgIcon.Images.Add("u", GetSystemIcon.GetUnknownFileIcon(false));
            this.imgIcon.Images.Add(".mp3", GetSystemIcon.GetIconByFileType(".mp3", false));
            this.imgIcon.Images.Add(".jpg", GetSystemIcon.GetIconByFileType(".jpg", false));
            this.imgIcon.Images.Add(".txt", GetSystemIcon.GetIconByFileType(".txt", false));
            this.imgIcon.Images.Add("artist", Properties.Resources.artist);
        }
Example #12
0
 public void AddIndex(string name, ClusterMode cluster, IndexMode mode, IndexType type, params object[] columns)
 {
     Index index = new Index(name, cluster, mode, type, columns);
     AddIndex(index);
 }
Example #13
0
 /// <summary>
 /// Specify IndexMode slightly less fluently.
 /// </summary>
 public PropertyMap <T> IndexMode(IndexMode mode)
 {
     this.indexMode = mode;
     return(this);
 }
Example #14
0
        public static IEnumerator Load(IndexMode mode, string tileUrl, Action <Unity3DTileIndex> success,
                                       Action <IndexMode, string, string> fail)
        {
            if (mode == IndexMode.Default || mode == IndexMode.None)
            {
                success(null);
                yield break;
            }

            string url  = UrlUtils.ReplaceDataProtocol(tileUrl);
            string dir  = UrlUtils.GetBaseUri(tileUrl);
            string file = UrlUtils.GetLastPathSegment(tileUrl);

            var filesToTry = new Queue <string>();

            if (mode == IndexMode.ExternalPNG)
            {
                filesToTry.Enqueue(UrlUtils.StripUrlExtension(file) + "_index.png");
                filesToTry.Enqueue(UrlUtils.ChangeUrlExtension(file, ".png"));
            }
            else if (mode == IndexMode.ExternalPPM)
            {
                filesToTry.Enqueue(UrlUtils.StripUrlExtension(file) + "_index.ppm");
                filesToTry.Enqueue(UrlUtils.ChangeUrlExtension(file, ".ppm"));
            }
            else if (mode == IndexMode.ExternalPPMZ)
            {
                filesToTry.Enqueue(UrlUtils.StripUrlExtension(file) + "_index.ppmz");
                filesToTry.Enqueue(UrlUtils.ChangeUrlExtension(file, ".ppmz"));
            }
            else
            {
                filesToTry.Enqueue(file);
            }

            Stream    stream    = null;
            Exception exception = null;
            string    ext       = null;

            while (stream == null && filesToTry.Count > 0)
            {
                exception = null;
                IEnumerator enumerator = null;
                ILoader     loader     = null;
                try
                {
                    file   = filesToTry.Dequeue();
                    ext    = UrlUtils.GetUrlExtension(file).ToLower();
                    loader = AbstractWebRequestLoader.CreateDefaultRequestLoader(dir);
                    if (ext == ".b3dm")
                    {
                        loader = new B3DMLoader(loader);
                    }
                    //yield return loader.LoadStream(file); //works but can't catch exceptions
                    enumerator = loader.LoadStream(file);
                }
                catch (Exception ex)
                {
                    exception = ex;
                }
                while (exception == null)
                {
                    try
                    {
                        if (!enumerator.MoveNext())
                        {
                            break;
                        }
                    }
                    catch (Exception ex)
                    {
                        exception = ex;
                        break;
                    }
                    yield return(enumerator.Current);
                }

                if (exception == null && loader.LoadedStream != null && loader.LoadedStream.Length > 0)
                {
                    stream = loader.LoadedStream;
                    stream.Seek(0, SeekOrigin.Begin);
                }
            }

            if (stream == null || stream.Length == 0)
            {
                fail(mode, tileUrl, "download failed" + (exception != null ? (" " + exception.Message) : ""));
                yield break;
            }

            try
            {
                if (ext == ".b3dm" || ext == ".glb")
                {
                    success(LoadFromGLB(stream));
                }
                else if (ext == ".gltf")
                {
                    success(LoadFromGLTF(stream));
                }
                else if (ext == ".png")
                {
                    success(LoadFromPNG(stream));
                }
                else if (ext == ".ppm" || ext == ".ppmz")
                {
                    success(LoadFromPPM(stream, compressed: ext == ".ppmz"));
                }
                else
                {
                    fail(mode, tileUrl, "unhandled file type: " + ext);
                }
            }
            catch (Exception ex)
            {
                fail(mode, tileUrl, "failed to parse " + file + ": " + ex.Message + "\n" + ex.StackTrace);
            }
        }
        public IStructureTypeConfigurator UsingIndexMode(IndexMode mode)
        {
            _indexMode = mode;

            return(this);
        }
Example #16
0
        /// <summary>
        /// Use kmeans to group markers
        /// </summary>
        /// <param name="markerLocations">marker set</param>
        /// <param name="count">row or col count</param>
        /// <param name="mode">ByRow or ByCol</param>
        /// <returns></returns>
        public static Point[][] indexMarker(List <Point> markerLocations, int count, IndexMode mode)
        {
            Point[][] markerIndices;
            Mat       ptsMat = new Mat();

            foreach (Point p in markerLocations)
            {
                Mat t = new Mat(1, 1, Emgu.CV.CvEnum.DepthType.Cv32F, 1);
                if (mode == IndexMode.ByRow)
                {
                    t.SetTo <float>(new float[] { p.Y });
                }
                else if (mode == IndexMode.ByCol)
                {
                    t.SetTo <float>(new float[] { p.X });
                }
                ptsMat.PushBack(t);
            }
            Mat centerMat = new Mat(), labelMat = new Mat();

            CvInvoke.Kmeans(ptsMat, count, labelMat, new MCvTermCriteria(100, 0.01), 10, Emgu.CV.CvEnum.KMeansInitType.PPCenters, centerMat);
            Image <Gray, int> labelImg = labelMat.ToImage <Gray, int>();

            markerIndices = new Point[count][];
            for (int i = 0; i < count; i++)
            {
                List <Point> tempList = new List <Point>();
                for (int p = 0; p < labelMat.Rows; p++)
                {
                    if (i == (int)(labelImg[p, 0].Intensity))
                    {
                        tempList.Add(markerLocations[p]);
                    }
                }
                markerIndices[i] = tempList.ToArray();
            }
            Array.Sort(markerIndices, (Point[] ps1, Point[] ps2) =>
            {
                if (mode == IndexMode.ByRow)
                {
                    return(ps1[0].Y - ps2[0].Y);
                }
                else if (mode == IndexMode.ByCol)
                {
                    return(ps1[0].X - ps2[0].X);
                }
                return(0);
            });


            for (int i = 0; i < markerIndices.Length; i++)
            {
                Array.Sort(markerIndices[i], (Point p1, Point p2) =>
                {
                    if (mode == IndexMode.ByRow)
                    {
                        return(p1.X - p2.X);
                    }
                    else if (mode == IndexMode.ByCol)
                    {
                        return(p1.Y - p2.Y);
                    }
                    return(0);
                });
            }
            return(markerIndices);
        }
 public ReflectionFieldMapper(PropertyInfo propertyInfo, StoreMode store, IndexMode index, TermVectorMode termVector, TypeConverter converter, string fieldName, bool caseSensitive, Analyzer analyzer, float boost)
     : this(propertyInfo, store, index, termVector, converter, fieldName, QueryParser.Operator.OR, caseSensitive, analyzer, boost)
 {
 }
Example #18
0
        private Thread threadGetMP3Tag; //获取MP3TAG数据的线程

        #endregion Fields

        #region Constructors

        /// <summary>
        /// 索引前需要重新初始化
        /// </summary>
        public Index(FileFinder _form, IndexMode type)
        {
            this.form = _form;
            this.indexType = type;
        }
Example #19
0
 public static extern uint SigGenFrequencyToPhase(
     short handle,
     double frequency,
     IndexMode indexMode,
     uint bufferlength,
     out uint phase);
Example #20
0
        /// <summary>
        /// 重置索引器
        /// </summary>
        public void Reset(IndexMode _type)
        {
            this.indexType = _type;

            this.currentDirectory = "";

            this.scanDirectoryStack.Clear();
            this.findFileDataQueue.Clear();
            this.fileDataQueue.Clear();

            this.mp3DirectoryStack.Clear();
            this.mp3FileQueue.Clear();
            this.mp3TagQueue.Clear();

            this.mp3Artist.Clear();
            this.mp3Directorys.Clear();

            this.fileScanPath.Clear();
            this.mp3ScanPath.Clear();

            this.isScanFileEnd = false;
            this.isDealDataEnd = false;

            this.isScanMP3End = false;
            this.isGetMP3TagEnd = false;

            this.isStopIndexFile = false;
            this.isStopIndexMP3 = false;

            this.isIndexFileComplete = false;
            this.isIndexMP3Complete = false;

            this.fileCounter = 0;
            this.folderCounter = 0;
            this.mp3FileCounter = 0;
            this.mp3FolderCounter = 0;
        }
Example #21
0
 public ReflectionFieldMapper(PropertyInfo propertyInfo, StoreMode store, IndexMode index, TermVectorMode termVector,
                              TypeConverter converter, string fieldName, bool caseSensitive, Analyzer analyzer)
     : this(propertyInfo, store, index, termVector, converter, fieldName, caseSensitive, analyzer, 1f)
 {
 }
Example #22
0
 /// <param name="field">Backing field used to store data in Lucene index.</param>
 /// <param name="indexMode">How the field should be indexed for searching and sorting.</param>
 public FieldAttribute(string field, IndexMode indexMode)
     : base(field)
 {
     this.indexMode = indexMode;
 }
 /// <param name="field">Backing field used to store data in Lucene index.</param>
 /// <param name="indexMode">How the field should be indexed for searching and sorting.</param>
 public FieldAttribute(string field, IndexMode indexMode)
     : base(field)
 {
     this.indexMode = indexMode;
 }
Example #24
0
 public void AddIndex(string Name, ClusterMode Cluster, IndexMode Mode, IndexType Type, params object[] Columns)
 {
     Index index = new Index(Name, Cluster, Mode, Type, Columns);
     AddIndex(index);
 }