Example #1
0
            public void Run(System.Object state)
            {
                System.Random   rand       = new Random(seed);
                System.String[] myInterned = new System.String[Enclosing_Instance.testStrings.Length];
                for (int j = 0; j < iter; j++)
                {
                    int           idx = rand.Next(Enclosing_Instance.testStrings.Length);
                    System.String s   = Enclosing_Instance.testStrings[idx];
                    if (newStrings == true && (new System.Random().NextDouble()) > 0.5)
                    {
                        s = new System.Text.StringBuilder(s).ToString();                         // make a copy half of the time
                    }
                    System.String interned      = StringHelper.Intern(s);
                    System.String prevInterned  = myInterned[idx];
                    System.String otherInterned = Enclosing_Instance.internedStrings[idx];

                    // test against other threads
                    Assert.IsFalse(otherInterned != null && otherInterned != interned);
                    Enclosing_Instance.internedStrings[idx] = interned;

                    // test against local copy
                    Assert.IsFalse(prevInterned != null && prevInterned != interned);
                    myInterned[idx] = interned;
                }
                this.Reset.Set();
            }
Example #2
0
            protected internal override string[] CreateValue(IndexReader reader, Entry entryKey, IState state)
            {
                System.String   field    = StringHelper.Intern(entryKey.field);
                System.String[] retArray = new System.String[reader.MaxDoc];
                TermDocs        termDocs = reader.TermDocs(state);
                TermEnum        termEnum = reader.Terms(new Term(field), state);

                try
                {
                    do
                    {
                        Term term = termEnum.Term;
                        if (term == null || (System.Object)term.Field != (System.Object)field)
                        {
                            break;
                        }
                        System.String termval = term.Text;
                        termDocs.Seek(termEnum, state);
                        while (termDocs.Next(state))
                        {
                            retArray[termDocs.Doc] = termval;
                        }
                    }while (termEnum.Next(state));
                }
                finally
                {
                    termDocs.Close();
                    termEnum.Close();
                }
                return(retArray);
            }
Example #3
0
            public FieldForMerge(System.Object value_Renamed, FieldInfo fi, bool binary, bool compressed, bool tokenize)
            {
                this.isStored     = true;
                this.fieldsData   = value_Renamed;
                this.isCompressed = compressed;
                this.isBinary     = binary;
                if (binary)
                {
                    binaryLength = ((byte[])value_Renamed).Length;
                }

                this.isTokenized = tokenize;

                this.name      = StringHelper.Intern(fi.name);
                this.isIndexed = fi.isIndexed;
                this.omitNorms = fi.omitNorms;
                this.omitTermFreqAndPositions    = fi.omitTermFreqAndPositions;
                this.storeOffsetWithTermVector   = fi.storeOffsetWithTermVector;
                this.storePositionWithTermVector = fi.storePositionWithTermVector;
                this.storeTermVector             = fi.storeTermVector;
            }
Example #4
0
            protected internal override StringIndex CreateValue(IndexReader reader, Entry entryKey, IState state)
            {
                System.String field           = StringHelper.Intern(entryKey.field);
                int[]         retArray        = new int[reader.MaxDoc];
                int[]         retArrayOrdered = new int[reader.MaxDoc];
                for (int i = 0; i < retArrayOrdered.Length; i++)
                {
                    retArrayOrdered[i] = -1;
                }

                var length = reader.MaxDoc + 1;
                UnmanagedStringArray mterms   = new UnmanagedStringArray(length);
                TermDocs             termDocs = reader.TermDocs(state);

                SegmentTermEnum termEnum = (SegmentTermEnum)reader.Terms(new Term(field), state);
                int             t        = 0; // current term number
                int             docIndex = 0;

                // an entry for documents that have no terms in this field
                // should a document with no terms be at top or bottom?
                // this puts them at the top - if it is changed, FieldDocSortedHitQueue
                // needs to change as well.
                t++;

                try
                {
                    do
                    {
                        if (termEnum.termBuffer.Field != field || t >= length)
                        {
                            break;
                        }

                        // store term text
                        mterms.Add(termEnum.termBuffer.TextAsSpan);

                        termDocs.Seek(termEnum, state);
                        while (termDocs.Next(state))
                        {
                            var pt = retArray[termDocs.Doc];
                            retArray[termDocs.Doc] = t;

                            if (pt == 0)
                            {
                                retArrayOrdered[docIndex++] = termDocs.Doc;
                            }
                        }

                        t++;
                    }while (termEnum.Next(state));
                }
                finally
                {
                    termDocs.Close();
                    termEnum.Close();
                }

                StringIndex value_Renamed = new StringIndex(retArray, retArrayOrdered, mterms);

                return(value_Renamed);
            }
Example #5
0
            internal System.Object custom; // which custom comparator or parser

            /// <summary>Creates one of these objects for a custom comparator/parser. </summary>
            internal Entry(System.String field, System.Object custom)
            {
                this.field  = StringHelper.Intern(field);
                this.custom = custom;
            }