コード例 #1
0
 public EnumFieldSource(string field, FieldCache.IIntParser parser, IDictionary<int?, string> enumIntToStringMap, IDictionary<string, int?> enumStringToIntMap)
     : base(field)
 {
     this.parser = parser;
     this.enumIntToStringMap = enumIntToStringMap;
     this.enumStringToIntMap = enumStringToIntMap;
 }
コード例 #2
0
 public FloatDocValuesAnonymousInnerClassHelper(FloatFieldSource outerInstance, FloatFieldSource @this, FieldCache.Floats arr, Bits valid)
     : base(@this)
 {
     this.outerInstance = outerInstance;
     this.arr = arr;
     this.valid = valid;
 }
コード例 #3
0
 public DoubleDocValuesAnonymousInnerClassHelper(DoubleFieldSource outerInstance, DoubleFieldSource @this, FieldCache.Doubles arr, Bits valid)
     : base(@this)
 {
     this.outerInstance = outerInstance;
     this.arr = arr;
     this.valid = valid;
 }
コード例 #4
0
ファイル: TestFieldCache.cs プロジェクト: mundher/lucene.net
        public virtual void  Test()
        {
            FieldCache cache = Lucene.Net.Search.FieldCache_Fields.DEFAULT;

            double[] doubles = cache.GetDoubles(reader, "theDouble");
            Assert.AreSame(doubles, cache.GetDoubles(reader, "theDouble"), "Second request to cache return same array");
            Assert.AreSame(doubles, cache.GetDoubles(reader, "theDouble", Lucene.Net.Search.FieldCache_Fields.DEFAULT_DOUBLE_PARSER), "Second request with explicit parser return same array");
            Assert.IsTrue(doubles.Length == NUM_DOCS, "doubles Size: " + doubles.Length + " is not: " + NUM_DOCS);
            for (int i = 0; i < doubles.Length; i++)
            {
                Assert.IsTrue(doubles[i] == (System.Double.MaxValue - i), doubles[i] + " does not equal: " + (System.Double.MaxValue - i));
            }

            long[] longs = cache.GetLongs(reader, "theLong");
            Assert.AreSame(longs, cache.GetLongs(reader, "theLong"), "Second request to cache return same array");
            Assert.AreSame(longs, cache.GetLongs(reader, "theLong", Lucene.Net.Search.FieldCache_Fields.DEFAULT_LONG_PARSER), "Second request with explicit parser return same array");
            Assert.IsTrue(longs.Length == NUM_DOCS, "longs Size: " + longs.Length + " is not: " + NUM_DOCS);
            for (int i = 0; i < longs.Length; i++)
            {
                Assert.IsTrue(longs[i] == (System.Int64.MaxValue - i), longs[i] + " does not equal: " + (System.Int64.MaxValue - i));
            }

            sbyte[] bytes = cache.GetBytes(reader, "theByte");
            Assert.AreSame(bytes, cache.GetBytes(reader, "theByte"), "Second request to cache return same array");
            Assert.AreSame(bytes, cache.GetBytes(reader, "theByte", Lucene.Net.Search.FieldCache_Fields.DEFAULT_BYTE_PARSER), "Second request with explicit parser return same array");
            Assert.IsTrue(bytes.Length == NUM_DOCS, "bytes Size: " + bytes.Length + " is not: " + NUM_DOCS);
            for (int i = 0; i < bytes.Length; i++)
            {
                Assert.IsTrue(bytes[i] == (sbyte)((byte)System.SByte.MaxValue - i), bytes[i] + " does not equal: " + ((byte)System.SByte.MaxValue - i));
            }

            short[] shorts = cache.GetShorts(reader, "theShort");
            Assert.AreSame(shorts, cache.GetShorts(reader, "theShort"), "Second request to cache return same array");
            Assert.AreSame(shorts, cache.GetShorts(reader, "theShort", Lucene.Net.Search.FieldCache_Fields.DEFAULT_SHORT_PARSER), "Second request with explicit parser return same array");
            Assert.IsTrue(shorts.Length == NUM_DOCS, "shorts Size: " + shorts.Length + " is not: " + NUM_DOCS);
            for (int i = 0; i < shorts.Length; i++)
            {
                Assert.IsTrue(shorts[i] == (short)(System.Int16.MaxValue - i), shorts[i] + " does not equal: " + (System.Int16.MaxValue - i));
            }

            int[] ints = cache.GetInts(reader, "theInt");
            Assert.AreSame(ints, cache.GetInts(reader, "theInt"), "Second request to cache return same array");
            Assert.AreSame(ints, cache.GetInts(reader, "theInt", Lucene.Net.Search.FieldCache_Fields.DEFAULT_INT_PARSER), "Second request with explicit parser return same array");
            Assert.IsTrue(ints.Length == NUM_DOCS, "ints Size: " + ints.Length + " is not: " + NUM_DOCS);
            for (int i = 0; i < ints.Length; i++)
            {
                Assert.IsTrue(ints[i] == (System.Int32.MaxValue - i), ints[i] + " does not equal: " + (System.Int32.MaxValue - i));
            }

            float[] floats = cache.GetFloats(reader, "theFloat");
            Assert.AreSame(floats, cache.GetFloats(reader, "theFloat"), "Second request to cache return same array");
            Assert.AreSame(floats, cache.GetFloats(reader, "theFloat", Lucene.Net.Search.FieldCache_Fields.DEFAULT_FLOAT_PARSER), "Second request with explicit parser return same array");
            Assert.IsTrue(floats.Length == NUM_DOCS, "floats Size: " + floats.Length + " is not: " + NUM_DOCS);
            for (int i = 0; i < floats.Length; i++)
            {
                Assert.IsTrue(floats[i] == (System.Single.MaxValue - i), floats[i] + " does not equal: " + (System.Single.MaxValue - i));
            }
        }
