public virtual void  TestInsanity2()
        {
            FieldCache cache = Lucene.Net.Search.FieldCache_Fields.DEFAULT;

            cache.PurgeAllCaches();

            System.String[] strings;
            sbyte[]         bytes;

            strings = cache.GetStrings(readerA, "theString");
            strings = cache.GetStrings(readerB, "theString");
            strings = cache.GetStrings(readerX, "theString");

            // this one is ok
            bytes = cache.GetBytes(readerX, "theByte");


            // // //

            Insanity[] insanity = FieldCacheSanityChecker.CheckSanity(cache.GetCacheEntries());

            Assert.AreEqual(1, insanity.Length, "wrong number of cache errors");
            Assert.AreEqual(InsanityType.SUBREADER, insanity[0].GetType(), "wrong type of cache error");
            Assert.AreEqual(3, insanity[0].GetCacheEntries().Length, "wrong number of entries in cache error");

            // we expect bad things, don't let tearDown complain about them
            cache.PurgeAllCaches();
        }
        public virtual void  TestSanity()
        {
            FieldCache cache = Lucene.Net.Search.FieldCache_Fields.DEFAULT;

            cache.PurgeAllCaches();

            double[] doubles;
            int[]    ints;

            doubles = cache.GetDoubles(readerA, "theDouble");
            doubles = cache.GetDoubles(readerA, "theDouble", Lucene.Net.Search.FieldCache_Fields.DEFAULT_DOUBLE_PARSER);
            doubles = cache.GetDoubles(readerB, "theDouble", Lucene.Net.Search.FieldCache_Fields.DEFAULT_DOUBLE_PARSER);

            ints = cache.GetInts(readerX, "theInt");
            ints = cache.GetInts(readerX, "theInt", Lucene.Net.Search.FieldCache_Fields.DEFAULT_INT_PARSER);

            // // //

            Insanity[] insanity = FieldCacheSanityChecker.CheckSanity(cache.GetCacheEntries());

            if (0 < insanity.Length)
            {
                System.IO.StreamWriter temp_writer;
                temp_writer           = new System.IO.StreamWriter(System.Console.OpenStandardError(), System.Console.Error.Encoding);
                temp_writer.AutoFlush = true;
                DumpArray(GetTestLabel() + " INSANITY", insanity, temp_writer);
            }

            Assert.AreEqual(0, insanity.Length, "shouldn't be any cache insanity");
            cache.PurgeAllCaches();
        }
        public virtual void  TestInsanity1()
        {
            FieldCache cache = Lucene.Net.Search.FieldCache_Fields.DEFAULT;

            cache.PurgeAllCaches();

            int[]           ints;
            System.String[] strings;
            sbyte[]         bytes;

            ints    = cache.GetInts(readerX, "theInt", Lucene.Net.Search.FieldCache_Fields.DEFAULT_INT_PARSER);
            strings = cache.GetStrings(readerX, "theInt");

            // this one is ok
            bytes = cache.GetBytes(readerX, "theByte");

            // // //

            Insanity[] insanity = FieldCacheSanityChecker.CheckSanity(cache.GetCacheEntries());

            Assert.AreEqual(1, insanity.Length, "wrong number of cache errors");
            Assert.AreEqual(InsanityType.VALUEMISMATCH, insanity[0].Type, "wrong type of cache error");
            Assert.AreEqual(2, insanity[0].GetCacheEntries().Length, "wrong number of entries in cache error");

            // we expect bad things, don't let tearDown complain about them
            cache.PurgeAllCaches();
        }
Example #4
0
 /// <summary> Return cached DocValues for input field and reader.</summary>
 /// <param name="cache">FieldCache so that values of a field are loaded once per reader (RAM allowing)
 /// </param>
 /// <param name="field">Field for which values are required.
 /// </param>
 /// <seealso cref="ValueSource">
 /// </seealso>
 public abstract DocValues GetCachedFieldValues(FieldCache cache, string field, IndexReader reader);
