lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nightowl...@apache.org
Subject [07/11] lucenenet git commit: Lucene.Net.Core: Reviewed and removed some TODOs
Date Sat, 25 Mar 2017 06:11:21 GMT
Lucene.Net.Core: Reviewed and removed some TODOs


Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/d4df388d
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/d4df388d
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/d4df388d

Branch: refs/heads/api-work
Commit: d4df388d315fbd852b1ec48b8d1caeec8c51e05f
Parents: 2fc3881
Author: Shad Storhaug <shad@shadstorhaug.com>
Authored: Sat Mar 25 06:02:22 2017 +0700
Committer: Shad Storhaug <shad@shadstorhaug.com>
Committed: Sat Mar 25 06:02:22 2017 +0700

----------------------------------------------------------------------
 src/Lucene.Net.Core/Search/FieldCache.cs      | 1077 ++++++++++----------
 src/Lucene.Net.Core/Util/Constants.cs         |   99 +-
 src/Lucene.Net.Core/Util/RamUsageEstimator.cs |  207 ++--
 3 files changed, 688 insertions(+), 695 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/d4df388d/src/Lucene.Net.Core/Search/FieldCache.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Search/FieldCache.cs b/src/Lucene.Net.Core/Search/FieldCache.cs
index 60f6250..0a7f90f 100644
--- a/src/Lucene.Net.Core/Search/FieldCache.cs
+++ b/src/Lucene.Net.Core/Search/FieldCache.cs
@@ -910,543 +910,542 @@ namespace Lucene.Net.Search
             }
         }
     }
