You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by sy...@apache.org on 2014/11/07 04:59:51 UTC
[4/5] lucenenet git commit: Various
Various
Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/a37fd381
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/a37fd381
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/a37fd381
Branch: refs/heads/master
Commit: a37fd3810e630560f209175bb5897975c21c57a2
Parents: 42bbbba
Author: Itamar Syn-Hershko <it...@code972.com>
Authored: Fri Nov 7 05:56:10 2014 +0200
Committer: Itamar Syn-Hershko <it...@code972.com>
Committed: Fri Nov 7 05:56:10 2014 +0200
----------------------------------------------------------------------
.../Codecs/Lucene40/Lucene40FieldInfosReader.cs | 2 +-
src/Lucene.Net.Core/Index/BufferedUpdates.cs | 3 +-
src/Lucene.Net.Core/Search/Query.cs | 30 +++++++-------------
src/Lucene.Net.Core/Support/HashMap.cs | 2 +-
src/Lucene.Net.Core/Support/Number.cs | 12 ++++++++
src/Lucene.Net.Core/Support/WeakDictionary.cs | 2 +-
src/Lucene.Net.Core/Util/RamUsageEstimator.cs | 2 +-
src/Lucene.Net.Queries/CustomScoreQuery.cs | 6 ++--
src/Lucene.Net.Queries/Function/BoostedQuery.cs | 4 +--
.../Lucene.Net.Queries.csproj | 4 ---
10 files changed, 31 insertions(+), 36 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a37fd381/src/Lucene.Net.Core/Codecs/Lucene40/Lucene40FieldInfosReader.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Codecs/Lucene40/Lucene40FieldInfosReader.cs b/src/Lucene.Net.Core/Codecs/Lucene40/Lucene40FieldInfosReader.cs
index 2941740..d5ac8c3 100644
--- a/src/Lucene.Net.Core/Codecs/Lucene40/Lucene40FieldInfosReader.cs
+++ b/src/Lucene.Net.Core/Codecs/Lucene40/Lucene40FieldInfosReader.cs
@@ -188,7 +188,7 @@ namespace Lucene.Net.Codecs.Lucene40
{"BYTES_VAR_SORTED", BYTES_VAR_SORTED}
};
- public static readonly IDictionary<string, int> ordinalLookup = new HashMap<string, int>() {
+ public static readonly IDictionary<string, int> ordinalLookup = new HashMap<string, int>(14) {
{"NONE", 0},
{"VAR_INTS", 1},
{"FLOAT_32", 2},
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a37fd381/src/Lucene.Net.Core/Index/BufferedUpdates.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Index/BufferedUpdates.cs b/src/Lucene.Net.Core/Index/BufferedUpdates.cs
index 383b6ff..2d507d3 100644
--- a/src/Lucene.Net.Core/Index/BufferedUpdates.cs
+++ b/src/Lucene.Net.Core/Index/BufferedUpdates.cs
@@ -246,8 +246,7 @@ namespace Lucene.Net.Index
public virtual void AddNumericUpdate(NumericDocValuesUpdate update, int docIDUpto)
{
- /*Linked*/
- HashMap<Term, NumericDocValuesUpdate> fieldUpdates;
+ /*Linked*/HashMap<Term, NumericDocValuesUpdate> fieldUpdates;
if (!NumericUpdates.TryGetValue(update.Field, out fieldUpdates))
{
fieldUpdates = new /*Linked*/HashMap<Term, NumericDocValuesUpdate>();
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a37fd381/src/Lucene.Net.Core/Search/Query.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Search/Query.cs b/src/Lucene.Net.Core/Search/Query.cs
index 6111cba..7ff1367 100644
--- a/src/Lucene.Net.Core/Search/Query.cs
+++ b/src/Lucene.Net.Core/Search/Query.cs
@@ -48,24 +48,17 @@ namespace Lucene.Net.Search
/// </summary>
public abstract class Query : ICloneable
{
- private float boost = 1.0f; // query boost factor
+ protected Query()
+ {
+ Boost = 1.0f; // query boost factor
+ }
/// <summary>
/// Sets the boost for this query clause to <code>b</code>. Documents
/// matching this clause will (in addition to the normal weightings) have
/// their score multiplied by <code>b</code>.
/// </summary>
- public virtual float Boost
- {
- set
- {
- boost = value;
- }
- get
- {
- return boost;
- }
- }
+ public float Boost { get; set; }
/// <summary>
/// Prints a query to a string, with <code>field</code> assumed to be the
@@ -130,7 +123,7 @@ namespace Lucene.Net.Search
{
const int prime = 31;
int result = 1;
- result = prime * result + Number.FloatToIntBits(boost);
+ result = prime * result + Number.FloatToIntBits(Boost);
return result;
}
@@ -140,16 +133,13 @@ namespace Lucene.Net.Search
{
return true;
}
- if (obj == null)
- {
- return false;
- }
- if (this.GetType() != obj.GetType())
+ var other = obj as Query;
+ if (other == null)
{
return false;
}
- var other = (Query)obj;
- if (Number.FloatToIntBits(boost) != Number.FloatToIntBits(other.boost))
+
+ if (Number.FloatToIntBits(Boost) != Number.FloatToIntBits(other.Boost))
{
return false;
}
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a37fd381/src/Lucene.Net.Core/Support/HashMap.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Support/HashMap.cs b/src/Lucene.Net.Core/Support/HashMap.cs
index 766447c..addd506 100644
--- a/src/Lucene.Net.Core/Support/HashMap.cs
+++ b/src/Lucene.Net.Core/Support/HashMap.cs
@@ -65,7 +65,7 @@ namespace Lucene.Net.Support
private TValue _nullValue;
// Indicates the type of key is a non-nullable valuetype
- private bool _isValueType;
+ private readonly bool _isValueType;
public HashMap()
: this(0)
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a37fd381/src/Lucene.Net.Core/Support/Number.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Support/Number.cs b/src/Lucene.Net.Core/Support/Number.cs
index 2738278..13bf69e 100644
--- a/src/Lucene.Net.Core/Support/Number.cs
+++ b/src/Lucene.Net.Core/Support/Number.cs
@@ -416,8 +416,15 @@ namespace Lucene.Net.Support
return BitConverter.ToSingle(BitConverter.GetBytes(value), 0);
}
+ public static int FloatToRawIntBits(float value)
+ {
+ // TODO: does this handle NaNs the same?
+ return BitConverter.ToInt32(BitConverter.GetBytes(value), 0);
+ }
+
public static int FloatToIntBits(float value)
{
+ // TODO it is claimed that this could be faster
return BitConverter.ToInt32(BitConverter.GetBytes(value), 0);
}
@@ -426,6 +433,11 @@ namespace Lucene.Net.Support
return BitConverter.ToInt64(BitConverter.GetBytes(value), 0);
}
+ public static long DoubleToRawLongBits(double value)
+ {
+ return BitConverter.DoubleToInt64Bits(value);
+ }
+
//Flips the endianness from Little-Endian to Big-Endian
//2 bytes
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a37fd381/src/Lucene.Net.Core/Support/WeakDictionary.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Support/WeakDictionary.cs b/src/Lucene.Net.Core/Support/WeakDictionary.cs
index a5e78b8..454d4df 100644
--- a/src/Lucene.Net.Core/Support/WeakDictionary.cs
+++ b/src/Lucene.Net.Core/Support/WeakDictionary.cs
@@ -55,7 +55,7 @@ namespace Lucene.Net.Support
private void Clean()
{
if (_hm.Count == 0) return;
- var newHm = new HashMap<WeakKey<TKey>, TValue>();
+ var newHm = new HashMap<WeakKey<TKey>, TValue>(_hm.Count);
foreach (var entry in _hm.Where(x => x.Key != null && x.Key.IsAlive))
{
newHm.Add(entry.Key, entry.Value);
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a37fd381/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 dae6329..d3f289b 100644
--- a/src/Lucene.Net.Core/Util/RamUsageEstimator.cs
+++ b/src/Lucene.Net.Core/Util/RamUsageEstimator.cs
@@ -93,7 +93,7 @@ namespace Lucene.Net.Util
static RamUsageEstimator()
{
- PrimitiveSizes = new HashMap<Type, int>();
+ PrimitiveSizes = new HashMap<Type, int>(8);
PrimitiveSizes[typeof(bool)] = Convert.ToInt32(NUM_BYTES_BOOLEAN);
PrimitiveSizes[typeof(sbyte)] = Convert.ToInt32(NUM_BYTES_BYTE);
PrimitiveSizes[typeof(char)] = Convert.ToInt32(NUM_BYTES_CHAR);
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a37fd381/src/Lucene.Net.Queries/CustomScoreQuery.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Queries/CustomScoreQuery.cs b/src/Lucene.Net.Queries/CustomScoreQuery.cs
index 490d351..a408361 100644
--- a/src/Lucene.Net.Queries/CustomScoreQuery.cs
+++ b/src/Lucene.Net.Queries/CustomScoreQuery.cs
@@ -83,7 +83,7 @@ namespace Lucene.Net.Queries
Query sq = subQuery.Rewrite(reader);
if (sq != subQuery)
{
- clone = Clone();
+ clone = (CustomScoreQuery)Clone();
clone.subQuery = sq;
}
@@ -94,7 +94,7 @@ namespace Lucene.Net.Queries
{
if (clone == null)
{
- clone = Clone();
+ clone = (CustomScoreQuery)Clone();
}
clone.scoringQueries[i] = v;
}
@@ -224,7 +224,7 @@ namespace Lucene.Net.Queries
{
if (qStrict)
{
- valSrcWeight.ValueForNormalization;
+ var _ = valSrcWeight.ValueForNormalization;
// do not include ValueSource part in the query normalization
}
else
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a37fd381/src/Lucene.Net.Queries/Function/BoostedQuery.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Queries/Function/BoostedQuery.cs b/src/Lucene.Net.Queries/Function/BoostedQuery.cs
index 1798987..fc078c7 100644
--- a/src/Lucene.Net.Queries/Function/BoostedQuery.cs
+++ b/src/Lucene.Net.Queries/Function/BoostedQuery.cs
@@ -134,7 +134,7 @@ namespace Lucene.Net.Queries.Function
public override Explanation Explain(AtomicReaderContext readerContext, int doc)
{
Explanation subQueryExpl = qWeight.Explain(readerContext, doc);
- if (!subQueryExpl.Match)
+ if (!subQueryExpl.IsMatch)
{
return subQueryExpl;
}
@@ -207,8 +207,6 @@ namespace Lucene.Net.Queries.Function
}
}
- //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
- //ORIGINAL LINE: public Explanation explain(int doc) throws java.io.IOException
public virtual Explanation explain(int doc)
{
Explanation subQueryExpl = weight.qWeight.Explain(readerContext, doc);
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a37fd381/src/Lucene.Net.Queries/Lucene.Net.Queries.csproj
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Queries/Lucene.Net.Queries.csproj b/src/Lucene.Net.Queries/Lucene.Net.Queries.csproj
index 4755eab..e44d734 100644
--- a/src/Lucene.Net.Queries/Lucene.Net.Queries.csproj
+++ b/src/Lucene.Net.Queries/Lucene.Net.Queries.csproj
@@ -35,11 +35,7 @@
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
- <Reference Include="System.Xml.Linq" />
- <Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
- <Reference Include="System.Data" />
- <Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="BooleanFilter.cs" />