Example #5
0
 /*(non-Javadoc) <see cref="Lucene.Net.Search.Function.FieldCacheSource.getCachedValues(Lucene.Net.Search.FieldCache, java.lang.String, Lucene.Net.Index.IndexReader) */
 public override DocValues GetCachedFieldValues(FieldCache cache, System.String field, IndexReader reader)
 {
     short[] arr = cache.GetShorts(reader, field, parser);
     return new AnonymousClassDocValues(arr, this);
 }
Example #6
0
 /*(non-Javadoc) @see Lucene.Net.Search.Function.FieldCacheSource#getCachedValues(Lucene.Net.Search.FieldCache, java.lang.String, Lucene.Net.Index.IndexReader) */
 public override DocValues GetCachedFieldValues(FieldCache cache, System.String field, IndexReader reader)
 {
     byte[] arr = (parser == null) ? cache.GetBytes(reader, field) : cache.GetBytes(reader, field, parser);
     return(new AnonymousClassDocValues(arr, this));
 }
 public override DocValues GetCachedFieldValues(FieldCache cache, System.String field, IndexReader reader)
 {
     float[] arr = (parser == null) ? cache.GetFloats(reader, field) : cache.GetFloats(reader, field, parser);
     return new AnonymousClassDocValues(arr, this);
 }
 public override DocValues GetCachedFieldValues(FieldCache cache, System.String field, IndexReader reader, IState state)
 {
     throw new System.NotSupportedException(Lucene.Net.Search.Function.JustCompileSearchFunction.UNSUPPORTED_MSG);
 }
Example #9
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();
 }
Example #10
0
 /// <summary> Return cached DocValues for input field and reader.</summary>
 /// <param name="cache">FieldCache so that values of a field are loaded once per reader (RAM allowing)
 /// </param>
 /// <param name="field">Field for which values are required.
 /// </param>
 /// <seealso cref="ValueSource">
 /// </seealso>
 public abstract DocValues GetCachedFieldValues(FieldCache cache, System.String field, IndexReader reader, IState state);
Example #11
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();
		}
			public override DocValues GetCachedFieldValues(FieldCache cache, System.String field, IndexReader reader)
			{
				throw new System.NotSupportedException(Lucene.Net.Search.Function.JustCompileSearchFunction.UNSUPPORTED_MSG);
			}
Example #13
0
 /*(non-Javadoc) <see cref="Lucene.Net.Search.Function.FieldCacheSource.getCachedValues(Lucene.Net.Search.FieldCache, java.lang.String, Lucene.Net.Index.IndexReader) */
 public override DocValues GetCachedFieldValues(FieldCache cache, System.String field, IndexReader reader, IState state)
 {
     sbyte[] arr = cache.GetBytes(reader, field, parser, state);
     return(new AnonymousClassDocValues(arr, this));
 }
Example #14
0
		/// <summary> Return cached DocValues for input field and reader.</summary>
		/// <param name="cache">FieldCache so that values of a field are loaded once per reader (RAM allowing)
		/// </param>
		/// <param name="field">Field for which values are required.
		/// </param>
		/// <seealso cref="ValueSource">
		/// </seealso>
		public abstract DocValues GetCachedFieldValues(FieldCache cache, System.String field, IndexReader reader);
 /*(non-Javadoc) <see cref="Lucene.Net.Search.Function.FieldCacheSource.getCachedValues(Lucene.Net.Search.FieldCache, java.lang.String, Lucene.Net.Index.IndexReader) */
 public override DocValues GetCachedFieldValues(FieldCache cache, string field, IndexReader reader)
 {
     int[] arr = cache.GetInts(reader, field, parser);
     return(new AnonymousClassDocValues(arr, this));
 }
		/// <summary> Quick and dirty convenience method</summary>
		/// <seealso cref="check">
		/// </seealso>
		public static Insanity[] CheckSanity(FieldCache cache)
		{
			return CheckSanity(cache.GetCacheEntries());
		}
 /// <summary> Quick and dirty convenience method</summary>
 /// <seealso cref="Check">
 /// </seealso>
 public static Insanity[] CheckSanity(FieldCache cache)
 {
     return(CheckSanity(cache.GetCacheEntries()));
 }