-
-    /*LUCENE TO-DO refactoring because of enum nonsense
-  public static readonly FieldCache DEFAULT = new FieldCacheImpl();
-
-  private class FieldCache_ByteParserAnonymousInnerClassHelper : FieldCache_ByteParser
-  {
-      public FieldCache_ByteParserAnonymousInnerClassHelper()
-      {
-      }
-
-      public virtual sbyte ParseByte(BytesRef term)
-      {
-      // TODO: would be far better to directly parse from
-      // UTF8 bytes... but really users should use
-      // IntField, instead, which already decodes
-      // directly from byte[]
-      return (sbyte)Convert.ToByte(term.Utf8ToString());
-      }
-    public override string ToString()
-    {
-      return typeof(FieldCache).Name + ".DEFAULT_BYTE_PARSER";
-    }
-    public virtual TermsEnum TermsEnum(Terms terms)
-    {
-      return terms.Iterator(null);
-    }
-  }
-
-  private class FieldCache_ShortParserAnonymousInnerClassHelper : FieldCache_ShortParser
-  {
-      public FieldCache_ShortParserAnonymousInnerClassHelper()
-      {
-      }
-
-      public virtual short ParseShort(BytesRef term)
-      {
-      // TODO: would be far better to directly parse from
-      // UTF8 bytes... but really users should use
-      // IntField, instead, which already decodes
-      // directly from byte[]
-      return Convert.ToInt16(term.Utf8ToString());
-      }
-    public override string ToString()
-    {
-      return typeof(FieldCache).Name + ".DEFAULT_SHORT_PARSER";
-    }
-
-    public virtual TermsEnum TermsEnum(Terms terms)
-    {
-      return terms.Iterator(null);
-    }
-  }
-
-  private class FieldCache_IntParserAnonymousInnerClassHelper : FieldCache_IntParser
-  {
-      public FieldCache_IntParserAnonymousInnerClassHelper()
-      {
-      }
-
-      public virtual int ParseInt(BytesRef term)
-      {
-      // TODO: would be far better to directly parse from
-      // UTF8 bytes... but really users should use
-      // IntField, instead, which already decodes
-      // directly from byte[]
-      return Convert.ToInt32(term.Utf8ToString());
-      }
-
-    public virtual TermsEnum TermsEnum(Terms terms)
-    {
-      return terms.Iterator(null);
-    }
-
-    public override string ToString()
-    {
-      return typeof(FieldCache).Name + ".DEFAULT_INT_PARSER";
-    }
-  }
-
-  private class FieldCache_FloatParserAnonymousInnerClassHelper : FieldCache_FloatParser
-  {
-      public FieldCache_FloatParserAnonymousInnerClassHelper()
-      {
-      }
-
-      public virtual float ParseFloat(BytesRef term)
-      {
-      // TODO: would be far better to directly parse from
-      // UTF8 bytes... but really users should use
-      // FloatField, instead, which already decodes
-      // directly from byte[]
-      return Convert.ToSingle(term.Utf8ToString());
-      }
-
-    public virtual TermsEnum TermsEnum(Terms terms)
-    {
-      return terms.Iterator(null);
-    }
-
-    public override string ToString()
-    {
-      return typeof(FieldCache).Name + ".DEFAULT_FLOAT_PARSER";
-    }
-  }
-
-  private class FieldCache_LongParserAnonymousInnerClassHelper : FieldCache_LongParser
-  {
-      public FieldCache_LongParserAnonymousInnerClassHelper()
-      {
-      }
-
-      public virtual long ParseLong(BytesRef term)
-      {
-      // TODO: would be far better to directly parse from
-      // UTF8 bytes... but really users should use
-      // LongField, instead, which already decodes
-      // directly from byte[]
-      return Convert.ToInt64(term.Utf8ToString());
-      }
-
-    public virtual TermsEnum TermsEnum(Terms terms)
-    {
-      return terms.Iterator(null);
-    }
-
-    public override string ToString()
-    {
-      return typeof(FieldCache).Name + ".DEFAULT_LONG_PARSER";
-    }
-  }
-
-  private class FieldCache_DoubleParserAnonymousInnerClassHelper : FieldCache_DoubleParser
-  {
-      public FieldCache_DoubleParserAnonymousInnerClassHelper()
-      {
-      }
-
-      public virtual double ParseDouble(BytesRef term)
-      {
-      // TODO: would be far better to directly parse from
-      // UTF8 bytes... but really users should use
-      // DoubleField, instead, which already decodes
-      // directly from byte[]
-      return Convert.ToDouble(term.Utf8ToString());
-      }
-
-    public virtual TermsEnum TermsEnum(Terms terms)
-    {
-      return terms.Iterator(null);
-    }
-
-    public override string ToString()
-    {
-      return typeof(FieldCache).Name + ".DEFAULT_DOUBLE_PARSER";
-    }
-  }
-
-  private class FieldCache_IntParserAnonymousInnerClassHelper2 : FieldCache_IntParser
-  {
-      public FieldCache_IntParserAnonymousInnerClassHelper2()
-      {
-      }
-
-      public override int ParseInt(BytesRef term)
-      {
-        return NumericUtils.PrefixCodedToInt(term);
-      }
-
-      public override TermsEnum TermsEnum(Terms terms)
-      {
-        return NumericUtils.FilterPrefixCodedInts(terms.Iterator(null));
-      }
-
-      public override string ToString()
-      {
-        return typeof(FieldCache).Name + ".NUMERIC_UTILS_INT_PARSER";
-      }
-  }
-
-  private class FieldCache_FloatParserAnonymousInnerClassHelper2 : FieldCache_FloatParser
-  {
-      public FieldCache_FloatParserAnonymousInnerClassHelper2()
-      {
-      }
-
-      public override float ParseFloat(BytesRef term)
-      {
-        return NumericUtils.SortableIntToFloat(NumericUtils.PrefixCodedToInt(term));
-      }
-      public override string ToString()
-      {
-        return typeof(FieldCache).Name + ".NUMERIC_UTILS_FLOAT_PARSER";
-      }
-
-      public override TermsEnum TermsEnum(Terms terms)
-      {
-        return NumericUtils.FilterPrefixCodedInts(terms.Iterator(null));
-      }
-  }
-
-  private class FieldCache_LongParserAnonymousInnerClassHelper2 : FieldCache_LongParser
-  {
-      public FieldCache_LongParserAnonymousInnerClassHelper2()
-      {
-      }
-
-      public override long ParseLong(BytesRef term)
-      {
-        return NumericUtils.PrefixCodedToLong(term);
-      }
-      public override string ToString()
-      {
-        return typeof(FieldCache).Name + ".NUMERIC_UTILS_LONG_PARSER";
-      }
-
-      public override TermsEnum TermsEnum(Terms terms)
-      {
-        return NumericUtils.FilterPrefixCodedLongs(terms.Iterator(null));
-      }
-  }
-
-  private class FieldCache_DoubleParserAnonymousInnerClassHelper2 : FieldCache_DoubleParser
-  {
-      public FieldCache_DoubleParserAnonymousInnerClassHelper2()
-      {
-      }
-
-      public override double ParseDouble(BytesRef term)
-      {
-        return NumericUtils.SortableLongToDouble(NumericUtils.PrefixCodedToLong(term));
-      }
-      public override string ToString()
-      {
-        return typeof(FieldCache).Name + ".NUMERIC_UTILS_DOUBLE_PARSER";
-      }
-
-      public override TermsEnum TermsEnum(Terms terms)
-      {
-        return NumericUtils.FilterPrefixCodedLongs(terms.Iterator(null));
-      }
-  }
-}
-
-  public abstract class FieldCache_Bytes
-  {
-    /// <summary>
-    /// Return a single Byte representation of this field's value. </summary>
-    public abstract sbyte Get(int docID);
-
-    /// <summary>
-    /// Zero value for every document </summary>
-    public static readonly FieldCache_Bytes EMPTY = new FieldCache_BytesAnonymousInnerClassHelper();
-
-    private class FieldCache_BytesAnonymousInnerClassHelper : FieldCache_Bytes
-    {
-        public FieldCache_BytesAnonymousInnerClassHelper()
-        {
-        }
-
-      public override sbyte Get(int docID)
-      {
-        return 0;
-      }
-    }
-  }
-
-  public abstract class FieldCache_Shorts
-  {
-    /// <summary>
-    /// Return a short representation of this field's value. </summary>
-    public abstract short Get(int docID);
-
-    /// <summary>
-    /// Zero value for every document </summary>
-    public static readonly FieldCache_Shorts EMPTY = new FieldCache_ShortsAnonymousInnerClassHelper();
-
-    private class FieldCache_ShortsAnonymousInnerClassHelper : FieldCache_Shorts
-    {
-        public FieldCache_ShortsAnonymousInnerClassHelper()
-        {
-        }
-
-      public override short Get(int docID)
-      {
-        return 0;
-      }
-    }
-  }
-
-  public abstract class FieldCache_Ints
-  {
-    /// <summary>
-    /// Return an integer representation of this field's value. </summary>
-    public abstract int Get(int docID);
-
-    /// <summary>
-    /// Zero value for every document </summary>
-    public static readonly FieldCache_Ints EMPTY = new FieldCache_IntsAnonymousInnerClassHelper();
-
-    private class FieldCache_IntsAnonymousInnerClassHelper : FieldCache_Ints
-    {
-        public FieldCache_IntsAnonymousInnerClassHelper()
-        {
-        }
-
-      public override int Get(int docID)
-      {
-        return 0;
-      }
-    }
-  }
-
-  public abstract class FieldCache_Longs
-  {
-    /// <summary>
-    /// Return an long representation of this field's value. </summary>
-    public abstract long Get(int docID);
-
-    /// <summary>
-    /// Zero value for every document </summary>
-    public static readonly FieldCache_Longs EMPTY = new FieldCache_LongsAnonymousInnerClassHelper();
-
-    private class FieldCache_LongsAnonymousInnerClassHelper : FieldCache_Longs
-    {
-        public FieldCache_LongsAnonymousInnerClassHelper()
-        {
-        }
-
-      public override long Get(int docID)
-      {
-        return 0;
-      }
-    }
-  }
-
-  public abstract class FieldCache_Floats
-  {
-    /// <summary>
-    /// Return an float representation of this field's value. </summary>
-    public abstract float Get(int docID);
-
-    /// <summary>
-    /// Zero value for every document </summary>
-    public static readonly FieldCache_Floats EMPTY = new FieldCache_FloatsAnonymousInnerClassHelper();
-
-    private class FieldCache_FloatsAnonymousInnerClassHelper : FieldCache_Floats
-    {
-        public FieldCache_FloatsAnonymousInnerClassHelper()
-        {
-        }
-
-      public override float Get(int docID)
-      {
-        return 0;
-      }
-    }
-  }
-
-  public abstract class FieldCache_Doubles
-  {
-    /// <summary>
-    /// Return an double representation of this field's value. </summary>
-    public abstract double Get(int docID);
-
-    /// <summary>
-    /// Zero value for every document </summary>
-    public static readonly FieldCache_Doubles EMPTY = new FieldCache_DoublesAnonymousInnerClassHelper();
-
-    private class FieldCache_DoublesAnonymousInnerClassHelper : FieldCache_Doubles
-    {
-        public FieldCache_DoublesAnonymousInnerClassHelper()
-        {
-        }
-
-      public override double Get(int docID)
-      {
-        return 0;
-      }
-    }
-  }
-
-  public sealed class FieldCache_CreationPlaceholder
-  {
-    internal object Value;
-  }
-
-  public interface FieldCache_Parser
-  {
-    /// <summary>
-    /// Pulls a <seealso cref="TermsEnum"/> from the given <seealso cref="Terms"/>.
this method allows certain parsers
-    /// to filter the actual TermsEnum before the field cache is filled.
-    /// </summary>
-    /// <param name="terms"> the <seealso cref="Terms"/> instance to create the
<seealso cref="TermsEnum"/> from. </param>
-    /// <returns> a possibly filtered <seealso cref="TermsEnum"/> instance, this
method must not return <code>null</code>. </returns>
-    /// <exception cref="IOException"> if an <seealso cref="IOException"/> occurs
</exception>
-    TermsEnum TermsEnum(Terms terms);
-  }
-
-  [Obsolete]
-  public interface FieldCache_ByteParser : FieldCache_Parser
-  {
-    /// <summary>
-    /// Return a single Byte representation of this field's value. </summary>
-    sbyte ParseByte(BytesRef term);
-  }
-
-  [Obsolete]
-  public interface FieldCache_ShortParser : FieldCache_Parser
-  {
-    /// <summary>
-    /// Return a short representation of this field's value. </summary>
-    short ParseShort(BytesRef term);
-  }
-
-  public interface FieldCache_IntParser : FieldCache_Parser
-  {
-    /// <summary>
-    /// Return an integer representation of this field's value. </summary>
-    int ParseInt(BytesRef term);
-  }
-
-  public interface FieldCache_FloatParser : FieldCache_Parser
-  {
-    /// <summary>
-    /// Return an float representation of this field's value. </summary>
-    float ParseFloat(BytesRef term);
-  }
-
-  public interface FieldCache_LongParser : FieldCache_Parser
-  {
-    /// <summary>
-    /// Return an long representation of this field's value. </summary>
-    long ParseLong(BytesRef term);
-  }
-
-  public interface FieldCache_DoubleParser : FieldCache_Parser
-  {
-    /// <summary>
-    /// Return an double representation of this field's value. </summary>
-    double ParseDouble(BytesRef term);
-  }
-
-  public sealed class FieldCache_CacheEntry
-  {
-    private readonly object readerKey;
-    private readonly string fieldName;
-    private readonly Type cacheType;
-    private readonly object custom;
-    private readonly object value;
-    private string Size;
-
-    public FieldCache_CacheEntry(object readerKey, string fieldName, Type cacheType, object
custom, object value)
-    {
-      this.readerKey = readerKey;
-      this.fieldName = fieldName;
-      this.cacheType = cacheType;
-      this.custom = custom;
-      this.value = value;
-    }
-
-    public object ReaderKey
-    {
-        get
-        {
-          return readerKey;
-        }
-    }
-
-    public string FieldName
-    {
-        get
-        {
-          return fieldName;
-        }
-    }
-
-    public Type CacheType
-    {
-        get
-        {
-          return cacheType;
-        }
-    }
-
-    public object Custom
-    {
-        get
-        {
-          return custom;
-        }
-    }
-
-    public object Value
-    {
-        get
-        {
-          return value;
-        }
-    }
-
-    /// <summary>
-    /// Computes (and stores) the estimated size of the cache Value </summary>
-    /// <seealso cref= #getEstimatedSize </seealso>
-    public void EstimateSize()
-    {
-      long bytesUsed = RamUsageEstimator.SizeOf(Value);
-      Size = RamUsageEstimator.HumanReadableUnits(bytesUsed);
-    }
-
-    /// <summary>
-    /// The most recently estimated size of the value, null unless
-    /// estimateSize has been called.
-    /// </summary>
-    public string EstimatedSize
-    {
-        get
-        {
-          return Size;
-        }
-    }
-
-    public override string ToString()
-    {
-      StringBuilder b = new StringBuilder();
-      b.Append("'").Append(ReaderKey).Append("'=>");
-      b.Append("'").Append(FieldName).Append("',");
-      b.Append(CacheType).Append(",").Append(Custom);
-      b.Append("=>").Append(Value.GetType().Name).Append("#");
-      b.Append(System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(Value));
-
-      string s = EstimatedSize;
-      if (null != s)
-      {
-        b.Append(" (size =~ ").Append(s).Append(')');
-      }
-
-      return b.ToString();
-    }
-  }*/
+    
+//  // LUCENENET NOTE: refactoring because of enum nonsense
+//  public static readonly FieldCache DEFAULT = new FieldCacheImpl();
+
+//  private class FieldCache_ByteParserAnonymousInnerClassHelper : FieldCache_ByteParser
+//  {
+//      public FieldCache_ByteParserAnonymousInnerClassHelper()
+//      {
+//      }
+
+//      public virtual sbyte ParseByte(BytesRef term)
+//      {
+//      // TODO: would be far better to directly parse from
+//      // UTF8 bytes... but really users should use
+//      // IntField, instead, which already decodes
+//      // directly from byte[]
+//      return (sbyte)Convert.ToByte(term.Utf8ToString());
+//      }
+//    public override string ToString()
+//    {
+//      return typeof(FieldCache).Name + ".DEFAULT_BYTE_PARSER";
+//    }
+//    public virtual TermsEnum TermsEnum(Terms terms)
+//    {
+//      return terms.Iterator(null);
+//    }
+//  }
+
+//  private class FieldCache_ShortParserAnonymousInnerClassHelper : FieldCache_ShortParser
+//  {
+//      public FieldCache_ShortParserAnonymousInnerClassHelper()
+//      {
+//      }
+
+//      public virtual short ParseShort(BytesRef term)
+//      {
+//      // TODO: would be far better to directly parse from
+//      // UTF8 bytes... but really users should use
+//      // IntField, instead, which already decodes
+//      // directly from byte[]
+//      return Convert.ToInt16(term.Utf8ToString());
+//      }
+//    public override string ToString()
+//    {
+//      return typeof(FieldCache).Name + ".DEFAULT_SHORT_PARSER";
+//    }
+
+//    public virtual TermsEnum TermsEnum(Terms terms)
+//    {
+//      return terms.Iterator(null);
+//    }
+//  }
+
+//  private class FieldCache_IntParserAnonymousInnerClassHelper : FieldCache_IntParser
+//  {
+//      public FieldCache_IntParserAnonymousInnerClassHelper()
+//      {
+//      }
+
+//      public virtual int ParseInt(BytesRef term)
+//      {
+//      // TODO: would be far better to directly parse from
+//      // UTF8 bytes... but really users should use
+//      // IntField, instead, which already decodes
+//      // directly from byte[]
+//      return Convert.ToInt32(term.Utf8ToString());
+//      }
+
+//    public virtual TermsEnum TermsEnum(Terms terms)
+//    {
+//      return terms.Iterator(null);
+//    }
+
+//    public override string ToString()
+//    {
+//      return typeof(FieldCache).Name + ".DEFAULT_INT_PARSER";
+//    }
+//  }
+
+//  private class FieldCache_FloatParserAnonymousInnerClassHelper : FieldCache_FloatParser
+//  {
+//      public FieldCache_FloatParserAnonymousInnerClassHelper()
+//      {
+//      }
+
+//      public virtual float ParseFloat(BytesRef term)
+//      {
+//      // TODO: would be far better to directly parse from
+//      // UTF8 bytes... but really users should use
+//      // FloatField, instead, which already decodes
+//      // directly from byte[]
+//      return Convert.ToSingle(term.Utf8ToString());
+//      }
+
+//    public virtual TermsEnum TermsEnum(Terms terms)
+//    {
+//      return terms.Iterator(null);
+//    }
+
+//    public override string ToString()
+//    {
+//      return typeof(FieldCache).Name + ".DEFAULT_FLOAT_PARSER";
+//    }
+//  }
+
+//  private class FieldCache_LongParserAnonymousInnerClassHelper : FieldCache_LongParser
+//  {
+//      public FieldCache_LongParserAnonymousInnerClassHelper()
+//      {
+//      }
+
+//      public virtual long ParseLong(BytesRef term)
+//      {
+//      // TODO: would be far better to directly parse from
+//      // UTF8 bytes... but really users should use
+//      // LongField, instead, which already decodes
+//      // directly from byte[]
+//      return Convert.ToInt64(term.Utf8ToString());
+//      }
+
+//    public virtual TermsEnum TermsEnum(Terms terms)
+//    {
+//      return terms.Iterator(null);
+//    }
+
+//    public override string ToString()
+//    {
+//      return typeof(FieldCache).Name + ".DEFAULT_LONG_PARSER";
+//    }
+//  }
+
+//  private class FieldCache_DoubleParserAnonymousInnerClassHelper : FieldCache_DoubleParser
+//  {
+//      public FieldCache_DoubleParserAnonymousInnerClassHelper()
+//      {
+//      }
+
+//      public virtual double ParseDouble(BytesRef term)
+//      {
+//      // TODO: would be far better to directly parse from
+//      // UTF8 bytes... but really users should use
+//      // DoubleField, instead, which already decodes
+//      // directly from byte[]
+//      return Convert.ToDouble(term.Utf8ToString());
+//      }
+
+//    public virtual TermsEnum TermsEnum(Terms terms)
+//    {
+//      return terms.Iterator(null);
+//    }
+
+//    public override string ToString()
+//    {
+//      return typeof(FieldCache).Name + ".DEFAULT_DOUBLE_PARSER";
+//    }
+//  }
+
+//  private class FieldCache_IntParserAnonymousInnerClassHelper2 : FieldCache_IntParser
+//  {
+//      public FieldCache_IntParserAnonymousInnerClassHelper2()
+//      {
+//      }
+
+//      public override int ParseInt(BytesRef term)
+//      {
+//        return NumericUtils.PrefixCodedToInt(term);
+//      }
+
+//      public override TermsEnum TermsEnum(Terms terms)
+//      {
+//        return NumericUtils.FilterPrefixCodedInts(terms.Iterator(null));
+//      }
+
+//      public override string ToString()
+//      {
+//        return typeof(FieldCache).Name + ".NUMERIC_UTILS_INT_PARSER";
+//      }
+//  }
+
+//  private class FieldCache_FloatParserAnonymousInnerClassHelper2 : FieldCache_FloatParser
+//  {
+//      public FieldCache_FloatParserAnonymousInnerClassHelper2()
+//      {
+//      }
+
+//      public override float ParseFloat(BytesRef term)
+//      {
+//        return NumericUtils.SortableIntToFloat(NumericUtils.PrefixCodedToInt(term));
+//      }
+//      public override string ToString()
+//      {
+//        return typeof(FieldCache).Name + ".NUMERIC_UTILS_FLOAT_PARSER";
+//      }
+
+//      public override TermsEnum TermsEnum(Terms terms)
+//      {
+//        return NumericUtils.FilterPrefixCodedInts(terms.Iterator(null));
+//      }
+//  }
+
+//  private class FieldCache_LongParserAnonymousInnerClassHelper2 : FieldCache_LongParser
+//  {
+//      public FieldCache_LongParserAnonymousInnerClassHelper2()
+//      {
+//      }
+
+//      public override long ParseLong(BytesRef term)
+//      {
+//        return NumericUtils.PrefixCodedToLong(term);
+//      }
+//      public override string ToString()
+//      {
+//        return typeof(FieldCache).Name + ".NUMERIC_UTILS_LONG_PARSER";
+//      }
+
+//      public override TermsEnum TermsEnum(Terms terms)
+//      {
+//        return NumericUtils.FilterPrefixCodedLongs(terms.Iterator(null));
+//      }
+//  }
+
+//  private class FieldCache_DoubleParserAnonymousInnerClassHelper2 : FieldCache_DoubleParser
+//  {
+//      public FieldCache_DoubleParserAnonymousInnerClassHelper2()
+//      {
+//      }
+
+//      public override double ParseDouble(BytesRef term)
+//      {
+//        return NumericUtils.SortableLongToDouble(NumericUtils.PrefixCodedToLong(term));
+//      }
+//      public override string ToString()
+//      {
+//        return typeof(FieldCache).Name + ".NUMERIC_UTILS_DOUBLE_PARSER";
+//      }
+
+//      public override TermsEnum TermsEnum(Terms terms)
+//      {
+//        return NumericUtils.FilterPrefixCodedLongs(terms.Iterator(null));
+//      }
+//  }
+//}
+
+//  public abstract class FieldCache_Bytes
+//  {
+//    /// <summary>
+//    /// Return a single Byte representation of this field's value. </summary>
+//    public abstract sbyte Get(int docID);
+
+//    /// <summary>
+//    /// Zero value for every document </summary>
+//    public static readonly FieldCache_Bytes EMPTY = new FieldCache_BytesAnonymousInnerClassHelper();
+
+//    private class FieldCache_BytesAnonymousInnerClassHelper : FieldCache_Bytes
+//    {
+//        public FieldCache_BytesAnonymousInnerClassHelper()
+//        {
+//        }
+
+//      public override sbyte Get(int docID)
+//      {
+//        return 0;
+//      }
+//    }
+//  }
+
+//  public abstract class FieldCache_Shorts
+//  {
+//    /// <summary>
+//    /// Return a short representation of this field's value. </summary>
+//    public abstract short Get(int docID);
+
+//    /// <summary>
+//    /// Zero value for every document </summary>
+//    public static readonly FieldCache_Shorts EMPTY = new FieldCache_ShortsAnonymousInnerClassHelper();
+
+//    private class FieldCache_ShortsAnonymousInnerClassHelper : FieldCache_Shorts
+//    {
+//        public FieldCache_ShortsAnonymousInnerClassHelper()
+//        {
+//        }
+
+//      public override short Get(int docID)
+//      {
+//        return 0;
+//      }
+//    }
+//  }
+
+//  public abstract class FieldCache_Ints
+//  {
+//    /// <summary>
+//    /// Return an integer representation of this field's value. </summary>
+//    public abstract int Get(int docID);
+
+//    /// <summary>
+//    /// Zero value for every document </summary>
+//    public static readonly FieldCache_Ints EMPTY = new FieldCache_IntsAnonymousInnerClassHelper();
+
+//    private class FieldCache_IntsAnonymousInnerClassHelper : FieldCache_Ints
+//    {
+//        public FieldCache_IntsAnonymousInnerClassHelper()
+//        {
+//        }
+
+//      public override int Get(int docID)
+//      {
+//        return 0;
+//      }
+//    }
+//  }
+
+//  public abstract class FieldCache_Longs
+//  {
+//    /// <summary>
+//    /// Return an long representation of this field's value. </summary>
+//    public abstract long Get(int docID);
+
+//    /// <summary>
+//    /// Zero value for every document </summary>
+//    public static readonly FieldCache_Longs EMPTY = new FieldCache_LongsAnonymousInnerClassHelper();
+
+//    private class FieldCache_LongsAnonymousInnerClassHelper : FieldCache_Longs
+//    {
+//        public FieldCache_LongsAnonymousInnerClassHelper()
+//        {
+//        }
+
+//      public override long Get(int docID)
+//      {
+//        return 0;
+//      }
+//    }
+//  }
+
+//  public abstract class FieldCache_Floats
+//  {
+//    /// <summary>
+//    /// Return an float representation of this field's value. </summary>
+//    public abstract float Get(int docID);
+
+//    /// <summary>
+//    /// Zero value for every document </summary>
+//    public static readonly FieldCache_Floats EMPTY = new FieldCache_FloatsAnonymousInnerClassHelper();
+
+//    private class FieldCache_FloatsAnonymousInnerClassHelper : FieldCache_Floats
+//    {
+//        public FieldCache_FloatsAnonymousInnerClassHelper()
+//        {
+//        }
+
+//      public override float Get(int docID)
+//      {
+//        return 0;
+//      }
+//    }
+//  }
+
+//  public abstract class FieldCache_Doubles
+//  {
+//    /// <summary>
+//    /// Return an double representation of this field's value. </summary>
+//    public abstract double Get(int docID);
+
+//    /// <summary>
+//    /// Zero value for every document </summary>
+//    public static readonly FieldCache_Doubles EMPTY = new FieldCache_DoublesAnonymousInnerClassHelper();
+
+//    private class FieldCache_DoublesAnonymousInnerClassHelper : FieldCache_Doubles
+//    {
+//        public FieldCache_DoublesAnonymousInnerClassHelper()
+//        {
+//        }
+
+//      public override double Get(int docID)
+//      {
+//        return 0;
+//      }
+//    }
+//  }
+
+//  public sealed class FieldCache_CreationPlaceholder
+//  {
+//    internal object Value;
+//  }
+
+//  public interface FieldCache_Parser
+//  {
+//    /// <summary>
+//    /// Pulls a <seealso cref="TermsEnum"/> from the given <seealso cref="Terms"/>.
this method allows certain parsers
+//    /// to filter the actual TermsEnum before the field cache is filled.
+//    /// </summary>
+//    /// <param name="terms"> the <seealso cref="Terms"/> instance to create
the <seealso cref="TermsEnum"/> from. </param>
+//    /// <returns> a possibly filtered <seealso cref="TermsEnum"/> instance,
this method must not return <code>null</code>. </returns>
+//    /// <exception cref="IOException"> if an <seealso cref="IOException"/>
occurs </exception>
+//    TermsEnum TermsEnum(Terms terms);
+//  }
+
+//  [Obsolete]
+//  public interface FieldCache_ByteParser : FieldCache_Parser
+//  {
+//    /// <summary>
+//    /// Return a single Byte representation of this field's value. </summary>
+//    sbyte ParseByte(BytesRef term);
+//  }
+
+//  [Obsolete]
+//  public interface FieldCache_ShortParser : FieldCache_Parser
+//  {
+//    /// <summary>
+//    /// Return a short representation of this field's value. </summary>
+//    short ParseShort(BytesRef term);
+//  }
+
+//  public interface FieldCache_IntParser : FieldCache_Parser
+//  {
+//    /// <summary>
+//    /// Return an integer representation of this field's value. </summary>
+//    int ParseInt(BytesRef term);
+//  }
+
+//  public interface FieldCache_FloatParser : FieldCache_Parser
+//  {
+//    /// <summary>
+//    /// Return an float representation of this field's value. </summary>
+//    float ParseFloat(BytesRef term);
+//  }
+
+//  public interface FieldCache_LongParser : FieldCache_Parser
+//  {
+//    /// <summary>
+//    /// Return an long representation of this field's value. </summary>
+//    long ParseLong(BytesRef term);
+//  }
+
+//  public interface FieldCache_DoubleParser : FieldCache_Parser
+//  {
+//    /// <summary>
+//    /// Return an double representation of this field's value. </summary>
+//    double ParseDouble(BytesRef term);
+//  }
+
+//  public sealed class FieldCache_CacheEntry
+//  {
+//    private readonly object readerKey;
+//    private readonly string fieldName;
+//    private readonly Type cacheType;
+//    private readonly object custom;
+//    private readonly object value;
+//    private string Size;
+
+//    public FieldCache_CacheEntry(object readerKey, string fieldName, Type cacheType, object
custom, object value)
+//    {
+//      this.readerKey = readerKey;
+//      this.fieldName = fieldName;
+//      this.cacheType = cacheType;
+//      this.custom = custom;
+//      this.value = value;
+//    }
+
+//    public object ReaderKey
+//    {
+//        get
+//        {
+//          return readerKey;
+//        }
+//    }
+
+//    public string FieldName
+//    {
+//        get
+//        {
+//          return fieldName;
+//        }
+//    }
+
+//    public Type CacheType
+//    {
+//        get
+//        {
+//          return cacheType;
+//        }
+//    }
+
+//    public object Custom
+//    {
+//        get
+//        {
+//          return custom;
+//        }
+//    }
+
+//    public object Value
+//    {
+//        get
+//        {
+//          return value;
+//        }
+//    }
+
+//    /// <summary>
+//    /// Computes (and stores) the estimated size of the cache Value </summary>
+//    /// <seealso cref= #getEstimatedSize </seealso>
+//    public void EstimateSize()
+//    {
+//      long bytesUsed = RamUsageEstimator.SizeOf(Value);
+//      Size = RamUsageEstimator.HumanReadableUnits(bytesUsed);
+//    }
+
+//    /// <summary>
+//    /// The most recently estimated size of the value, null unless
+//    /// estimateSize has been called.
+//    /// </summary>
+//    public string EstimatedSize
+//    {
+//        get
+//        {
+//          return Size;
+//        }
+//    }
+
+//    public override string ToString()
+//    {
+//      StringBuilder b = new StringBuilder();
+//      b.Append("'").Append(ReaderKey).Append("'=>");
+//      b.Append("'").Append(FieldName).Append("',");
+//      b.Append(CacheType).Append(",").Append(Custom);
+//      b.Append("=>").Append(Value.GetType().Name).Append("#");
+//      b.Append(System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(Value));
+
+//      string s = EstimatedSize;
+//      if (null != s)
+//      {
+//        b.Append(" (size =~ ").Append(s).Append(')');
+//      }
+
+//      return b.ToString();
+//    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/d4df388d/src/Lucene.Net.Core/Util/Constants.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/Constants.cs b/src/Lucene.Net.Core/Util/Constants.cs
index 69b5392..284a647 100644
--- a/src/Lucene.Net.Core/Util/Constants.cs
+++ b/src/Lucene.Net.Core/Util/Constants.cs
@@ -116,56 +116,57 @@ namespace Lucene.Net.Util
             catch (System.Security.SecurityException) //Ignore in medium trust.
             {
             }