コード例 #5
0
        public virtual void TestDocsWithField()
        {
            FieldCache cache = FieldCache_Fields.DEFAULT;

            cache.PurgeAllCaches();
            Assert.AreEqual(0, cache.CacheEntries.Length);
            cache.GetDoubles(Reader, "theDouble", true);

            // The double[] takes two slots (one w/ null parser, one
            // w/ real parser), and docsWithField should also
            // have been populated:
            Assert.AreEqual(3, cache.CacheEntries.Length);
            Bits bits = cache.GetDocsWithField(Reader, "theDouble");

            // No new entries should appear:
            Assert.AreEqual(3, cache.CacheEntries.Length);
            Assert.IsTrue(bits is Bits_MatchAllBits);

            Ints ints = cache.GetInts(Reader, "sparse", true);

            Assert.AreEqual(6, cache.CacheEntries.Length);
            Bits docsWithField = cache.GetDocsWithField(Reader, "sparse");

            Assert.AreEqual(6, cache.CacheEntries.Length);
            for (int i = 0; i < docsWithField.Length(); i++)
            {
                if (i % 2 == 0)
                {
                    Assert.IsTrue(docsWithField.Get(i));
                    Assert.AreEqual(i, ints.Get(i));
                }
                else
                {
                    Assert.IsFalse(docsWithField.Get(i));
                }
            }

            Ints numInts = cache.GetInts(Reader, "numInt", Random().NextBoolean());

            docsWithField = cache.GetDocsWithField(Reader, "numInt");
            for (int i = 0; i < docsWithField.Length(); i++)
            {
                if (i % 2 == 0)
                {
                    Assert.IsTrue(docsWithField.Get(i));
                    Assert.AreEqual(i, numInts.Get(i));
                }
                else
                {
                    Assert.IsFalse(docsWithField.Get(i));
                }
            }
        }
コード例 #6
0
 static FieldCache_Fields()
 {
     DEFAULT                     = new FieldCacheImpl();
     DEFAULT_BYTE_PARSER         = new AnonymousClassByteParser();
     DEFAULT_SHORT_PARSER        = new AnonymousClassShortParser();
     DEFAULT_INT_PARSER          = new AnonymousClassIntParser();
     DEFAULT_FLOAT_PARSER        = new AnonymousClassFloatParser();
     DEFAULT_LONG_PARSER         = new AnonymousClassLongParser();
     DEFAULT_DOUBLE_PARSER       = new AnonymousClassDoubleParser();
     NUMERIC_UTILS_INT_PARSER    = new AnonymousClassIntParser1();
     NUMERIC_UTILS_FLOAT_PARSER  = new AnonymousClassFloatParser1();
     NUMERIC_UTILS_LONG_PARSER   = new AnonymousClassLongParser1();
     NUMERIC_UTILS_DOUBLE_PARSER = new AnonymousClassDoubleParser1();
 }
