lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From paulir...@apache.org
Subject [28/53] [abbrv] git commit: Port Facet.Params
Date Thu, 07 Nov 2013 13:53:43 GMT
Port Facet.Params


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

Branch: refs/heads/branch_4x
Commit: 5be6151351d6b5643a45fd334df2cf2b4c33a519
Parents: 9184d14
Author: Paul Irwin <paulirwin@gmail.com>
Authored: Sun Nov 3 19:01:32 2013 -0500
Committer: Paul Irwin <paulirwin@gmail.com>
Committed: Sun Nov 3 19:01:32 2013 -0500

----------------------------------------------------------------------
 src/contrib/Facet/Contrib.Facet.csproj          |  3 ++
 src/contrib/Facet/Params/FacetSearchParams.cs   | 55 ++++++++++++++++++++
 .../Facet/Params/PerDimensionIndexingParams.cs  | 54 +++++++++++++++++++
 .../Facet/Params/PerDimensionOrdinalPolicy.cs   | 35 +++++++++++++
 4 files changed, 147 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/5be61513/src/contrib/Facet/Contrib.Facet.csproj
----------------------------------------------------------------------
diff --git a/src/contrib/Facet/Contrib.Facet.csproj b/src/contrib/Facet/Contrib.Facet.csproj
index f6dc66e..ff48e89 100644
--- a/src/contrib/Facet/Contrib.Facet.csproj
+++ b/src/contrib/Facet/Contrib.Facet.csproj
@@ -49,6 +49,9 @@
     <Compile Include="Encoding\UniqueValuesIntEncoder.cs" />
     <Compile Include="Params\CategoryListParams.cs" />
     <Compile Include="Params\FacetIndexingParams.cs" />