-            /* LUCENE TO-DO Well that was all over the top to check architechture
-            bool is64Bit = false;
-            try
-            {
-              Type unsafeClass = Type.GetType("sun.misc.Unsafe");
-              Field unsafeField = unsafeClass.getDeclaredField("theUnsafe");
-              unsafeField.Accessible = true;
-              object @unsafe = unsafeField.get(null);
-              int addressSize = (int)((Number) unsafeClass.GetMethod("addressSize").invoke(@unsafe));
-              is64Bit = addressSize >= 8;
-            }
-            catch (Exception e)
-            {
-              string x = System.getProperty("sun.arch.data.model");
-              if (x != null)
-              {
-                is64Bit = x.IndexOf("64") != -1;
-              }
-              else
-              {
-                if (OS_ARCH != null && OS_ARCH.IndexOf("64") != -1)
-                {
-                  is64Bit = true;
-                }
-                else
-                {
-                  is64Bit = false;
-                }
-              }
-            }
-            RUNTIME_IS_64BIT = is64Bit;
 
-            // this method only exists in Java 8:
-            bool v8 = true;
-            try
-            {
-              typeof(Collections).getMethod("emptySortedSet");
-            }
-            catch (NoSuchMethodException nsme)
-            {
-              v8 = false;
-            }
-            JRE_IS_MINIMUM_JAVA8 = v8;
-            Package pkg = LucenePackage.Get();
-            string v = (pkg == null) ? null : pkg.ImplementationVersion;
-            if (v == null)
-            {
-              v = MainVersionWithoutAlphaBeta() + "-SNAPSHOT";
-            }
-            LUCENE_VERSION = Ident(v);*/
+            //LUCENENET NOTE: Well that was all over the top to check architechture
+            //bool is64Bit = false;
+            //try
+            //{
+            //  Type unsafeClass = Type.GetType("sun.misc.Unsafe");
+            //  Field unsafeField = unsafeClass.getDeclaredField("theUnsafe");
+            //  unsafeField.Accessible = true;
+            //  object @unsafe = unsafeField.get(null);
+            //  int addressSize = (int)((Number) unsafeClass.GetMethod("addressSize").invoke(@unsafe));
+            //  is64Bit = addressSize >= 8;
+            //}
+            //catch (Exception e)
+            //{
+            //  string x = System.getProperty("sun.arch.data.model");
+            //  if (x != null)
+            //  {
+            //    is64Bit = x.IndexOf("64") != -1;
+            //  }
+            //  else
+            //  {
+            //    if (OS_ARCH != null && OS_ARCH.IndexOf("64") != -1)
+            //    {
+            //      is64Bit = true;
+            //    }
+            //    else
+            //    {
+            //      is64Bit = false;
+            //    }
+            //  }
+            //}
+            //RUNTIME_IS_64BIT = is64Bit;
+
+            //// this method only exists in Java 8:
+            //bool v8 = true;
+            //try
+            //{
+            //  typeof(Collections).getMethod("emptySortedSet");
+            //}
+            //catch (NoSuchMethodException nsme)
+            //{
+            //  v8 = false;
+            //}
+            //JRE_IS_MINIMUM_JAVA8 = v8;
+            //Package pkg = LucenePackage.Get();
+            //string v = (pkg == null) ? null : pkg.ImplementationVersion;
+            //if (v == null)
+            //{
+            //  v = MainVersionWithoutAlphaBeta() + "-SNAPSHOT";
+            //}
+            //LUCENE_VERSION = Ident(v);
         }
 
         // this method prevents inlining the final version constant in compiled classes,

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/d4df388d/src/Lucene.Net.Core/Util/RamUsageEstimator.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/RamUsageEstimator.cs b/src/Lucene.Net.Core/Util/RamUsageEstimator.cs
index 8c1602e..6e0fca7 100644
--- a/src/Lucene.Net.Core/Util/RamUsageEstimator.cs
+++ b/src/Lucene.Net.Core/Util/RamUsageEstimator.cs
@@ -135,105 +135,98 @@ namespace Lucene.Net.Util
             int objectAlignment = Constants.RUNTIME_IS_64BIT ? 8 : 4;
 
 