コード例 #7
0
 public virtual void TestInfoStream()
 {
     try
     {
         FieldCache   cache = FieldCache_Fields.DEFAULT;
         MemoryStream bos   = new MemoryStream(1024);
         cache.InfoStream = new StreamWriter(bos.ToString(), false, IOUtils.CHARSET_UTF_8);
         cache.GetDoubles(Reader, "theDouble", false);
         cache.GetFloats(Reader, "theDouble", false);
         Assert.IsTrue(bos.ToString(/*IOUtils.UTF_8*/).IndexOf("WARNING") != -1);
     }
     finally
     {
         FieldCache_Fields.DEFAULT.PurgeAllCaches();
     }
 }
コード例 #8
0
ファイル: TestFieldCache.cs プロジェクト: ravendb/lucenenet
 public virtual void  TestInfoStream()
 {
     try
     {
         FieldCache             cache  = Lucene.Net.Search.FieldCache_Fields.DEFAULT;
         System.IO.MemoryStream bos    = new System.IO.MemoryStream(1024);
         System.IO.StreamWriter writer = new System.IO.StreamWriter(bos);
         cache.InfoStream = writer;
         double[] doubles = cache.GetDoubles(reader, "theDouble", null);
         float[]  floats  = cache.GetFloats(reader, "theDouble", null);
         writer.Flush();
         bos.Position = 0;
         using (var sr = new StreamReader(bos))
         {
             var result = sr.ReadToEnd();
             Assert.IsTrue(result.IndexOf("WARNING") != -1);
         }
     }
     finally
     {
         Lucene.Net.Search.FieldCache_Fields.DEFAULT.PurgeAllCaches();
     }
 }
コード例 #9
0
ファイル: TestFieldCache.cs プロジェクト: mundher/lucene.net
 public virtual void  TestInfoStream()
 {
     try
     {
         FieldCache             cache  = Lucene.Net.Search.FieldCache_Fields.DEFAULT;
         System.IO.MemoryStream bos    = new System.IO.MemoryStream(1024);
         System.IO.StreamWriter writer = new System.IO.StreamWriter(bos);
         cache.InfoStream = writer;
         double[] doubles = cache.GetDoubles(reader, "theDouble");
         float[]  floats  = cache.GetFloats(reader, "theDouble");
         char[]   tmpChar;
         byte[]   tmpByte;
         writer.Flush();
         tmpByte = bos.GetBuffer();
         tmpChar = new char[bos.Length];
         System.Array.Copy(tmpByte, 0, tmpChar, 0, tmpChar.Length);
         Assert.IsTrue(new System.String(tmpChar).IndexOf("WARNING") != -1);
     }
     finally
     {
         Lucene.Net.Search.FieldCache_Fields.DEFAULT.PurgeAllCaches();
     }
 }
コード例 #10
0
 public LongFieldSource(string field, FieldCache.ILongParser parser)
     : base(field)
 {
     this.parser = parser;
 }
コード例 #11
0
ファイル: FieldCacheImpl.cs プロジェクト: philiphoy/ravendb
 internal StringIndexCache(FieldCache wrapper) : base(wrapper)
 {
 }
コード例 #12
0
 public ShortFieldSource(string field, FieldCache.IShortParser parser)
     : base(field)
 {
     this.parser = parser;
 }
コード例 #13
0
ファイル: FieldCacheImpl.cs プロジェクト: philiphoy/ravendb
 internal IntCache(FieldCache wrapper) : base(wrapper)
 {
 }
コード例 #14
0
ファイル: FieldCacheImpl.cs プロジェクト: philiphoy/ravendb
 internal LongCache(FieldCache wrapper) : base(wrapper)
 {
 }
コード例 #15
0
ファイル: FieldCacheImpl.cs プロジェクト: philiphoy/ravendb
 internal CustomCache(FieldCache wrapper) : base(wrapper)
 {
 }
コード例 #16
0
ファイル: FieldCacheImpl.cs プロジェクト: philiphoy/ravendb
 internal ByteCache(FieldCache wrapper) : base(wrapper)
 {
 }
コード例 #17
0
 /// <summary>
 /// Quick and dirty convenience method </summary>
 /// <seealso cref= #check </seealso>
 public static Insanity[] CheckSanity(FieldCache cache)
 {
     return CheckSanity(cache.CacheEntries);
 }
コード例 #18
0
 static FieldCache_Fields()
 {
     DEFAULT = new FieldCacheImpl();
 }
コード例 #19
0
 public LongDocValuesAnonymousInnerClassHelper(LongFieldSource outerInstance, LongFieldSource @this, FieldCache.Longs arr, Bits valid)
     : base(@this)
 {
     this.outerInstance = outerInstance;
     this.arr = arr;
     this.valid = valid;
 }
