lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From paulir...@apache.org
Subject [24/53] [abbrv] git commit: Start of work on Facet
Date Thu, 07 Nov 2013 13:53:39 GMT
Start of work on Facet


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

Branch: refs/heads/branch_4x
Commit: d68aa4f77dc4a37c5fc513ceb753f448c50fb13c
Parents: 74e62b2
Author: Paul Irwin <paulirwin@gmail.com>
Authored: Wed Oct 30 16:43:36 2013 -0400
Committer: Paul Irwin <paulirwin@gmail.com>
Committed: Wed Oct 30 16:43:36 2013 -0400

----------------------------------------------------------------------
 build/vs2012/Lucene.Net.All/Lucene.Net.All.sln  |  11 +
 src/contrib/Facet/Contrib.Facet.csproj          |  64 ++++++
 src/contrib/Facet/Properties/AssemblyInfo.cs    |  36 +++
 src/contrib/Facet/Search/FacetArrays.cs         |  60 +++++
 src/contrib/Facet/Search/FacetRequest.cs        | 143 ++++++++++++
 src/contrib/Facet/Search/IAggregator.cs         |  15 ++
 src/contrib/Facet/Taxonomy/CategoryPath.cs      | 229 +++++++++++++++++++
 .../Facet/Taxonomy/ParallelTaxonomyArrays.cs    |  14 ++
 src/contrib/Facet/Taxonomy/TaxonomyReader.cs    | 147 ++++++++++++
 .../QueryParsers/Contrib.QueryParsers.csproj    |   2 +-
 10 files changed, 720 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/d68aa4f7/build/vs2012/Lucene.Net.All/Lucene.Net.All.sln
----------------------------------------------------------------------
diff --git a/build/vs2012/Lucene.Net.All/Lucene.Net.All.sln b/build/vs2012/Lucene.Net.All/Lucene.Net.All.sln
index c413839..833fb8d 100644
--- a/build/vs2012/Lucene.Net.All/Lucene.Net.All.sln
+++ b/build/vs2012/Lucene.Net.All/Lucene.Net.All.sln
@@ -39,6 +39,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Contrib.QueryParsers",
"..\
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Contrib.Sandbox", "..\..\..\src\contrib\Sandbox\Contrib.Sandbox.csproj",
"{1DE43B60-4041-4A2E-9717-5B4CA891D0FD}"
 EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Contrib.Facet", "..\..\..\src\contrib\Facet\Contrib.Facet.csproj",
"{CAA4EAA9-C055-4E90-86F3-CB154CC22ADD}"
+EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Any CPU = Debug|Any CPU
@@ -183,6 +185,14 @@ Global
 		{1DE43B60-4041-4A2E-9717-5B4CA891D0FD}.Release|Any CPU.Build.0 = Release|Any CPU
 		{1DE43B60-4041-4A2E-9717-5B4CA891D0FD}.Release35|Any CPU.ActiveCfg = Release|Any CPU
 		{1DE43B60-4041-4A2E-9717-5B4CA891D0FD}.Release35|Any CPU.Build.0 = Release|Any CPU