-            /* LUCENENET TODO
-
-		    Type unsafeClass = null;
-		    object tempTheUnsafe = null;
-		    try
-		    {
-		      unsafeClass = Type.GetType("sun.misc.Unsafe");
-		      FieldInfo unsafeField = unsafeClass.getDeclaredField("theUnsafe");
-		      unsafeField.Accessible = true;
-		      tempTheUnsafe = unsafeField.get(null);
-		    }
-		    catch (Exception e)
-		    {
-		      // Ignore.
-		    }
-		    TheUnsafe = tempTheUnsafe;
-
-		    // get object reference size by getting scale factor of Object[] arrays:
-		    try
-		    {
-		      Method arrayIndexScaleM = unsafeClass.GetMethod("arrayIndexScale", typeof(Type));
-		      referenceSize = (int)((Number) arrayIndexScaleM.invoke(TheUnsafe, typeof(object[])));
-		    }
-		    catch (Exception e)
-		    {
-		      // ignore.
-		    }
-            */
+		    //Type unsafeClass = null;
+		    //object tempTheUnsafe = null;
+		    //try
+		    //{
+		    //  unsafeClass = Type.GetType("sun.misc.Unsafe");
+		    //  FieldInfo unsafeField = unsafeClass.getDeclaredField("theUnsafe");
+		    //  unsafeField.Accessible = true;
+		    //  tempTheUnsafe = unsafeField.get(null);
+		    //}
+		    //catch (Exception e)
+		    //{
+		    //  // Ignore.
+		    //}
+		    //TheUnsafe = tempTheUnsafe;
+
+		    //// get object reference size by getting scale factor of Object[] arrays:
+		    //try
+		    //{
+		    //  Method arrayIndexScaleM = unsafeClass.GetMethod("arrayIndexScale", typeof(Type));
+		    //  referenceSize = (int)((Number) arrayIndexScaleM.invoke(TheUnsafe, typeof(object[])));
+		    //}
+		    //catch (Exception e)
+		    //{
+		    //  // ignore.
+		    //}
 
             // "best guess" based on reference size. We will attempt to modify
             // these to exact values if there is supported infrastructure.
             objectHeader = Constants.RUNTIME_IS_64BIT ? (8 + referenceSize) : 8;
 		    arrayHeader = Constants.RUNTIME_IS_64BIT ? (8 + 2 * referenceSize) : 12;
 