コード例 #20
0
 internal CustomCache(FieldCache wrapper)
     : base(wrapper)
 {
 }
コード例 #21
0
        public virtual void TestNonIndexedFields()
        {
            Directory         dir = NewDirectory();
            RandomIndexWriter iw  = new RandomIndexWriter(Random(), dir);
            Document          doc = new Document();

            doc.Add(new StoredField("bogusbytes", "bogus"));
            doc.Add(new StoredField("bogusshorts", "bogus"));
            doc.Add(new StoredField("bogusints", "bogus"));
            doc.Add(new StoredField("boguslongs", "bogus"));
            doc.Add(new StoredField("bogusfloats", "bogus"));
            doc.Add(new StoredField("bogusdoubles", "bogus"));
            doc.Add(new StoredField("bogusterms", "bogus"));
            doc.Add(new StoredField("bogustermsindex", "bogus"));
            doc.Add(new StoredField("bogusmultivalued", "bogus"));
            doc.Add(new StoredField("bogusbits", "bogus"));
            iw.AddDocument(doc);
            DirectoryReader ir = iw.Reader;

            iw.Dispose();

            AtomicReader ar = GetOnlySegmentReader(ir);

            FieldCache cache = FieldCache_Fields.DEFAULT;

            cache.PurgeAllCaches();
            Assert.AreEqual(0, cache.CacheEntries.Length);

            Bytes bytes = cache.GetBytes(ar, "bogusbytes", true);

            Assert.AreEqual(0, bytes.Get(0));

            Shorts shorts = cache.GetShorts(ar, "bogusshorts", true);

            Assert.AreEqual(0, shorts.Get(0));

            Ints ints = cache.GetInts(ar, "bogusints", true);

            Assert.AreEqual(0, ints.Get(0));

            Longs longs = cache.GetLongs(ar, "boguslongs", true);

            Assert.AreEqual(0, longs.Get(0));

            Floats floats = cache.GetFloats(ar, "bogusfloats", true);

            Assert.AreEqual(0, floats.Get(0), 0.0f);

            Doubles doubles = cache.GetDoubles(ar, "bogusdoubles", true);

            Assert.AreEqual(0, doubles.Get(0), 0.0D);

            BytesRef        scratch  = new BytesRef();
            BinaryDocValues binaries = cache.GetTerms(ar, "bogusterms", true);

            binaries.Get(0, scratch);
            Assert.AreEqual(0, scratch.Length);

            SortedDocValues sorted = cache.GetTermsIndex(ar, "bogustermsindex");

            Assert.AreEqual(-1, sorted.GetOrd(0));
            sorted.Get(0, scratch);
            Assert.AreEqual(0, scratch.Length);

            SortedSetDocValues sortedSet = cache.GetDocTermOrds(ar, "bogusmultivalued");

            sortedSet.Document = 0;
            Assert.AreEqual(SortedSetDocValues.NO_MORE_ORDS, sortedSet.NextOrd());

            Bits bits = cache.GetDocsWithField(ar, "bogusbits");

            Assert.IsFalse(bits.Get(0));

            // check that we cached nothing
            Assert.AreEqual(0, cache.CacheEntries.Length);
            ir.Dispose();
            dir.Dispose();
        }
コード例 #22
0
 /// <summary> Forcible purges all cache entries from the FieldCache.
 /// <p/>
 /// This method will be called by tearDown to clean up FieldCache.DEFAULT.
 /// If a (poorly written) test has some expectation that the FieldCache
 /// will persist across test methods (ie: a static IndexReader) this 
 /// method can be overridden to do nothing.
 /// <p/>
 /// </summary>
 /// <seealso cref="FieldCache.PurgeAllCaches()">
 /// </seealso>
 protected internal virtual void PurgeFieldCache(FieldCache fc)
 {
     fc.PurgeAllCaches();
 }