+    <Compile Include="Params\FacetSearchParams.cs" />
+    <Compile Include="Params\PerDimensionIndexingParams.cs" />
+    <Compile Include="Params\PerDimensionOrdinalPolicy.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="Search\DocValuesCategoryListIterator.cs" />
     <Compile Include="Search\FacetArrays.cs" />

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/5be61513/src/contrib/Facet/Params/FacetSearchParams.cs
----------------------------------------------------------------------
diff --git a/src/contrib/Facet/Params/FacetSearchParams.cs b/src/contrib/Facet/Params/FacetSearchParams.cs
new file mode 100644
index 0000000..17f911d
--- /dev/null
+++ b/src/contrib/Facet/Params/FacetSearchParams.cs
@@ -0,0 +1,55 @@
+using Lucene.Net.Facet.Search;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace Lucene.Net.Facet.Params
+{
+    public class FacetSearchParams
+    {
+        public readonly FacetIndexingParams indexingParams;
+        public readonly IList<FacetRequest> facetRequests;
+
+        public FacetSearchParams(params FacetRequest[] facetRequests)
+            : this(FacetIndexingParams.DEFAULT, facetRequests)
+        {
+        }
+
+        public FacetSearchParams(IList<FacetRequest> facetRequests)
+            : this(FacetIndexingParams.DEFAULT, facetRequests)
+        {
+        }
+
+        public FacetSearchParams(FacetIndexingParams indexingParams, params FacetRequest[]
facetRequests)
+            : this(indexingParams, facetRequests.ToList())
+        {
+        }
+
+        public FacetSearchParams(FacetIndexingParams indexingParams, IList<FacetRequest>
facetRequests)
+        {
+            if (facetRequests == null || facetRequests.Count == 0)
+            {
+                throw new ArgumentException("at least one FacetRequest must be defined");
+            }
+
+            this.facetRequests = facetRequests;
+            this.indexingParams = indexingParams;
+        }
+
+        public override string ToString()
+        {
+            string INDENT = "  ";
+            char NEWLINE = '\n';
+            StringBuilder sb = new StringBuilder("IndexingParams: ");
+            sb.Append(NEWLINE).Append(INDENT).Append(indexingParams);
+            sb.Append(NEWLINE).Append("FacetRequests:");
+            foreach (FacetRequest facetRequest in facetRequests)
+            {
+                sb.Append(NEWLINE).Append(INDENT).Append(facetRequest);
+            }
+
+            return sb.ToString();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/5be61513/src/contrib/Facet/Params/PerDimensionIndexingParams.cs
----------------------------------------------------------------------
diff --git a/src/contrib/Facet/Params/PerDimensionIndexingParams.cs b/src/contrib/Facet/Params/PerDimensionIndexingParams.cs
new file mode 100644
index 0000000..cff2387
--- /dev/null
+++ b/src/contrib/Facet/Params/PerDimensionIndexingParams.cs
@@ -0,0 +1,54 @@
+using Lucene.Net.Facet.Taxonomy;
+using Lucene.Net.Support;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace Lucene.Net.Facet.Params
+{
+    public class PerDimensionIndexingParams : FacetIndexingParams
+    {
+        private readonly IDictionary<String, CategoryListParams> clParamsMap;
+
+        public PerDimensionIndexingParams(IDictionary<CategoryPath, CategoryListParams>
paramsMap)
+            : this(paramsMap, DEFAULT_CATEGORY_LIST_PARAMS)
+        {
+        }
+
+        public PerDimensionIndexingParams(IDictionary<CategoryPath, CategoryListParams>
paramsMap, 
+            CategoryListParams categoryListParams)
+            : base(categoryListParams)
+        {
+            clParamsMap = new HashMap<String, CategoryListParams>();
+            foreach (KeyValuePair<CategoryPath, CategoryListParams> e in paramsMap)
+            {
+                clParamsMap[e.Key.components[0]] = e.Value;
+            }
+        }
+
+        public override IList<CategoryListParams> AllCategoryListParams
+        {
+            get
+            {
+                List<CategoryListParams> vals = new List<CategoryListParams>(clParamsMap.Values);
+                vals.Add(clParams);
+                return vals;
+            }
+        }
+
+        public override CategoryListParams GetCategoryListParams(CategoryPath category)
+        {
+            if (category != null)
+            {
+                CategoryListParams clParams = clParamsMap[category.components[0]];
+                if (clParams != null)
+                {
+                    return clParams;
+                }
+            }
+
+            return null;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/5be61513/src/contrib/Facet/Params/PerDimensionOrdinalPolicy.cs
----------------------------------------------------------------------
diff --git a/src/contrib/Facet/Params/PerDimensionOrdinalPolicy.cs b/src/contrib/Facet/Params/PerDimensionOrdinalPolicy.cs
new file mode 100644
index 0000000..021ecd1
--- /dev/null
+++ b/src/contrib/Facet/Params/PerDimensionOrdinalPolicy.cs
@@ -0,0 +1,35 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace Lucene.Net.Facet.Params
+{
+    public class PerDimensionOrdinalPolicy : CategoryListParams
+    {
+        private readonly IDictionary<String, OrdinalPolicy> policies;
+        private readonly OrdinalPolicy defaultOP;
+
+        public PerDimensionOrdinalPolicy(IDictionary<String, OrdinalPolicy> policies)
+            : this(policies, DEFAULT_ORDINAL_POLICY)
+        {
+        }
+
+        public PerDimensionOrdinalPolicy(IDictionary<String, OrdinalPolicy> policies,
OrdinalPolicy defaultOP)
+        {
+            this.defaultOP = defaultOP;
+            this.policies = policies;
+        }
+
+        public override OrdinalPolicy GetOrdinalPolicy(string dimension)
+        {
+            OrdinalPolicy op = policies[dimension];
+            return op == null ? defaultOP : op;
+        }
+
+        public override string ToString()
+        {
+            return base.ToString() + @" policies=" + policies;
+        }
+    }
+}


Mime
View raw message