-            /* LUCENENET TODO
-             
-		    // get the object header size:
-		    // - first try out if the field offsets are not scaled (see warning in Unsafe docs)
-		    // - get the object header size by getting the field offset of the first field of a
dummy object
-		    // If the scaling is byte-wise and unsafe is available, enable dynamic size measurement
for
-		    // estimateRamUsage().
-		    Method tempObjectFieldOffsetMethod = null;
-		    try
-		    {
-		      Method objectFieldOffsetM = unsafeClass.GetMethod("objectFieldOffset", typeof(FieldInfo));
-		      FieldInfo dummy1Field = typeof(DummyTwoLongObject).getDeclaredField("dummy1");
-		      int ofs1 = (int)((Number) objectFieldOffsetM.invoke(TheUnsafe, dummy1Field));
-		      FieldInfo dummy2Field = typeof(DummyTwoLongObject).getDeclaredField("dummy2");
-		      int ofs2 = (int)((Number) objectFieldOffsetM.invoke(TheUnsafe, dummy2Field));
-		      if (Math.Abs(ofs2 - ofs1) == NUM_BYTES_LONG)
-		      {
-			    FieldInfo baseField = typeof(DummyOneFieldObject).getDeclaredField("base");
-			    objectHeader = (int)((Number) objectFieldOffsetM.invoke(TheUnsafe, baseField));
-			    tempObjectFieldOffsetMethod = objectFieldOffsetM;
-		      }
-		    }
-		    catch (Exception e)
-		    {
-		      // Ignore.
-		    }
-		    ObjectFieldOffsetMethod = tempObjectFieldOffsetMethod;
-
-		    // Get the array header size by retrieving the array base offset
-		    // (offset of the first element of an array).
-		    try
-		    {
-		      Method arrayBaseOffsetM = unsafeClass.GetMethod("arrayBaseOffset", typeof(Type));
-		      // we calculate that only for byte[] arrays, it's actually the same for all types:
-		      arrayHeader = (int)((Number) arrayBaseOffsetM.invoke(TheUnsafe, typeof(sbyte[])));
-		    }
-		    catch (Exception e)
-		    {
-		      // Ignore.
-		    }
-            */
+		    //// get the object header size:
+		    //// - first try out if the field offsets are not scaled (see warning in Unsafe docs)
+		    //// - get the object header size by getting the field offset of the first field of
a dummy object
+		    //// If the scaling is byte-wise and unsafe is available, enable dynamic size measurement
for
+		    //// estimateRamUsage().
+		    //Method tempObjectFieldOffsetMethod = null;
+		    //try
+		    //{
+		    //  Method objectFieldOffsetM = unsafeClass.GetMethod("objectFieldOffset", typeof(FieldInfo));
+		    //  FieldInfo dummy1Field = typeof(DummyTwoLongObject).getDeclaredField("dummy1");
+		    //  int ofs1 = (int)((Number) objectFieldOffsetM.invoke(TheUnsafe, dummy1Field));
+		    //  FieldInfo dummy2Field = typeof(DummyTwoLongObject).getDeclaredField("dummy2");
+		    //  int ofs2 = (int)((Number) objectFieldOffsetM.invoke(TheUnsafe, dummy2Field));
+		    //  if (Math.Abs(ofs2 - ofs1) == NUM_BYTES_LONG)
+		    //  {
+			   // FieldInfo baseField = typeof(DummyOneFieldObject).getDeclaredField("base");
+			   // objectHeader = (int)((Number) objectFieldOffsetM.invoke(TheUnsafe, baseField));
+			   // tempObjectFieldOffsetMethod = objectFieldOffsetM;
+		    //  }
+		    //}
+		    //catch (Exception e)
+		    //{
+		    //  // Ignore.
+		    //}
+		    //ObjectFieldOffsetMethod = tempObjectFieldOffsetMethod;
+
+		    //// Get the array header size by retrieving the array base offset
+		    //// (offset of the first element of an array).
+		    //try
+		    //{
+		    //  Method arrayBaseOffsetM = unsafeClass.GetMethod("arrayBaseOffset", typeof(Type));
+		    //  // we calculate that only for byte[] arrays, it's actually the same for all types:
+		    //  arrayHeader = (int)((Number) arrayBaseOffsetM.invoke(TheUnsafe, typeof(sbyte[])));
+		    //}
+		    //catch (Exception e)
+		    //{
+		    //  // Ignore.
+		    //}
+
             NUM_BYTES_OBJECT_REF = referenceSize;
             NUM_BYTES_OBJECT_HEADER = objectHeader;
             NUM_BYTES_ARRAY_HEADER = arrayHeader;
 