コード例 #23
0
        public virtual void Test()
        {
            FieldCache cache = FieldCache_Fields.DEFAULT;

            FieldCache_Fields.Doubles doubles = cache.GetDoubles(Reader, "theDouble", Random().NextBoolean());
            Assert.AreSame(doubles, cache.GetDoubles(Reader, "theDouble", Random().NextBoolean()), "Second request to cache return same array");
            Assert.AreSame(doubles, cache.GetDoubles(Reader, "theDouble", FieldCache_Fields.DEFAULT_DOUBLE_PARSER, Random().NextBoolean()), "Second request with explicit parser return same array");
            for (int i = 0; i < NUM_DOCS; i++)
            {
                Assert.IsTrue(doubles.Get(i) == (double.MaxValue - i), doubles.Get(i) + " does not equal: " + (double.MaxValue - i));
            }

            FieldCache_Fields.Longs longs = cache.GetLongs(Reader, "theLong", Random().NextBoolean());
            Assert.AreSame(longs, cache.GetLongs(Reader, "theLong", Random().NextBoolean()), "Second request to cache return same array");
            Assert.AreSame(longs, cache.GetLongs(Reader, "theLong", FieldCache_Fields.DEFAULT_LONG_PARSER, Random().NextBoolean()), "Second request with explicit parser return same array");
            for (int i = 0; i < NUM_DOCS; i++)
            {
                Assert.IsTrue(longs.Get(i) == (long.MaxValue - i), longs.Get(i) + " does not equal: " + (long.MaxValue - i) + " i=" + i);
            }

            FieldCache_Fields.Bytes bytes = cache.GetBytes(Reader, "theByte", Random().NextBoolean());
            Assert.AreSame(bytes, cache.GetBytes(Reader, "theByte", Random().NextBoolean()), "Second request to cache return same array");
            Assert.AreSame(bytes, cache.GetBytes(Reader, "theByte", FieldCache_Fields.DEFAULT_BYTE_PARSER, Random().NextBoolean()), "Second request with explicit parser return same array");
            for (int i = 0; i < NUM_DOCS; i++)
            {
                Assert.IsTrue(bytes.Get(i) == (sbyte)(sbyte.MaxValue - i), bytes.Get(i) + " does not equal: " + (sbyte.MaxValue - i));
            }

            FieldCache_Fields.Shorts shorts = cache.GetShorts(Reader, "theShort", Random().NextBoolean());
            Assert.AreSame(shorts, cache.GetShorts(Reader, "theShort", Random().NextBoolean()), "Second request to cache return same array");
            Assert.AreSame(shorts, cache.GetShorts(Reader, "theShort", FieldCache_Fields.DEFAULT_SHORT_PARSER, Random().NextBoolean()), "Second request with explicit parser return same array");
            for (int i = 0; i < NUM_DOCS; i++)
            {
                Assert.IsTrue(shorts.Get(i) == (short)(short.MaxValue - i), shorts.Get(i) + " does not equal: " + (short.MaxValue - i));
            }

            FieldCache_Fields.Ints ints = cache.GetInts(Reader, "theInt", Random().NextBoolean());
            Assert.AreSame(ints, cache.GetInts(Reader, "theInt", Random().NextBoolean()), "Second request to cache return same array");
            Assert.AreSame(ints, cache.GetInts(Reader, "theInt", FieldCache_Fields.DEFAULT_INT_PARSER, Random().NextBoolean()), "Second request with explicit parser return same array");
            for (int i = 0; i < NUM_DOCS; i++)
            {
                Assert.IsTrue(ints.Get(i) == (int.MaxValue - i), ints.Get(i) + " does not equal: " + (int.MaxValue - i));
            }

            FieldCache_Fields.Floats floats = cache.GetFloats(Reader, "theFloat", Random().NextBoolean());
            Assert.AreSame(floats, cache.GetFloats(Reader, "theFloat", Random().NextBoolean()), "Second request to cache return same array");
            Assert.AreSame(floats, cache.GetFloats(Reader, "theFloat", FieldCache_Fields.DEFAULT_FLOAT_PARSER, Random().NextBoolean()), "Second request with explicit parser return same array");
            for (int i = 0; i < NUM_DOCS; i++)
            {
                Assert.IsTrue(floats.Get(i) == (float.MaxValue - i), floats.Get(i) + " does not equal: " + (float.MaxValue - i));
            }

            Bits docsWithField = cache.GetDocsWithField(Reader, "theLong");

            Assert.AreSame(docsWithField, cache.GetDocsWithField(Reader, "theLong"), "Second request to cache return same array");
            Assert.IsTrue(docsWithField is Bits_MatchAllBits, "docsWithField(theLong) must be class Bits.MatchAllBits");
            Assert.IsTrue(docsWithField.Length() == NUM_DOCS, "docsWithField(theLong) Size: " + docsWithField.Length() + " is not: " + NUM_DOCS);
            for (int i = 0; i < docsWithField.Length(); i++)
            {
                Assert.IsTrue(docsWithField.Get(i));
            }

            docsWithField = cache.GetDocsWithField(Reader, "sparse");
            Assert.AreSame(docsWithField, cache.GetDocsWithField(Reader, "sparse"), "Second request to cache return same array");
            Assert.IsFalse(docsWithField is Bits_MatchAllBits, "docsWithField(sparse) must not be class Bits.MatchAllBits");
            Assert.IsTrue(docsWithField.Length() == NUM_DOCS, "docsWithField(sparse) Size: " + docsWithField.Length() + " is not: " + NUM_DOCS);
            for (int i = 0; i < docsWithField.Length(); i++)
            {
                Assert.AreEqual(i % 2 == 0, docsWithField.Get(i));
            }

            // getTermsIndex
            SortedDocValues termsIndex = cache.GetTermsIndex(Reader, "theRandomUnicodeString");

            Assert.AreSame(termsIndex, cache.GetTermsIndex(Reader, "theRandomUnicodeString"), "Second request to cache return same array");
            BytesRef br = new BytesRef();

            for (int i = 0; i < NUM_DOCS; i++)
            {
                BytesRef term;
                int      ord = termsIndex.GetOrd(i);
                if (ord == -1)
                {
                    term = null;
                }
                else
                {
                    termsIndex.LookupOrd(ord, br);
                    term = br;
                }
                string s = term == null ? null : term.Utf8ToString();
                Assert.IsTrue(UnicodeStrings[i] == null || UnicodeStrings[i].Equals(s), "for doc " + i + ": " + s + " does not equal: " + UnicodeStrings[i]);
            }

            int nTerms = termsIndex.ValueCount;

            TermsEnum tenum = termsIndex.TermsEnum();
            BytesRef  val   = new BytesRef();

            for (int i = 0; i < nTerms; i++)
            {
                BytesRef val1 = tenum.Next();
                termsIndex.LookupOrd(i, val);
                // System.out.println("i="+i);
                Assert.AreEqual(val, val1);
            }

            // seek the enum around (note this isn't a great test here)
            int num = AtLeast(100);

            for (int i = 0; i < num; i++)
            {
                int k = Random().Next(nTerms);
                termsIndex.LookupOrd(k, val);
                Assert.AreEqual(TermsEnum.SeekStatus.FOUND, tenum.SeekCeil(val));
                Assert.AreEqual(val, tenum.Term());
            }

            for (int i = 0; i < nTerms; i++)
            {
                termsIndex.LookupOrd(i, val);
                Assert.AreEqual(TermsEnum.SeekStatus.FOUND, tenum.SeekCeil(val));
                Assert.AreEqual(val, tenum.Term());
            }

            // test bad field
            termsIndex = cache.GetTermsIndex(Reader, "bogusfield");

            // getTerms
            BinaryDocValues terms = cache.GetTerms(Reader, "theRandomUnicodeString", true);

            Assert.AreSame(terms, cache.GetTerms(Reader, "theRandomUnicodeString", true), "Second request to cache return same array");
            Bits bits = cache.GetDocsWithField(Reader, "theRandomUnicodeString");

            for (int i = 0; i < NUM_DOCS; i++)
            {
                terms.Get(i, br);
                BytesRef term;
                if (!bits.Get(i))
                {
                    term = null;
                }
                else
                {
                    term = br;
                }
                string s = term == null ? null : term.Utf8ToString();
                Assert.IsTrue(UnicodeStrings[i] == null || UnicodeStrings[i].Equals(s), "for doc " + i + ": " + s + " does not equal: " + UnicodeStrings[i]);
            }

            // test bad field
            terms = cache.GetTerms(Reader, "bogusfield", false);

            // getDocTermOrds
            SortedSetDocValues termOrds = cache.GetDocTermOrds(Reader, "theRandomUnicodeMultiValuedField");
            int numEntries = cache.CacheEntries.Length;

            // ask for it again, and check that we didnt create any additional entries:
            termOrds = cache.GetDocTermOrds(Reader, "theRandomUnicodeMultiValuedField");
            Assert.AreEqual(numEntries, cache.CacheEntries.Length);

            for (int i = 0; i < NUM_DOCS; i++)
            {
                termOrds.Document = i;
                // this will remove identical terms. A DocTermOrds doesn't return duplicate ords for a docId
                IList <BytesRef> values = new List <BytesRef>(new /*Linked*/ HashSet <BytesRef>(Arrays.AsList(MultiValued[i])));
                foreach (BytesRef v in values)
                {
                    if (v == null)
                    {
                        // why does this test use null values... instead of an empty list: confusing
                        break;
                    }
                    long ord = termOrds.NextOrd();
                    Debug.Assert(ord != SortedSetDocValues.NO_MORE_ORDS);
                    BytesRef scratch = new BytesRef();
                    termOrds.LookupOrd(ord, scratch);
                    Assert.AreEqual(v, scratch);
                }
                Assert.AreEqual(SortedSetDocValues.NO_MORE_ORDS, termOrds.NextOrd());
            }

            // test bad field
            termOrds = cache.GetDocTermOrds(Reader, "bogusfield");
            Assert.IsTrue(termOrds.ValueCount == 0);

            FieldCache_Fields.DEFAULT.PurgeByCacheKey(Reader.CoreCacheKey);
        }