+		{CAA4EAA9-C055-4E90-86F3-CB154CC22ADD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{CAA4EAA9-C055-4E90-86F3-CB154CC22ADD}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{CAA4EAA9-C055-4E90-86F3-CB154CC22ADD}.Debug35|Any CPU.ActiveCfg = Debug|Any CPU
+		{CAA4EAA9-C055-4E90-86F3-CB154CC22ADD}.Debug35|Any CPU.Build.0 = Debug|Any CPU
+		{CAA4EAA9-C055-4E90-86F3-CB154CC22ADD}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{CAA4EAA9-C055-4E90-86F3-CB154CC22ADD}.Release|Any CPU.Build.0 = Release|Any CPU
+		{CAA4EAA9-C055-4E90-86F3-CB154CC22ADD}.Release35|Any CPU.ActiveCfg = Release|Any CPU
+		{CAA4EAA9-C055-4E90-86F3-CB154CC22ADD}.Release35|Any CPU.Build.0 = Release|Any CPU
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE
@@ -205,5 +215,6 @@ Global
 		{7563D4D9-AE91-42BA-A270-1D264660F6DF} = {7E19085A-545B-4DE8-BBF5-B1DBC370FD37}
 		{56438272-B00E-40DE-9C9A-0785E705E7D9} = {7E19085A-545B-4DE8-BBF5-B1DBC370FD37}
 		{1DE43B60-4041-4A2E-9717-5B4CA891D0FD} = {7E19085A-545B-4DE8-BBF5-B1DBC370FD37}
+		{CAA4EAA9-C055-4E90-86F3-CB154CC22ADD} = {7E19085A-545B-4DE8-BBF5-B1DBC370FD37}
 	EndGlobalSection
 EndGlobal

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/d68aa4f7/src/contrib/Facet/Contrib.Facet.csproj
----------------------------------------------------------------------
diff --git a/src/contrib/Facet/Contrib.Facet.csproj b/src/contrib/Facet/Contrib.Facet.csproj
new file mode 100644
index 0000000..c8eb8c8
--- /dev/null
+++ b/src/contrib/Facet/Contrib.Facet.csproj
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props"
Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')"
/>
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{CAA4EAA9-C055-4E90-86F3-CB154CC22ADD}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>Lucene.Net.Facet</RootNamespace>
+    <AssemblyName>Lucene.Net.Contrib.Facet</AssemblyName>
+    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <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="Properties\AssemblyInfo.cs" />
+    <Compile Include="Search\FacetArrays.cs" />
+    <Compile Include="Search\FacetRequest.cs" />
+    <Compile Include="Search\IAggregator.cs" />
+    <Compile Include="Taxonomy\CategoryPath.cs" />
+    <Compile Include="Taxonomy\ParallelTaxonomyArrays.cs" />
+    <Compile Include="Taxonomy\TaxonomyReader.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\..\core\Lucene.Net.csproj">
+      <Project>{5d4ad9be-1ffb-41ab-9943-25737971bf57}</Project>
+      <Name>Lucene.Net</Name>
+    </ProjectReference>
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <!-- To modify your build process, add your task inside one of the targets below and
uncomment it. 
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/d68aa4f7/src/contrib/Facet/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/src/contrib/Facet/Properties/AssemblyInfo.cs b/src/contrib/Facet/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..4c8fac3
--- /dev/null
+++ b/src/contrib/Facet/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following 
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("Contrib.Facet")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("Contrib.Facet")]
+[assembly: AssemblyCopyright("Copyright ©  2013")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible 
+// to COM components.  If you need to access a type in this assembly from 
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("61d29091-6ac2-49de-a25b-71f76b3c480f")]
+
+// Version information for an assembly consists of the following four values:
+//
+//      Major Version
+//      Minor Version 
+//      Build Number
+//      Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers 
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/d68aa4f7/src/contrib/Facet/Search/FacetArrays.cs
----------------------------------------------------------------------
diff --git a/src/contrib/Facet/Search/FacetArrays.cs b/src/contrib/Facet/Search/FacetArrays.cs
new file mode 100644
index 0000000..982d452
--- /dev/null
+++ b/src/contrib/Facet/Search/FacetArrays.cs
@@ -0,0 +1,60 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace Lucene.Net.Facet.Search
+{
+    public class FacetArrays
+    {
+        private int[] ints;
+        private float[] floats;
+        public readonly int arrayLength;
+
+        public FacetArrays(int arrayLength)
+        {
+            this.arrayLength = arrayLength;
+        }
+
+        protected virtual float[] NewFloatArray()
+        {
+            return new float[arrayLength];
+        }
+
+        protected virtual int[] NewIntArray()
+        {
+            return new int[arrayLength];
+        }
+
+        protected virtual void DoFree(float[] floats, int[] ints)
+        {
+        }
+
+        public void Free()
+        {
+            DoFree(floats, ints);
+            ints = null;
+            floats = null;
+        }
+
+        public int[] GetIntArray()
+        {
+            if (ints == null)
+            {
+                ints = NewIntArray();
+            }
+
+            return ints;
+        }
+
+        public float[] GetFloatArray()
+        {
+            if (floats == null)
+            {
+                floats = NewFloatArray();
+            }
+
+            return floats;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/d68aa4f7/src/contrib/Facet/Search/FacetRequest.cs
----------------------------------------------------------------------
diff --git a/src/contrib/Facet/Search/FacetRequest.cs b/src/contrib/Facet/Search/FacetRequest.cs
new file mode 100644
index 0000000..7e14cb8
--- /dev/null
+++ b/src/contrib/Facet/Search/FacetRequest.cs
@@ -0,0 +1,143 @@
+using Lucene.Net.Facet.Taxonomy;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace Lucene.Net.Facet.Search
+{
+    public abstract class FacetRequest
+    {
+        public enum ResultMode
+        {
+            PER_NODE_IN_TREE,
+            GLOBAL_FLAT
+        }
+
+        public enum FacetArraysSource
+        {
+            INT,
+            FLOAT,
+            BOTH
+        }
+
+        public enum SortOrder
+        {
+            ASCENDING,
+            DESCENDING
+        }
+
+        public static readonly int DEFAULT_DEPTH = 1;
+        public static readonly ResultMode DEFAULT_RESULT_MODE = ResultMode.PER_NODE_IN_TREE;
+        public readonly CategoryPath categoryPath;
+        public readonly int numResults;
+        private int numLabel;
+        private int depth;
+        private SortOrder sortOrder;
+        private readonly int hashCode;
+        private ResultMode resultMode = DEFAULT_RESULT_MODE;
+
+        public FacetRequest(CategoryPath path, int numResults)
+        {
+            if (numResults <= 0)
+            {
+                throw new ArgumentException(@"num results must be a positive (>0) number:
" + numResults);
+            }
+
+            if (path == null)
+            {
+                throw new ArgumentException(@"category path cannot be null!");
+            }
+
+            categoryPath = path;
+            this.numResults = numResults;
+            numLabel = numResults;
+            depth = DEFAULT_DEPTH;
+            sortOrder = SortOrder.DESCENDING;
+            hashCode = categoryPath.GetHashCode() ^ this.numResults;
+        }
+
+        public virtual IAggregator CreateAggregator(bool useComplements, FacetArrays arrays,
TaxonomyReader taxonomy)
+        {
+            throw new NotSupportedException(@"this FacetRequest does not support this type
of Aggregator anymore; " + @"you should override FacetsAccumulator to return the proper FacetsAggregator");
+        }
+
+        public override bool Equals(Object o)
+        {
+            if (o is FacetRequest)
+            {
+                FacetRequest that = (FacetRequest)o;
+                return that.hashCode == this.hashCode 
+                    && that.categoryPath.Equals(this.categoryPath) 
+                    && that.numResults == this.numResults 
+                    && that.depth == this.depth 
+                    && that.resultMode == this.resultMode 
+                    && that.numLabel == this.numLabel;
+            }
+
+            return false;
+        }
+
+        public virtual int Depth
+        {
+            get
+            {
+                return depth;
+            }
+            set
+            {
+                this.depth = value;
+            }
+        }
+
+        public abstract FacetArraysSource FacetArraysSourceValue { get; }
+
+        public virtual int NumLabel
+        {
+            get
+            {
+                return numLabel;
+            }
+            set
+            {
+                this.numLabel = value;
+            }
+        }
+
+        public virtual ResultMode ResultModeValue
+        {
+            get
+            {
+                return resultMode;
+            }
+            set
+            {
+                this.resultMode = value;
+            }
+        }
+
+        public virtual SortOrder SortOrderValue
+        {
+            get
+            {
+                return sortOrder;
+            }
+            set
+            {
+                this.sortOrder = value;
+            }
+        }
+
+        public abstract double GetValueOf(FacetArrays arrays, int idx);
+
+        public override int GetHashCode()
+        {
+            return hashCode;
+        }
+
+        public override string ToString()
+        {
+            return categoryPath.ToString() + @" nRes=" + numResults + @" nLbl=" + numLabel;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/d68aa4f7/src/contrib/Facet/Search/IAggregator.cs
----------------------------------------------------------------------
diff --git a/src/contrib/Facet/Search/IAggregator.cs b/src/contrib/Facet/Search/IAggregator.cs
new file mode 100644
index 0000000..1873ad3
--- /dev/null
+++ b/src/contrib/Facet/Search/IAggregator.cs
@@ -0,0 +1,15 @@
+using Lucene.Net.Index;
+using Lucene.Net.Util;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace Lucene.Net.Facet.Search
+{
+    public interface IAggregator
+    {
+        bool SetNextReader(AtomicReaderContext context);
+        void Aggregate(int docID, float score, IntsRef ordinals);
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/d68aa4f7/src/contrib/Facet/Taxonomy/CategoryPath.cs
----------------------------------------------------------------------
diff --git a/src/contrib/Facet/Taxonomy/CategoryPath.cs b/src/contrib/Facet/Taxonomy/CategoryPath.cs
new file mode 100644
index 0000000..9d88cd5
--- /dev/null
+++ b/src/contrib/Facet/Taxonomy/CategoryPath.cs
@@ -0,0 +1,229 @@
+using Lucene.Net.Support;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Text.RegularExpressions;
+
+namespace Lucene.Net.Facet.Taxonomy
+{
+    public class CategoryPath : IComparable<CategoryPath>
+    {
+        public static readonly CategoryPath EMPTY = new CategoryPath();
+        public readonly String[] components;
+        public readonly int length;
+
+        private CategoryPath()
+        {
+            components = null;
+            length = 0;
+        }
+
+        private CategoryPath(CategoryPath copyFrom, int prefixLen)
+        {
+            this.components = copyFrom.components;
+            length = prefixLen;
+        }
+
+        public CategoryPath(params string[] components)
+        {
+            foreach (string comp in components)
+            {
+                if (string.IsNullOrEmpty(comp))
+                {
+                    throw new ArgumentException(@"empty or null components not allowed: "
+ Arrays.ToString(components));
+                }
+            }
+
+            this.components = components;
+            length = components.Length;
+        }
+
+        public CategoryPath(string pathString, char delimiter)
+        {
+            String[] comps = pathString.Split(new[] { Regex.Escape(delimiter.ToString())
}, StringSplitOptions.None);
+            if (comps.Length == 1 && string.IsNullOrEmpty(comps[0]))
+            {
+                components = null;
+                length = 0;
+            }
+            else
+            {
+                foreach (string comp in comps)
+                {
+                    if (string.IsNullOrEmpty(comp))
+                    {
+                        throw new ArgumentException(@"empty or null components not allowed:
" + Arrays.ToString(comps));
+                    }
+                }
+
+                components = comps;
+                length = components.Length;
+            }
+        }
+
+        public virtual int FullPathLength()
+        {
+            if (length == 0)
+                return 0;
+            int charsNeeded = 0;
+            for (int i = 0; i < length; i++)
+            {
+                charsNeeded += components[i].Length;
+            }
+
+            charsNeeded += length - 1;
+            return charsNeeded;
+        }
+
+        public int CompareTo(CategoryPath other)
+        {
+            int len = length < other.length ? length : other.length;
+            for (int i = 0, j = 0; i < len; i++, j++)
+            {
+                int cmp = components[i].CompareTo(other.components[j]);
+                if (cmp < 0)
+                    return -1;
+                if (cmp > 0)
+                    return 1;
+            }
+
+            return length - other.length;
+        }
+
+        private void HasDelimiter(string offender, char delimiter)
+        {
+            throw new ArgumentException(@"delimiter character '" + delimiter + @"' (U+" +
Convert.ToString((int)delimiter, 16) + @") appears in path component \" + offender + @"\");
+        }
+
+        private void NoDelimiter(char[] buf, int offset, int len, char delimiter)
+        {
+            for (int idx = 0; idx < len; idx++)
+            {
+                if (buf[offset + idx] == delimiter)
+                {
+                    HasDelimiter(new string(buf, offset, len), delimiter);
+                }
+            }
+        }
+
+        public virtual int CopyFullPath(char[] buf, int start, char delimiter)
+        {
+            if (length == 0)
+            {
+                return 0;
+            }
+
+            int idx = start;
+            int upto = length - 1;
+            for (int i = 0; i < upto; i++)
+            {
+                int len = components[i].Length;
+                components[i].CopyTo(0, buf, idx, len); //.GetChars(0, len, buf, idx);
+                NoDelimiter(buf, idx, len, delimiter);
+                idx += len;
+                buf[idx++] = delimiter;
+            }
+
+            components[upto].CopyTo(0, buf, idx, components[upto].Length); //.GetChars(0,
components[upto].Length(), buf, idx);
+            NoDelimiter(buf, idx, components[upto].Length, delimiter);
+            return idx + components[upto].Length - start;
+        }
+
+        public override bool Equals(Object obj)
+        {
+            if (!(obj is CategoryPath))
+            {
+                return false;
+            }
+
+            CategoryPath other = (CategoryPath)obj;
+            if (length != other.length)
+            {
+                return false;
+            }
+
+            for (int i = length - 1; i >= 0; i--)
+            {
+                if (!components[i].Equals(other.components[i]))
+                {
+                    return false;
+                }
+            }
+
+            return true;
+        }
+
+        public override int GetHashCode()
+        {
+            if (length == 0)
+            {
+                return 0;
+            }
+
+            int hash = length;
+            for (int i = 0; i < length; i++)
+            {
+                hash = hash * 31 + components[i].GetHashCode();
+            }
+
+            return hash;
+        }
+
+        public virtual long LongHashCode()
+        {
+            if (length == 0)
+            {
+                return 0;
+            }
+
+            long hash = length;
+            for (int i = 0; i < length; i++)
+            {
+                hash = hash * 65599 + components[i].GetHashCode();
+            }
+
+            return hash;
+        }
+
+        public virtual CategoryPath Subpath(int length)
+        {
+            if (length >= this.length || length < 0)
+            {
+                return this;
+            }
+            else if (length == 0)
+            {
+                return EMPTY;
+            }
+            else
+            {
+                return new CategoryPath(this, length);
+            }
+        }
+
+        public override string ToString()
+        {
+            return ToString('/');
+        }
+
+        public virtual string ToString(char delimiter)
+        {
+            if (length == 0)
+                return @"";
+            StringBuilder sb = new StringBuilder();
+            for (int i = 0; i < length; i++)
+            {
+                if (components[i].IndexOf(delimiter) != -1)
+                {
+                    HasDelimiter(components[i], delimiter);
+                }
+
+                sb.Append(components[i]).Append(delimiter);
+            }
+
+            sb.Remove(sb.Length - 1, 1);
+            return sb.ToString();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/d68aa4f7/src/contrib/Facet/Taxonomy/ParallelTaxonomyArrays.cs
----------------------------------------------------------------------
diff --git a/src/contrib/Facet/Taxonomy/ParallelTaxonomyArrays.cs b/src/contrib/Facet/Taxonomy/ParallelTaxonomyArrays.cs
new file mode 100644
index 0000000..48eee9b
--- /dev/null
+++ b/src/contrib/Facet/Taxonomy/ParallelTaxonomyArrays.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace Lucene.Net.Facet.Taxonomy
+{
+    public abstract class ParallelTaxonomyArrays
+    {
+        public abstract int[] Parents { get; }
+        public abstract int[] Children { get; }
+        public abstract int[] Siblings { get; }
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/d68aa4f7/src/contrib/Facet/Taxonomy/TaxonomyReader.cs
----------------------------------------------------------------------
diff --git a/src/contrib/Facet/Taxonomy/TaxonomyReader.cs b/src/contrib/Facet/Taxonomy/TaxonomyReader.cs
new file mode 100644
index 0000000..c7fe08e
--- /dev/null
+++ b/src/contrib/Facet/Taxonomy/TaxonomyReader.cs
@@ -0,0 +1,147 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading;
+
+namespace Lucene.Net.Facet.Taxonomy
+{
+    public abstract class TaxonomyReader : IDisposable
+    {
+        public class ChildrenIterator
+        {
+            private readonly int[] siblings;
+            private int child;
+
+            internal ChildrenIterator(int child, int[] siblings)
+            {
+                this.siblings = siblings;
+                this.child = child;
+            }
+
+            public virtual int Next()
+            {
+                int res = child;
+                if (child != TaxonomyReader.INVALID_ORDINAL)
+                {
+                    child = siblings[child];
+                }
+
+                return res;
+            }
+        }
+
+        public const int ROOT_ORDINAL = 0;
+        public const int INVALID_ORDINAL = -1;
+
+        public static T OpenIfChanged<T>(T oldTaxoReader)
+            where T : TaxonomyReader
+        {
+            T newTaxoReader = (T)oldTaxoReader.DoOpenIfChanged();
+            return newTaxoReader;
+        }
+
+        private volatile bool closed = false;
+
+        private int refCount = 1;
+
+        protected abstract void DoClose();
+
+        protected abstract TaxonomyReader DoOpenIfChanged();
+
+        protected void EnsureOpen()
+        {
+            if (RefCount <= 0)
+            {
+                throw new ObjectDisposedException(@"this TaxonomyReader is closed");
+            }
+        }
+
+        public void Dispose()
+        {
+            if (!closed)
+            {
+                lock (this)
+                {
+                    if (!closed)
+                    {
+                        DecRef();
+                        closed = true;
+                    }
+                }
+            }
+        }
+
+        public void DecRef()
+        {
+            EnsureOpen();
+            int rc = Interlocked.Decrement(ref refCount);
+            if (rc == 0)
+            {
+                bool success = false;
+                try
+                {
+                    DoClose();
+                    closed = true;
+                    success = true;
+                }
+                finally
+                {
+                    if (!success)
+                    {
+                        Interlocked.Increment(ref refCount);
+                    }
+                }
+            }
+            else if (rc < 0)
+            {
+                throw new InvalidOperationException(@"too many decRef calls: refCount is
" + rc + @" after decrement");
+            }
+        }
+
+        public abstract ParallelTaxonomyArrays GetParallelTaxonomyArrays();
+
+        public virtual ChildrenIterator GetChildren(int ordinal)
+        {
+            ParallelTaxonomyArrays arrays = GetParallelTaxonomyArrays();
+            int child = ordinal >= 0 ? arrays.Children[ordinal] : INVALID_ORDINAL;
+            return new ChildrenIterator(child, arrays.Siblings);
+        }
+
+        public abstract IDictionary<String, String> GetCommitUserData();
+
+        public abstract int GetOrdinal(CategoryPath categoryPath);
+
+        public abstract CategoryPath GetPath(int ordinal);
+
+        public int RefCount
+        {
+            get
+            {
+                return refCount;
+            }
+        }
+
+        public abstract int Size { get; }
+
+        public void IncRef()
+        {
+            EnsureOpen();
+            Interlocked.Increment(ref refCount);
+        }
+
+        public bool TryIncRef()
+        {
+            int count;
+            while ((count = refCount) > 0)
+            {
+                if (Interlocked.CompareExchange(ref refCount, count + 1, count) == count)
+                {
+                    return true;
+                }
+            }
+
+            return false;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/d68aa4f7/src/contrib/QueryParsers/Contrib.QueryParsers.csproj
----------------------------------------------------------------------
diff --git a/src/contrib/QueryParsers/Contrib.QueryParsers.csproj b/src/contrib/QueryParsers/Contrib.QueryParsers.csproj
index 421620c..afee635 100644
--- a/src/contrib/QueryParsers/Contrib.QueryParsers.csproj
+++ b/src/contrib/QueryParsers/Contrib.QueryParsers.csproj
@@ -8,7 +8,7 @@
     <OutputType>Library</OutputType>
     <AppDesignerFolder>Properties</AppDesignerFolder>
     <RootNamespace>Lucene.Net.QueryParsers</RootNamespace>
-    <AssemblyName>Contrib.QueryParsers</AssemblyName>
+    <AssemblyName>Lucene.Net.Contrib.QueryParsers</AssemblyName>
     <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
     <FileAlignment>512</FileAlignment>
     <TargetFrameworkProfile />


Mime
View raw message