-            /* LUCENENET TODO
-          // Try to get the object alignment (the default seems to be 8 on Hotspot,
-          // regardless of the architecture).
-          int objectAlignment = 8;
-          try
-          {
-            Type beanClazz = Type.GetType("com.sun.management.HotSpotDiagnosticMXBean").asSubclass(typeof(PlatformManagedObject));
-            object hotSpotBean = ManagementFactory.getPlatformMXBean(beanClazz);
-            if (hotSpotBean != null)
-            {
-              Method getVMOptionMethod = beanClazz.GetMethod("getVMOption", typeof(string));
-              object vmOption = getVMOptionMethod.invoke(hotSpotBean, "ObjectAlignmentInBytes");
-              objectAlignment = Convert.ToInt32(vmOption.GetType().GetMethod("getValue").invoke(vmOption).ToString());
-            }
-          }
-          catch (Exception e)
-          {
-            // Ignore.
-          }
-            */
+            //// Try to get the object alignment (the default seems to be 8 on Hotspot,
+            //// regardless of the architecture).
+            //int objectAlignment = 8;
+            //try
+            //{
+            //Type beanClazz = Type.GetType("com.sun.management.HotSpotDiagnosticMXBean").asSubclass(typeof(PlatformManagedObject));
+            //object hotSpotBean = ManagementFactory.getPlatformMXBean(beanClazz);
+            //if (hotSpotBean != null)
+            //{
+            //    Method getVMOptionMethod = beanClazz.GetMethod("getVMOption", typeof(string));
+            //    object vmOption = getVMOptionMethod.invoke(hotSpotBean, "ObjectAlignmentInBytes");
+            //    objectAlignment = Convert.ToInt32(vmOption.GetType().GetMethod("getValue").invoke(vmOption).ToString());
+            //}
+            //}
+            //catch (Exception e)
+            //{
+            //// Ignore.
+            //}
 
             NUM_BYTES_OBJECT_ALIGNMENT = objectAlignment;
 