コード例 #24
0
ファイル: FieldCache.cs プロジェクト: zweib730/beagrep
		static FieldCache_Fields()
		{
			DEFAULT = new FieldCacheImpl();
		}
コード例 #25
0
 public SimScorerAnonymousInnerClassHelper(BoostingSimilarity outerInstance, SimScorer sub, FieldCache.Floats values)
 {
     this.OuterInstance = outerInstance;
     this.Sub = sub;
     this.Values = values;
 }
コード例 #26
0
 public FloatFieldSource(string field, FieldCache.IFloatParser parser)
     : base(field)
 {
     this.parser = parser;
 }
コード例 #27
0
 public FunctionValuesAnonymousInnerClassHelper(ByteFieldSource outerInstance, FieldCache.Bytes arr)
 {
     this.outerInstance = outerInstance;
     this.arr = arr;
 }
コード例 #28
0
ファイル: FieldCache.cs プロジェクト: Mpdreamz/lucene.net
		static FieldCache_Fields()
		{
			DEFAULT = new FieldCacheImpl();
			DEFAULT_BYTE_PARSER = new AnonymousClassByteParser();
			DEFAULT_SHORT_PARSER = new AnonymousClassShortParser();
			DEFAULT_INT_PARSER = new AnonymousClassIntParser();
			DEFAULT_FLOAT_PARSER = new AnonymousClassFloatParser();
			DEFAULT_LONG_PARSER = new AnonymousClassLongParser();
			DEFAULT_DOUBLE_PARSER = new AnonymousClassDoubleParser();
			NUMERIC_UTILS_INT_PARSER = new AnonymousClassIntParser1();
			NUMERIC_UTILS_FLOAT_PARSER = new AnonymousClassFloatParser1();
			NUMERIC_UTILS_LONG_PARSER = new AnonymousClassLongParser1();
			NUMERIC_UTILS_DOUBLE_PARSER = new AnonymousClassDoubleParser1();
		}