@@ -614,24 +607,24 @@ namespace Lucene.Net.Util
         {
             Type type = f.FieldType;
             int fsize = type.GetTypeInfo().IsPrimitive ? primitiveSizes[type] : NUM_BYTES_OBJECT_REF;
-            /* LUCENE-TODO I dont think this will ever not be null
-            if (ObjectFieldOffsetMethod != null)
-            {
-              try
-              {
-                long offsetPlusSize = (long)((Number) ObjectFieldOffsetMethod.invoke(TheUnsafe,
f)) + fsize;
-                return Math.Max(sizeSoFar, offsetPlusSize);
-              }
-              catch (Exception ex)
-              {
-                throw new Exception("Access problem with sun.misc.Unsafe", ex);
-              }
-            }
-            else
-            {
-              // TODO: No alignments based on field type/ subclass fields alignments?
-              return sizeSoFar + fsize;
-            }*/
+            // LUCENENET NOTE: I dont think this will ever not be null
+            //if (ObjectFieldOffsetMethod != null)
+            //{
+            //  try
+            //  {
+            //    long offsetPlusSize = (long)((Number) ObjectFieldOffsetMethod.invoke(TheUnsafe,
f)) + fsize;
+            //    return Math.Max(sizeSoFar, offsetPlusSize);
+            //  }
+            //  catch (Exception ex)
+            //  {
+            //    throw new Exception("Access problem with sun.misc.Unsafe", ex);
+            //  }
+            //}
+            //else
+            //{
+            //  // TODO: No alignments based on field type/ subclass fields alignments?
+            //  return sizeSoFar + fsize;
+            //}
             return sizeSoFar + fsize;
         }
 


Mime
View raw message