コード例 #29
0
 public ByteFieldSource(string field, FieldCache.IByteParser parser)
     : base(field)
 {
     this.parser = parser;
 }
コード例 #30
0
 public CustomScoreProviderAnonymousInnerClassHelper(CustomExternalQuery outerInstance, AtomicReaderContext context, FieldCache.Ints values)
     : base(context)
 {
     this.outerInstance = outerInstance;
     this.context = context;
     this.values = values;
 }
コード例 #31
0
ファイル: IntFieldSource.cs プロジェクト: Cefa68000/lucenenet
 public IntDocValuesAnonymousInnerClassHelper(IntFieldSource outerInstance, IntFieldSource @this, FieldCache.Ints arr, Bits valid)
     : base(@this)
 {
     this.outerInstance = outerInstance;
     this.arr = arr;
     this.valid = valid;
     val = new MutableValueInt();
 }
コード例 #32
0
ファイル: FieldCacheImpl.cs プロジェクト: philiphoy/ravendb
 internal Cache(FieldCache wrapper)
 {
     this.wrapper = wrapper;
 }
コード例 #33
0
ファイル: FieldCacheImpl.cs プロジェクト: Nangal/lucene.net
 internal Cache(FieldCache wrapper)
 {
     this.wrapper = wrapper;
 }
コード例 #34
0
ファイル: FieldCacheImpl.cs プロジェクト: philiphoy/ravendb
 internal ShortCache(FieldCache wrapper) : base(wrapper)
 {
 }
コード例 #35
0
ファイル: FieldCacheImpl.cs プロジェクト: Nangal/lucene.net
 internal ShortCache(FieldCache wrapper):base(wrapper)
 {
 }
コード例 #36
0
ファイル: FieldCacheImpl.cs プロジェクト: philiphoy/ravendb
 internal FloatCache(FieldCache wrapper) : base(wrapper)
 {
 }
コード例 #37
0
ファイル: FieldCacheImpl.cs プロジェクト: Nangal/lucene.net
 internal FloatCache(FieldCache wrapper):base(wrapper)
 {
 }
コード例 #38
0
ファイル: FieldCacheImpl.cs プロジェクト: philiphoy/ravendb
 internal DoubleCache(FieldCache wrapper) : base(wrapper)
 {
 }
コード例 #39
0
ファイル: FieldCacheImpl.cs プロジェクト: Nangal/lucene.net
 internal DoubleCache(FieldCache wrapper):base(wrapper)
 {
 }
コード例 #40
0
ファイル: FieldCacheImpl.cs プロジェクト: philiphoy/ravendb
 internal AutoCache(FieldCache wrapper) : base(wrapper)
 {
 }
コード例 #41
0
 public DoubleFieldSource(string field, FieldCache.IDoubleParser parser)
     : base(field)
 {
     this.parser = parser;
 }
コード例 #42
0
ファイル: FieldCacheImpl.cs プロジェクト: Nangal/lucene.net
 internal ByteCache(FieldCache wrapper):base(wrapper)
 {
 }
コード例 #43
0
ファイル: SortField.cs プロジェクト: apache/lucenenet
 /// <summary>
 /// Creates a sort by terms in the given field, parsed
 /// to numeric values using a custom <seealso cref="IFieldCache.Parser"/>. </summary>
 /// <param name="field">  Name of field to sort by.  Must not be null. </param>
 /// <param name="parser"> Instance of a <seealso cref="IFieldCache.Parser"/>,
 ///  which must subclass one of the existing numeric
 ///  parsers from <seealso cref="IFieldCache"/>. Sort type is inferred
 ///  by testing which numeric parser the parser subclasses. </param>
 /// <exception cref="IllegalArgumentException"> if the parser fails to
 ///  subclass an existing numeric parser, or field is null </exception>
 public SortField(string field, FieldCache.IParser parser)
     : this(field, parser, false)
 {
 }
コード例 #44
0
ファイル: FieldCacheImpl.cs プロジェクト: Nangal/lucene.net
 internal IntCache(FieldCache wrapper):base(wrapper)
 {
 }
コード例 #45
0
ファイル: SortField.cs プロジェクト: apache/lucenenet
        /// <summary>
        /// Creates a sort, possibly in reverse, by terms in the given field, parsed
        /// to numeric values using a custom <seealso cref="IFieldCache.Parser"/>. </summary>
        /// <param name="field">  Name of field to sort by.  Must not be null. </param>
        /// <param name="parser"> Instance of a <seealso cref="IFieldCache.Parser"/>,
        ///  which must subclass one of the existing numeric
        ///  parsers from <seealso cref="IFieldCache"/>. Sort type is inferred
        ///  by testing which numeric parser the parser subclasses. </param>
        /// <param name="reverse"> True if natural order should be reversed. </param>
        /// <exception cref="IllegalArgumentException"> if the parser fails to
        ///  subclass an existing numeric parser, or field is null </exception>
        public SortField(string field, FieldCache.IParser parser, bool reverse)
        {
            if (parser is FieldCache.IIntParser)
            {
                InitFieldType(field, Type_e.INT);
            }
            else if (parser is FieldCache.IFloatParser)
            {
                InitFieldType(field, Type_e.FLOAT);
            }
            else if (parser is FieldCache.IShortParser)
            {
                InitFieldType(field, Type_e.SHORT);
            }
            else if (parser is FieldCache.IByteParser)
            {
                InitFieldType(field, Type_e.BYTE);
            }
            else if (parser is FieldCache.ILongParser)
            {
                InitFieldType(field, Type_e.LONG);
            }
            else if (parser is FieldCache.IDoubleParser)
            {
                InitFieldType(field, Type_e.DOUBLE);
            }
            else
            {
                throw new System.ArgumentException("Parser instance does not subclass existing numeric parser from FieldCache (got " + parser + ")");
            }

            this.reverse = reverse;
            this.parser = parser;
        }
コード例 #46
0
ファイル: FieldCacheImpl.cs プロジェクト: Nangal/lucene.net
 internal LongCache(FieldCache wrapper):base(wrapper)
 {
 }
コード例 #47
0
 internal AutoCache(FieldCache wrapper)
     : base(wrapper)
 {
 }
コード例 #48
0
ファイル: FieldCacheImpl.cs プロジェクト: Nangal/lucene.net
 internal StringIndexCache(FieldCache wrapper):base(wrapper)
 {
 }
コード例 #49
0
 internal Cache()
 {
     this.wrapper = null;
 }