├── .gitattributes ├── .gitignore ├── FxCopCustomDictionary.xml ├── LICENSE ├── Marlin.sln ├── Marlin.sln.DotSettings ├── Microsoft.HBase.Client.Tests ├── App.config ├── CellOperationsTests.cs ├── Clients │ ├── GatewayClientTest.cs │ ├── HBaseClientTestBase.cs │ └── VNetClientTest.cs ├── ClusterCredentialsFactory.cs ├── ClusterCredentialsFactoryTests.cs ├── ClusterCredentialsTests.cs ├── FilterTestRecord.cs ├── FilterTests.cs ├── Microsoft.HBase.Client.Tests.csproj ├── Properties │ └── AssemblyInfo.cs ├── PublicInternalArchitectureTests.cs ├── ScannerInformationTests.cs ├── Utilities │ ├── AssertEqualityComparer.cs │ ├── Catch.cs │ ├── ContextSpecification.cs │ ├── DisposableContextSpecification.cs │ ├── EnumerableExtensions.cs │ ├── GeneralComparisonOperator.cs │ ├── ObjectExtensions.cs │ ├── Pair.cs │ ├── SecureStringExtensions.cs │ ├── ShouldExtensionMethods.cs │ ├── StringExtensions.cs │ ├── TestAssemblyInitializeCleanup.cs │ ├── TestBase.cs │ ├── TestHelp.cs │ └── TestRunMode.cs ├── VirtualNetworkLoadBalancerTests.cs └── packages.config ├── Microsoft.HBase.Client.nuspec ├── Microsoft.HBase.Client ├── ClusterCredentials.cs ├── Exceptions │ ├── ArgumentContainsNullException.cs │ └── ArgumentEmptyException.cs ├── Filters │ ├── BinaryComparator.cs │ ├── BinaryPrefixComparator.cs │ ├── BitComparator.cs │ ├── ByteArrayComparable.cs │ ├── ColumnCountGetFilter.cs │ ├── ColumnPaginationFilter.cs │ ├── ColumnPrefixFilter.cs │ ├── ColumnRangeFilter.cs │ ├── CompareFilter.cs │ ├── DependentColumnFilter.cs │ ├── FamilyFilter.cs │ ├── Filter.cs │ ├── FilterList.cs │ ├── FirstKeyOnlyFilter.cs │ ├── InclusiveStopFilter.cs │ ├── KeyOnlyFilter.cs │ ├── MultipleColumnPrefixFilter.cs │ ├── NullComparator.cs │ ├── PageFilter.cs │ ├── PrefixFilter.cs │ ├── QualifierFilter.cs │ ├── RandomRowFilter.cs │ ├── RegexStringComparator.cs │ ├── RowFilter.cs │ ├── SingleColumnValueExcludeFilter.cs │ ├── SingleColumnValueFilter.cs │ ├── SkipFilter.cs │ ├── SubstringComparator.cs │ ├── TimestampsFilter.cs │ ├── ValueFilter.cs │ └── WhileMatchFilter.cs ├── GlobalSuppressions.cs ├── HBaseClient.cs ├── IHBaseClient.cs ├── Internal │ ├── ByteArrayEqualityComparer.cs │ ├── Extensions │ │ ├── ArgumentGuardExtensions.cs │ │ ├── ObjectExtensions.cs │ │ └── StringExtensions.cs │ ├── Helpers │ │ ├── DisposableHelp.cs │ │ └── TaskHelpers.cs │ └── ValidatedNotNullAttribute.cs ├── LoadBalancing │ ├── Constants.cs │ ├── IEndpointIgnorePolicy.cs │ ├── ILoadBalancer.cs │ ├── IgnoreFailedEndpointsPolicy.cs │ └── LoadBalancerRoundRobin.cs ├── Microsoft.HBase.Client.csproj ├── Microsoft.HBase.Client.csproj.DotSettings ├── Properties │ └── AssemblyInfo.cs ├── RequestOptions.cs ├── Requester │ ├── GatewayWebRequester.cs │ ├── IWebRequester.cs │ └── VNetWebRequester.cs ├── ScannerInformation.cs └── packages.config ├── Production.FxCop.ruleset ├── README.md ├── Test.FxCop.ruleset ├── TestSettings.testsettings └── schemas ├── ProtoBuf ├── CellMessage.proto ├── CellSetMessage.proto ├── ColumnSchemaMessage.proto ├── Generated │ ├── CellMessage.cs │ ├── CellSetMessage.cs │ ├── ColumnSchemaMessage.cs │ ├── ScannerMessage.cs │ ├── StorageClusterStatusMessage.cs │ ├── TableInfoMessage.cs │ ├── TableListMessage.cs │ ├── TableSchemaMessage.cs │ └── VersionMessage.cs ├── ProtoGen │ ├── Licence.txt │ ├── common.xslt │ ├── csharp.xslt │ ├── descriptor.proto │ ├── protobuf-net.dll │ ├── protobuf-net.xml │ ├── protoc-license.txt │ ├── protogen.exe │ ├── protogen.exe.config │ ├── vb.xslt │ └── xml.xslt ├── ScannerMessage.proto ├── StorageClusterStatusMessage.proto ├── TableInfoMessage.proto ├── TableListMessage.proto ├── TableSchemaMessage.proto └── VersionMessage.proto └── XML └── XMLSchema.xsd /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | #password files 5 | credentials.txt 6 | 7 | # User-specific files 8 | *.suo 9 | *.user 10 | *.sln.docstates 11 | 12 | # Build results 13 | [Dd]ebug/ 14 | [Dd]ebugPublic/ 15 | [Rr]elease/ 16 | x64/ 17 | build/ 18 | bld/ 19 | [Bb]in/ 20 | [Oo]bj/ 21 | 22 | # MSTest test Results 23 | [Tt]est[Rr]esult*/ 24 | [Bb]uild[Ll]og.* 25 | 26 | #NUNIT 27 | *.VisualState.xml 28 | TestResult.xml 29 | 30 | # Build Results of an ATL Project 31 | [Dd]ebugPS/ 32 | [Rr]eleasePS/ 33 | dlldata.c 34 | 35 | *_i.c 36 | *_p.c 37 | *_i.h 38 | *.ilk 39 | *.meta 40 | *.obj 41 | *.pch 42 | *.pdb 43 | *.pgc 44 | *.pgd 45 | *.rsp 46 | *.sbr 47 | *.tlb 48 | *.tli 49 | *.tlh 50 | *.tmp 51 | *.tmp_proj 52 | *.log 53 | *.vspscc 54 | *.vssscc 55 | .builds 56 | *.pidb 57 | *.svclog 58 | *.scc 59 | 60 | # Chutzpah Test files 61 | _Chutzpah* 62 | 63 | # Visual C++ cache files 64 | ipch/ 65 | *.aps 66 | *.ncb 67 | *.opensdf 68 | *.sdf 69 | *.cachefile 70 | 71 | # Visual Studio profiler 72 | *.psess 73 | *.vsp 74 | *.vspx 75 | 76 | # TFS 2012 Local Workspace 77 | $tf/ 78 | 79 | # Guidance Automation Toolkit 80 | *.gpState 81 | 82 | # ReSharper is a .NET coding add-in 83 | _ReSharper*/ 84 | *.[Rr]e[Ss]harper 85 | *.DotSettings.user 86 | 87 | # JustCode is a .NET coding addin-in 88 | .JustCode 89 | 90 | # TeamCity is a build add-in 91 | _TeamCity* 92 | 93 | # DotCover is a Code Coverage Tool 94 | *.dotCover 95 | 96 | # NCrunch 97 | *.ncrunch* 98 | _NCrunch_* 99 | .*crunch*.local.xml 100 | 101 | # MightyMoose 102 | *.mm.* 103 | AutoTest.Net/ 104 | 105 | # Web workbench (sass) 106 | .sass-cache/ 107 | 108 | # Installshield output folder 109 | [Ee]xpress/ 110 | 111 | # DocProject is a documentation generator add-in 112 | DocProject/buildhelp/ 113 | DocProject/Help/*.HxT 114 | DocProject/Help/*.HxC 115 | DocProject/Help/*.hhc 116 | DocProject/Help/*.hhk 117 | DocProject/Help/*.hhp 118 | DocProject/Help/Html2 119 | DocProject/Help/html 120 | 121 | # Click-Once directory 122 | publish/ 123 | 124 | # Publish Web Output 125 | *.[Pp]ublish.xml 126 | *.azurePubxml 127 | 128 | # NuGet Packages Directory 129 | packages/ 130 | ## TODO: If the tool you use requires repositories.config uncomment the next line 131 | #!packages/repositories.config 132 | 133 | # Enable "build/" folder in the NuGet Packages folder since NuGet packages use it for MSBuild targets 134 | # This line needs to be after the ignore of the build folder (and the packages folder if the line above has been uncommented) 135 | !packages/build/ 136 | 137 | # Windows Azure Build Output 138 | csx/ 139 | *.build.csdef 140 | 141 | # Windows Store app package directory 142 | AppPackages/ 143 | 144 | # Others 145 | sql/ 146 | *.Cache 147 | ClientBin/ 148 | [Ss]tyle[Cc]op.* 149 | ~$* 150 | *~ 151 | *.dbmdl 152 | *.dbproj.schemaview 153 | *.pfx 154 | *.publishsettings 155 | node_modules/ 156 | 157 | # RIA/Silverlight projects 158 | Generated_Code/ 159 | 160 | # Backup & report files from converting an old project file to a newer 161 | # Visual Studio version. Backup files are not needed, because we have git ;-) 162 | _UpgradeReport_Files/ 163 | Backup*/ 164 | UpgradeLog*.XML 165 | UpgradeLog*.htm 166 | 167 | # SQL Server files 168 | *.mdf 169 | *.ldf 170 | 171 | # Business Intelligence projects 172 | *.rdl.data 173 | *.bim.layout 174 | *.bim_*.settings 175 | 176 | # Microsoft Fakes 177 | FakesAssemblies/ 178 | 179 | #Roslyn caches 180 | .vs/ 181 | 182 | #GhostDoc files 183 | *.sln.GhostDoc.xml -------------------------------------------------------------------------------- /FxCopCustomDictionary.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 11 | 12 | 13 | 14 | 22 | 23 | headnode 24 | 25 | 26 | 32 | 33 | 34 | 35 | 48 | 49 | 50 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /Marlin.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.40629.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.HBase.Client", "Microsoft.HBase.Client\Microsoft.HBase.Client.csproj", "{256F1A52-D499-4086-83B4-AE13A515AE1D}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.HBase.Client.Tests", "Microsoft.HBase.Client.Tests\Microsoft.HBase.Client.Tests.csproj", "{30A575C3-71C8-4D13-91E0-6AE0359C6A8D}" 9 | EndProject 10 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{6A268A29-9EE7-4AA3-A29D-CDD7B6EC96C6}" 11 | ProjectSection(SolutionItems) = preProject 12 | Production.FxCop.ruleset = Production.FxCop.ruleset 13 | Test.FxCop.ruleset = Test.FxCop.ruleset 14 | TestSettings.testsettings = TestSettings.testsettings 15 | EndProjectSection 16 | EndProject 17 | Global 18 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 19 | Debug|Any CPU = Debug|Any CPU 20 | Release|Any CPU = Release|Any CPU 21 | EndGlobalSection 22 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 23 | {256F1A52-D499-4086-83B4-AE13A515AE1D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 24 | {256F1A52-D499-4086-83B4-AE13A515AE1D}.Debug|Any CPU.Build.0 = Debug|Any CPU 25 | {256F1A52-D499-4086-83B4-AE13A515AE1D}.Release|Any CPU.ActiveCfg = Release|Any CPU 26 | {256F1A52-D499-4086-83B4-AE13A515AE1D}.Release|Any CPU.Build.0 = Release|Any CPU 27 | {30A575C3-71C8-4D13-91E0-6AE0359C6A8D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 28 | {30A575C3-71C8-4D13-91E0-6AE0359C6A8D}.Debug|Any CPU.Build.0 = Debug|Any CPU 29 | {30A575C3-71C8-4D13-91E0-6AE0359C6A8D}.Release|Any CPU.ActiveCfg = Release|Any CPU 30 | {30A575C3-71C8-4D13-91E0-6AE0359C6A8D}.Release|Any CPU.Build.0 = Release|Any CPU 31 | EndGlobalSection 32 | GlobalSection(SolutionProperties) = preSolution 33 | HideSolutionNode = FALSE 34 | EndGlobalSection 35 | GlobalSection(ExtensibilityGlobals) = postSolution 36 | EnterpriseLibraryConfigurationToolBinariesPathV6 = packages\EnterpriseLibrary.TransientFaultHandling.6.0.1304.0\lib\portable-net45+win+wp8 37 | EndGlobalSection 38 | EndGlobal 39 | -------------------------------------------------------------------------------- /Microsoft.HBase.Client.Tests/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /Microsoft.HBase.Client.Tests/Clients/VNetClientTest.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation 2 | // All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | // use this file except in compliance with the License. You may obtain a copy 6 | // of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 9 | // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 10 | // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 11 | // MERCHANTABLITY OR NON-INFRINGEMENT. 12 | // 13 | // See the Apache Version 2.0 License for specific language governing 14 | // permissions and limitations under the License. 15 | 16 | namespace Microsoft.HBase.Client.Tests.Clients 17 | { 18 | using System.Collections.Generic; 19 | using Microsoft.HBase.Client.LoadBalancing; 20 | using Microsoft.Practices.EnterpriseLibrary.TransientFaultHandling; 21 | using Microsoft.VisualStudio.TestTools.UnitTesting; 22 | using Microsoft.HBase.Client.Tests.Utilities; 23 | using org.apache.hadoop.hbase.rest.protobuf.generated; 24 | using System.Linq; 25 | using System; 26 | using System.Text; 27 | [TestClass] 28 | public class VNetClientTest : HBaseClientTestBase 29 | { 30 | public override IHBaseClient CreateClient() 31 | { 32 | var regionServerIPs = new List(); 33 | // TODO automatically retrieve IPs from Ambari REST APIs 34 | regionServerIPs.Add("10.17.0.11"); 35 | regionServerIPs.Add("10.17.0.13"); 36 | 37 | var options = RequestOptions.GetDefaultOptions(); 38 | options.Port = 8090; 39 | options.AlternativeEndpoint = ""; 40 | 41 | return new HBaseClient(null, options, new LoadBalancerRoundRobin(regionServerIPs)); 42 | } 43 | 44 | [TestMethod] 45 | [TestCategory(TestRunMode.CheckIn)] 46 | public override void TestFullScan() 47 | { 48 | var client = CreateClient(); 49 | 50 | StoreTestData(client); 51 | var expectedSet = new HashSet(Enumerable.Range(0, 100)); 52 | IEnumerable cells = client.StatelessScannerAsync(testTableName).Result; 53 | foreach (CellSet cell in cells) 54 | { 55 | foreach (CellSet.Row row in cell.rows) 56 | { 57 | int k = BitConverter.ToInt32(row.key, 0); 58 | expectedSet.Remove(k); 59 | } 60 | } 61 | Assert.AreEqual(0, expectedSet.Count, "The expected set wasn't empty! Items left {0}!", string.Join(",", expectedSet)); 62 | } 63 | 64 | [TestMethod] 65 | [TestCategory(TestRunMode.CheckIn)] 66 | public override void TestSubsetScan() 67 | { 68 | var client = CreateClient(); 69 | const int startRow = 10; 70 | const int endRow = 10 + 5; 71 | StoreTestData(client); 72 | var expectedSet = new HashSet(Enumerable.Range(startRow, endRow - startRow)); 73 | // TODO how to change rowkey to internal hbase binary string 74 | IEnumerable cells = client.StatelessScannerAsync(testTableName, "", "startrow=\x0A\x00\x00\x00&endrow=\x0F\x00\x00\x00").Result; 75 | 76 | foreach (CellSet cell in cells) 77 | { 78 | foreach (CellSet.Row row in cell.rows) 79 | { 80 | int k = BitConverter.ToInt32(row.key, 0); 81 | expectedSet.Remove(k); 82 | } 83 | } 84 | Assert.AreEqual(0, expectedSet.Count, "The expected set wasn't empty! Items left {0}!", string.Join(",", expectedSet)); 85 | } 86 | 87 | [TestMethod] 88 | [TestCategory(TestRunMode.CheckIn)] 89 | public void TestCellsMultiVersionGet() 90 | { 91 | const string testKey = "content"; 92 | const string testValue = "the force is strong in this column"; 93 | var client = CreateClient(); 94 | var set = new CellSet(); 95 | var row = new CellSet.Row { key = Encoding.UTF8.GetBytes(testKey) }; 96 | set.rows.Add(row); 97 | 98 | var value = new Cell { column = Encoding.UTF8.GetBytes("d:starwars"), data = Encoding.UTF8.GetBytes(testValue) }; 99 | row.values.Add(value); 100 | 101 | client.StoreCellsAsync(testTableName, set).Wait(); 102 | client.StoreCellsAsync(testTableName, set).Wait(); 103 | CellSet cell = client.GetCellsAsync(testTableName, testKey, "d:starwars", "3").Result; 104 | Assert.AreEqual(2, cell.rows[0].values.Count); 105 | } 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /Microsoft.HBase.Client.Tests/ClusterCredentialsFactory.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation 2 | // All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | // use this file except in compliance with the License. You may obtain a copy 6 | // of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 9 | // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 10 | // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 11 | // MERCHANTABLITY OR NON-INFRINGEMENT. 12 | // 13 | // See the Apache Version 2.0 License for specific language governing 14 | // permissions and limitations under the License. 15 | 16 | namespace Microsoft.HBase.Client.Tests 17 | { 18 | using System; 19 | using System.Collections.Generic; 20 | using System.Globalization; 21 | using System.IO; 22 | using System.Linq; 23 | using Microsoft.HBase.Client.Internal; 24 | 25 | internal static class ClusterCredentialsFactory 26 | { 27 | /// 28 | /// Reads the cluster credentials from a file found under the given path. 29 | /// This file needs to contain exactly three lines, where the first is the cluster URI, the second the username and the third is the password. 30 | /// (Bad luck if your username/password contains either \r or \n!). 31 | /// 32 | /// A possible example is: 33 | /// 34 | /// https://csharpazurehbase.azurehdinsight.net/ 35 | /// admin 36 | /// _mySup3rS4f3P4ssW0rd. 37 | /// 38 | /// 39 | /// a file system path that contains a text file with the credentials 40 | /// a ClusterCredentials object with the cluster URI, user and the password 41 | internal static ClusterCredentials CreateFromFile(string path) 42 | { 43 | path.ArgumentNotNull("path"); 44 | 45 | List lines = File.ReadAllLines(path).ToList(); 46 | return CreateFromList(lines); 47 | } 48 | 49 | internal static ClusterCredentials CreateFromList(List lines) 50 | { 51 | lines.ArgumentNotNull("lines"); 52 | 53 | if (lines.Count() != 3) 54 | { 55 | throw new ArgumentException( 56 | string.Format( 57 | CultureInfo.InvariantCulture, 58 | "Expected the credentials file to have exactly three lines, " + 59 | "first containing the cluster URL, second the username, third the password. " + "Given {0} lines!", 60 | lines.Count()), 61 | "lines"); 62 | } 63 | 64 | var rv = new ClusterCredentials(new Uri(lines[0]), lines[1], lines[2]); 65 | return rv; 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /Microsoft.HBase.Client.Tests/ClusterCredentialsFactoryTests.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation 2 | // All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | // use this file except in compliance with the License. You may obtain a copy 6 | // of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 9 | // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 10 | // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 11 | // MERCHANTABLITY OR NON-INFRINGEMENT. 12 | // 13 | // See the Apache Version 2.0 License for specific language governing 14 | // permissions and limitations under the License. 15 | 16 | namespace Microsoft.HBase.Client.Tests 17 | { 18 | using System; 19 | using System.Collections.Generic; 20 | using System.IO; 21 | using Microsoft.HBase.Client.Internal; 22 | using Microsoft.HBase.Client.Tests.Utilities; 23 | using Microsoft.VisualStudio.TestTools.UnitTesting; 24 | 25 | // ReSharper disable InconsistentNaming 26 | 27 | [TestClass] 28 | public class When_I_call_ClusterCredentialsFactory_CreateFromList : DisposableContextSpecification 29 | { 30 | [TestMethod] 31 | [TestCategory(TestRunMode.CheckIn)] 32 | public void It_should_throw_when_the_list_is_null() 33 | { 34 | var ane = 35 | (ArgumentNullException) 36 | typeof(ArgumentNullException).ShouldBeThrownBy(() => DisposableHelp.SafeCreate(() => ClusterCredentialsFactory.CreateFromList(null))); 37 | ane.ParamName.ShouldEqual("lines"); 38 | } 39 | 40 | [TestMethod] 41 | [TestCategory(TestRunMode.CheckIn)] 42 | public void It_should_throw_when_the_list_is_too_long() 43 | { 44 | var lst = new List { Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), Guid.NewGuid().ToString() }; 45 | var ae = 46 | (ArgumentException) 47 | typeof(ArgumentException).ShouldBeThrownBy(() => DisposableHelp.SafeCreate(() => ClusterCredentialsFactory.CreateFromList(lst))); 48 | ae.ParamName.ShouldEqual("lines"); 49 | } 50 | 51 | [TestMethod] 52 | [TestCategory(TestRunMode.CheckIn)] 53 | public void It_should_throw_when_the_list_is_too_short() 54 | { 55 | var lst = new List(); 56 | 57 | // empty 58 | var ae = 59 | (ArgumentException) 60 | typeof(ArgumentException).ShouldBeThrownBy(() => DisposableHelp.SafeCreate(() => ClusterCredentialsFactory.CreateFromList(lst))); 61 | ae.ParamName.ShouldEqual("lines"); 62 | 63 | // one 64 | lst.Add(Guid.NewGuid().ToString()); 65 | ae = 66 | (ArgumentException) 67 | typeof(ArgumentException).ShouldBeThrownBy(() => DisposableHelp.SafeCreate(() => ClusterCredentialsFactory.CreateFromList(lst))); 68 | ae.ParamName.ShouldEqual("lines"); 69 | 70 | // two 71 | lst.Add(Guid.NewGuid().ToString()); 72 | ae = 73 | (ArgumentException) 74 | typeof(ArgumentException).ShouldBeThrownBy(() => DisposableHelp.SafeCreate(() => ClusterCredentialsFactory.CreateFromList(lst))); 75 | ae.ParamName.ShouldEqual("lines"); 76 | } 77 | } 78 | 79 | 80 | [TestClass] 81 | public class When_I_call_ClusterCredentialsFactory_CreateFromFile 82 | { 83 | [TestMethod] 84 | [TestCategory(TestRunMode.CheckIn)] 85 | public void It_should_throw_the_file_does_not_exist() 86 | { 87 | string path = Path.Combine(Directory.GetCurrentDirectory(), Guid.NewGuid().ToString()); 88 | var fnfe = 89 | (FileNotFoundException) 90 | typeof(FileNotFoundException).ShouldBeThrownBy(() => DisposableHelp.SafeCreate(() => ClusterCredentialsFactory.CreateFromFile(path))); 91 | fnfe.FileName.ShouldEqual(path); 92 | } 93 | 94 | [TestMethod] 95 | [TestCategory(TestRunMode.CheckIn)] 96 | public void It_should_throw_when_the_path_is_null() 97 | { 98 | var ane = 99 | (ArgumentNullException) 100 | typeof(ArgumentNullException).ShouldBeThrownBy(() => DisposableHelp.SafeCreate(() => ClusterCredentialsFactory.CreateFromFile(null))); 101 | ane.ParamName.ShouldEqual("path"); 102 | } 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /Microsoft.HBase.Client.Tests/FilterTestRecord.cs: -------------------------------------------------------------------------------- 1 | namespace Microsoft.HBase.Client.Tests 2 | { 3 | using System; 4 | using Microsoft.HBase.Client.Internal; 5 | 6 | internal static class FilterTestRecordExtensions 7 | { 8 | internal static FilterTestRecord WithAValue(this FilterTestRecord value, string a) 9 | { 10 | value.ArgumentNotNull("value"); 11 | return new FilterTestRecord(value.RowKey, value.LineNumber, a, value.B); 12 | } 13 | 14 | internal static FilterTestRecord WithBValue(this FilterTestRecord value, string b) 15 | { 16 | value.ArgumentNotNull("value"); 17 | return new FilterTestRecord(value.RowKey, value.LineNumber, value.A, b); 18 | } 19 | 20 | internal static FilterTestRecord WithLineNumberValue(this FilterTestRecord value, int lineNumber) 21 | { 22 | value.ArgumentNotNull("value"); 23 | return new FilterTestRecord(value.RowKey, lineNumber, value.A, value.B); 24 | } 25 | } 26 | 27 | internal class FilterTestRecord : IEquatable 28 | { 29 | internal FilterTestRecord(string rowKey, int lineNumber, string a, string b) 30 | { 31 | RowKey = rowKey; 32 | LineNumber = lineNumber; 33 | A = a; 34 | B = b; 35 | } 36 | 37 | internal string A { get; private set; } 38 | 39 | internal string B { get; private set; } 40 | 41 | internal int LineNumber { get; private set; } 42 | 43 | internal string RowKey { get; private set; } 44 | 45 | public bool Equals(FilterTestRecord other) 46 | { 47 | if (ReferenceEquals(null, other)) 48 | { 49 | return false; 50 | } 51 | return LineNumber == other.LineNumber && string.Equals(A, other.A) && string.Equals(RowKey, other.RowKey) && string.Equals(B, other.B); 52 | } 53 | 54 | public override bool Equals(object obj) 55 | { 56 | return Equals(obj as FilterTestRecord); 57 | } 58 | 59 | public override int GetHashCode() 60 | { 61 | unchecked 62 | { 63 | int hashCode = LineNumber; 64 | hashCode = (hashCode * 397) ^ (A != null ? A.GetHashCode() : 0); 65 | hashCode = (hashCode * 397) ^ (RowKey != null ? RowKey.GetHashCode() : 0); 66 | hashCode = (hashCode * 397) ^ (B != null ? B.GetHashCode() : 0); 67 | return hashCode; 68 | } 69 | } 70 | 71 | public override string ToString() 72 | { 73 | return string.Format("RowKey: {0}, LineNumber: {1}, A: {2}, B: {3}", RowKey, LineNumber, A, B); 74 | } 75 | 76 | public static bool operator ==(FilterTestRecord left, FilterTestRecord right) 77 | { 78 | return Equals(left, right); 79 | } 80 | 81 | public static bool operator !=(FilterTestRecord left, FilterTestRecord right) 82 | { 83 | return !Equals(left, right); 84 | } 85 | } 86 | } -------------------------------------------------------------------------------- /Microsoft.HBase.Client.Tests/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation 2 | // All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | // use this file except in compliance with the License. You may obtain a copy 6 | // of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 9 | // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 10 | // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 11 | // MERCHANTABLITY OR NON-INFRINGEMENT. 12 | // 13 | // See the Apache Version 2.0 License for specific language governing 14 | // permissions and limitations under the License. 15 | 16 | using System; 17 | using System.Reflection; 18 | using System.Runtime.InteropServices; 19 | 20 | [assembly: AssemblyTitle("Microsoft.HBase.Client.Tests")] 21 | [assembly: AssemblyDescription("")] 22 | [assembly: AssemblyConfiguration("")] 23 | [assembly: AssemblyCompany("Microsoft Corporation")] 24 | [assembly: AssemblyProduct("Microsoft.HBase.Client.Tests")] 25 | [assembly: AssemblyCopyright("Copyright © Microsoft Corporation 2014")] 26 | [assembly: AssemblyTrademark("")] 27 | [assembly: AssemblyCulture("")] 28 | [assembly: ComVisible(false)] 29 | [assembly: CLSCompliant(true)] 30 | [assembly: AssemblyVersion("1.0.0.0")] 31 | [assembly: AssemblyFileVersion("1.0.0.0")] 32 | -------------------------------------------------------------------------------- /Microsoft.HBase.Client.Tests/PublicInternalArchitectureTests.cs: -------------------------------------------------------------------------------- 1 | namespace Microsoft.HBase.Client.Tests 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Reflection; 7 | using Microsoft.HBase.Client.Tests.Utilities; 8 | using Microsoft.VisualStudio.TestTools.UnitTesting; 9 | 10 | // ReSharper disable InconsistentNaming 11 | // 12 | [TestClass] 13 | public class PublicInternalArchitecturalTests:TestBase 14 | { 15 | [TestMethod] 16 | [TestCategory(TestRunMode.CheckIn)] 17 | public void All_declarations_not_under_an_internal_or_resources_namespace_are_public_or_nested() 18 | { 19 | List assemblies = GetAssembliesUnderTest().ToList(); 20 | assemblies.Count.ShouldBeGreaterThan(0); 21 | 22 | var violatingTypes = new HashSet(); 23 | 24 | foreach (Assembly asm in assemblies) 25 | { 26 | List allAssemblyTypes = asm.GetTypes().ToList(); 27 | foreach (Type type in allAssemblyTypes) 28 | { 29 | string namespaceName = type.Namespace ?? string.Empty; 30 | if (namespaceName.Length == 0) 31 | { 32 | // skip anonymous types. 33 | continue; 34 | } 35 | 36 | if (namespaceName == "JetBrains.Profiler.Core.Instrumentation" && type.Name == "DataOnStack") 37 | { 38 | // appears when performing test coverage using dotCover. 39 | continue; 40 | } 41 | 42 | if (!namespaceName.Contains(".Internal") && !namespaceName.Contains(".Resources") && !type.IsPublic && !type.IsNested) 43 | { 44 | violatingTypes.Add(type); 45 | } 46 | } 47 | } 48 | 49 | violatingTypes.ShouldContainOnly(new Type[] { }); 50 | } 51 | 52 | [TestMethod] 53 | [TestCategory(TestRunMode.CheckIn)] 54 | public void All_declarations_under_an_internal_namespace_are_not_public() 55 | { 56 | List assemblies = GetAssembliesUnderTest().ToList(); 57 | assemblies.Count.ShouldBeGreaterThan(0); 58 | 59 | var violatingTypes = new HashSet(); 60 | 61 | foreach (Assembly asm in assemblies) 62 | { 63 | List allAssemblyTypes = asm.GetTypes().ToList(); 64 | foreach (Type type in allAssemblyTypes) 65 | { 66 | string namespaceName = type.Namespace ?? string.Empty; 67 | if (namespaceName.Contains(".Internal") && type.IsPublic) 68 | { 69 | violatingTypes.Add(type); 70 | } 71 | } 72 | } 73 | 74 | violatingTypes.ShouldContainOnly(new Type[] { }); 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /Microsoft.HBase.Client.Tests/ScannerInformationTests.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation 2 | // All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | // use this file except in compliance with the License. You may obtain a copy 6 | // of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 9 | // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 10 | // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 11 | // MERCHANTABLITY OR NON-INFRINGEMENT. 12 | // 13 | // See the Apache Version 2.0 License for specific language governing 14 | // permissions and limitations under the License. 15 | 16 | namespace Microsoft.HBase.Client.Tests 17 | { 18 | using System; 19 | using System.Net; 20 | using Microsoft.HBase.Client.Tests.Utilities; 21 | using Microsoft.VisualStudio.TestTools.UnitTesting; 22 | 23 | // ReSharper disable InconsistentNaming 24 | 25 | [TestClass] 26 | public class When_I_create_ScannerInformation : ContextSpecification 27 | { 28 | private const string expectedScannerId = "/140614753560332aa73e8"; 29 | private const string expectedTableName = "mytable"; 30 | private readonly Uri expectedLocation = new Uri("https://headnodehost:8090/" + expectedTableName + "/scanner" + expectedScannerId); 31 | private ScannerInformation target; 32 | 33 | protected override void Context() 34 | { 35 | target = new ScannerInformation(expectedLocation, expectedTableName, new WebHeaderCollection()); 36 | } 37 | 38 | [TestMethod] 39 | [TestCategory(TestRunMode.CheckIn)] 40 | public void It_should_have_the_expected_location() 41 | { 42 | target.Location.ShouldEqual(expectedLocation); 43 | } 44 | 45 | [TestMethod] 46 | [TestCategory(TestRunMode.CheckIn)] 47 | public void It_should_have_the_expected_scanner_identifier() 48 | { 49 | target.ScannerId.ShouldEqual(expectedScannerId.Substring(1)); 50 | } 51 | 52 | [TestMethod] 53 | [TestCategory(TestRunMode.CheckIn)] 54 | public void It_should_have_the_expected_table_name() 55 | { 56 | target.TableName.ShouldEqual(expectedTableName); 57 | } 58 | } 59 | 60 | [TestClass] 61 | public class When_I_call_a_ScannerInformation_ctor : ContextSpecification 62 | { 63 | private const string validTableName = "mytable"; 64 | private readonly Uri validLocation = new Uri("https://headnodehost:8090/" + validTableName + "/scanner/140614753560332aa73e8"); 65 | 66 | [TestMethod] 67 | [TestCategory(TestRunMode.CheckIn)] 68 | public void It_should_reject_empty_table_names() 69 | { 70 | object instance = null; 71 | typeof(ArgumentEmptyException).ShouldBeThrownBy(() => instance = new ScannerInformation(validLocation, string.Empty, new WebHeaderCollection())); 72 | instance.ShouldBeNull(); 73 | } 74 | 75 | [TestMethod] 76 | [TestCategory(TestRunMode.CheckIn)] 77 | public void It_should_reject_null_locations() 78 | { 79 | object instance = null; 80 | typeof(ArgumentNullException).ShouldBeThrownBy(() => instance = new ScannerInformation(null, validTableName, new WebHeaderCollection())); 81 | instance.ShouldBeNull(); 82 | } 83 | 84 | [TestMethod] 85 | [TestCategory(TestRunMode.CheckIn)] 86 | public void It_should_reject_null_table_names() 87 | { 88 | object instance = null; 89 | typeof(ArgumentNullException).ShouldBeThrownBy(() => instance = new ScannerInformation(validLocation, null, new WebHeaderCollection())); 90 | instance.ShouldBeNull(); 91 | } 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /Microsoft.HBase.Client.Tests/Utilities/Catch.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation 2 | // All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | // use this file except in compliance with the License. You may obtain a copy 6 | // of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 9 | // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 10 | // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 11 | // MERCHANTABLITY OR NON-INFRINGEMENT. 12 | // 13 | // See the Apache Version 2.0 License for specific language governing 14 | // permissions and limitations under the License. 15 | 16 | namespace Microsoft.HBase.Client.Tests.Utilities 17 | { 18 | using System; 19 | using System.Diagnostics.CodeAnalysis; 20 | 21 | /// 22 | /// Catches exception thrown by an action. 23 | /// 24 | /// 25 | /// Originally borrowed from Machine.Specifications, licensed under MS-PL. 26 | /// 27 | internal static class Catch 28 | { 29 | /// 30 | /// Executes and action, capturing the thrown exception if any. 31 | /// 32 | /// 33 | /// The action to execute. 34 | /// 35 | /// 36 | /// The thrown exception; otherwise null. 37 | /// 38 | [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "This is a testing utility (MWP).")] 39 | internal static Exception Exception(Action throwingAction) 40 | { 41 | try 42 | { 43 | throwingAction(); 44 | } 45 | catch (Exception exception) 46 | { 47 | return exception; 48 | } 49 | 50 | return null; 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Microsoft.HBase.Client.Tests/Utilities/ContextSpecification.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation 2 | // All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | // use this file except in compliance with the License. You may obtain a copy 6 | // of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 9 | // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 10 | // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 11 | // MERCHANTABLITY OR NON-INFRINGEMENT. 12 | // 13 | // See the Apache Version 2.0 License for specific language governing 14 | // permissions and limitations under the License. 15 | 16 | namespace Microsoft.HBase.Client.Tests.Utilities 17 | { 18 | using Microsoft.VisualStudio.TestTools.UnitTesting; 19 | 20 | /// 21 | /// Provides common services for BDD-style (context/specification) unit tests. 22 | /// Serves as an adapter between the MSTest framework and our BDD-style tests. 23 | /// 24 | //// Borrowed from the blog of SaintGimp (with permission). 25 | [TestClass] 26 | public abstract class ContextSpecification : TestBase 27 | { 28 | /// 29 | /// Sets up the environment for a specification context. 30 | /// 31 | protected virtual void Context() 32 | { 33 | } 34 | 35 | /// 36 | /// Acts on the context to create the observable condition. 37 | /// 38 | protected virtual void BecauseOf() 39 | { 40 | } 41 | 42 | /// 43 | [TestInitialize] 44 | public override void TestInitialize() 45 | { 46 | base.TestInitialize(); 47 | 48 | Context(); 49 | BecauseOf(); 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /Microsoft.HBase.Client.Tests/Utilities/DisposableContextSpecification.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation 2 | // All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | // use this file except in compliance with the License. You may obtain a copy 6 | // of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 9 | // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 10 | // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 11 | // MERCHANTABLITY OR NON-INFRINGEMENT. 12 | // 13 | // See the Apache Version 2.0 License for specific language governing 14 | // permissions and limitations under the License. 15 | 16 | namespace Microsoft.HBase.Client.Tests.Utilities 17 | { 18 | using System; 19 | using System.Collections.Generic; 20 | using System.Diagnostics.CodeAnalysis; 21 | using System.Reflection; 22 | using System.Threading; 23 | using Microsoft.VisualStudio.TestTools.UnitTesting; 24 | 25 | /// 26 | /// A that implements . 27 | /// 28 | [TestClass] 29 | public abstract class DisposableContextSpecification : ContextSpecification, IDisposable 30 | { 31 | private int _disposed; 32 | 33 | /// 34 | [SuppressMessage("Microsoft.Design", "CA1063:ImplementIDisposableCorrectly")] 35 | public void Dispose() 36 | { 37 | if (Interlocked.Exchange(ref _disposed, 1) != 0) 38 | { 39 | // already disposed or disposing 40 | return; 41 | } 42 | 43 | Dispose(true); 44 | 45 | // Use SupressFinalize in case a subclass of this type implements a finalizer. 46 | GC.SuppressFinalize(this); 47 | } 48 | 49 | /// 50 | /// Releases unmanaged and - optionally - managed resources. 51 | /// 52 | /// 53 | /// Use true to release both managed and unmanaged resources; false to release only unmanaged resources. 54 | /// 55 | protected virtual void Dispose(bool disposing) 56 | { 57 | if (disposing) 58 | { 59 | Type derrivedType = GetType(); 60 | FieldInfo[] fields = derrivedType.GetFields(); 61 | foreach (FieldInfo field in fields) 62 | { 63 | object value = field.GetValue(this); 64 | if (value.IsNotNull()) 65 | { 66 | Type valueType = value.GetType(); 67 | if (!valueType.IsValueType) 68 | { 69 | var asCollectionOfDisposables = value as IEnumerable; 70 | if (!ReferenceEquals(asCollectionOfDisposables, null)) 71 | { 72 | foreach (IDisposable disposable in asCollectionOfDisposables) 73 | { 74 | disposable.Dispose(); 75 | } 76 | } 77 | 78 | var asDisposable = value as IDisposable; 79 | if (!ReferenceEquals(asDisposable, null)) 80 | { 81 | asDisposable.Dispose(); 82 | } 83 | field.SetValue(this, null); 84 | } 85 | } 86 | } 87 | } 88 | } 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /Microsoft.HBase.Client.Tests/Utilities/EnumerableExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation 2 | // All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | // use this file except in compliance with the License. You may obtain a copy 6 | // of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 9 | // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 10 | // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 11 | // MERCHANTABLITY OR NON-INFRINGEMENT. 12 | // 13 | // See the Apache Version 2.0 License for specific language governing 14 | // permissions and limitations under the License. 15 | 16 | namespace Microsoft.HBase.Client.Tests.Utilities 17 | { 18 | using System; 19 | using System.Collections; 20 | using System.Collections.Generic; 21 | using System.Linq; 22 | 23 | internal static class EnumerableExtensions 24 | { 25 | ///Finds the index of the first item matching an expression in an enumerable. 26 | ///The enumerable to search. 27 | ///The expression to test the items against. 28 | ///The index of the first matching item, or -1 if no items match. 29 | internal static int FindIndex(this IEnumerable items, Func predicate) 30 | { 31 | if (items == null) 32 | { 33 | throw new ArgumentNullException("items"); 34 | } 35 | if (predicate == null) 36 | { 37 | throw new ArgumentNullException("predicate"); 38 | } 39 | 40 | int retVal = 0; 41 | foreach (T item in items) 42 | { 43 | if (predicate(item)) 44 | { 45 | return retVal; 46 | } 47 | retVal++; 48 | } 49 | return -1; 50 | } 51 | 52 | internal static bool IsEmpty(this IEnumerable thisValue) 53 | { 54 | return !(thisValue).IsNull() && !thisValue.Cast().Any(); 55 | } 56 | 57 | internal static bool IsNotEmpty(this IEnumerable thisValue) 58 | { 59 | return (thisValue).IsNull() || thisValue.Cast().Any(); 60 | } 61 | 62 | internal static bool IsNotNullOrEmpty(this IEnumerable thisValue) 63 | { 64 | return (thisValue).IsNotNull() && thisValue.Cast().Any(); 65 | } 66 | 67 | internal static bool IsNullOrEmpty(this IEnumerable thisValue) 68 | { 69 | return (thisValue).IsNull() || !thisValue.Cast().Any(); 70 | } 71 | 72 | internal static IEnumerable Subset(this IList list, int start, int end) 73 | { 74 | int i = start; 75 | while (i <= end) 76 | { 77 | yield return list[i]; 78 | checked 79 | { 80 | ++i; 81 | } 82 | } 83 | } 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /Microsoft.HBase.Client.Tests/Utilities/GeneralComparisonOperator.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation 2 | // All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | // use this file except in compliance with the License. You may obtain a copy 6 | // of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 9 | // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 10 | // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 11 | // MERCHANTABLITY OR NON-INFRINGEMENT. 12 | // 13 | // See the Apache Version 2.0 License for specific language governing 14 | // permissions and limitations under the License. 15 | 16 | namespace Microsoft.HBase.Client.Tests.Utilities 17 | { 18 | /// 19 | /// Represents the general types of comparisons the 20 | /// system can perform. 21 | /// 22 | internal enum GeneralComparisonOperator 23 | { 24 | /// 25 | /// Represents a Reference Equality comparison. 26 | /// 27 | ReferenceEqual, 28 | 29 | /// 30 | /// Represents an Equal comparison. 31 | /// 32 | Equal, 33 | 34 | /// 35 | /// Represents a Not Equal comparison. 36 | /// 37 | NotEqual, 38 | 39 | /// 40 | /// Represents a Less Than comparison. 41 | /// 42 | LessThan, 43 | 44 | /// 45 | /// Represents a Less Than Or Equal comparison. 46 | /// 47 | LessThanOrEqual, 48 | 49 | /// 50 | /// Represents a Greater Than comparison. 51 | /// 52 | GreaterThan, 53 | 54 | /// 55 | /// Represents a Greater Than Or Equal comparison. 56 | /// 57 | GreaterThanOrEqual 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /Microsoft.HBase.Client.Tests/Utilities/SecureStringExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation 2 | // All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | // use this file except in compliance with the License. You may obtain a copy 6 | // of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 9 | // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 10 | // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 11 | // MERCHANTABLITY OR NON-INFRINGEMENT. 12 | // 13 | // See the Apache Version 2.0 License for specific language governing 14 | // permissions and limitations under the License. 15 | 16 | namespace Microsoft.HBase.Client.Tests.Utilities 17 | { 18 | using System; 19 | using System.Runtime.InteropServices; 20 | using System.Security; 21 | 22 | internal static class SecureStringExtensions 23 | { 24 | /// 25 | /// Transforms a SecureString into a string. 26 | /// 27 | /// 28 | /// The SecureString to transform. 29 | /// 30 | /// 31 | /// A string representing the contents of the original SecureString. 32 | /// 33 | internal static string ToPlainString(this SecureString value) 34 | { 35 | if (value == null) 36 | { 37 | return null; 38 | } 39 | 40 | string rv; 41 | IntPtr pointer = IntPtr.Zero; 42 | try 43 | { 44 | pointer = Marshal.SecureStringToGlobalAllocUnicode(value); 45 | rv = Marshal.PtrToStringUni(pointer); 46 | } 47 | finally 48 | { 49 | Marshal.ZeroFreeGlobalAllocUnicode(pointer); 50 | } 51 | 52 | return rv; 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /Microsoft.HBase.Client.Tests/Utilities/TestAssemblyInitializeCleanup.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation 2 | // All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | // use this file except in compliance with the License. You may obtain a copy 6 | // of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 9 | // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 10 | // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 11 | // MERCHANTABLITY OR NON-INFRINGEMENT. 12 | // 13 | // See the Apache Version 2.0 License for specific language governing 14 | // permissions and limitations under the License. 15 | 16 | namespace Microsoft.HBase.Client.Tests.Utilities 17 | { 18 | using System; 19 | using System.Collections.Generic; 20 | using System.Diagnostics; 21 | using System.Linq; 22 | using System.Reflection; 23 | using System.Threading; 24 | using Microsoft.VisualStudio.TestTools.UnitTesting; 25 | 26 | /// 27 | /// Holds the MSTest [AssemblyInitialize] and [AssemblyCleanup] for this test assembly. 28 | /// 29 | [TestClass] 30 | public static class TestAssemblyInitializeCleanup 31 | { 32 | private static int _windowsAzureStorageEmulatorStarted; 33 | 34 | /// 35 | /// Frees resources obtained by the assembly after all tests in the assembly have run. 36 | /// 37 | [AssemblyCleanup] 38 | public static void AssemblyCleanup() 39 | { 40 | StopWindowsAzureStorageEmulator(); 41 | } 42 | 43 | /// 44 | /// Method that contains code to be executed before any tests in the assembly have run and allocate resources obtained by the assembly. 45 | /// 46 | /// 47 | [AssemblyInitialize] 48 | public static void AssemblyInitialize(TestContext context) 49 | { 50 | // populate assemblies under test. 51 | var types = new List(); 52 | types.Add(typeof(ClusterCredentials)); 53 | var assemblies = new List(); 54 | foreach (Type t in types) 55 | { 56 | assemblies.Add(t.Assembly); 57 | } 58 | 59 | AssembliesUnderTest = assemblies.ToArray(); 60 | } 61 | 62 | internal static IEnumerable AssembliesUnderTest { get; private set; } 63 | 64 | 65 | internal static bool WindowsAzureStorageEmulatorStarted 66 | { 67 | get { return _windowsAzureStorageEmulatorStarted != 0; } 68 | } 69 | 70 | 71 | internal static void StartWindowsAzureStorageEmulatorIfNotAlreadyStarted() 72 | { 73 | if (Interlocked.Exchange(ref _windowsAzureStorageEmulatorStarted, 1) == 0) 74 | { 75 | StartWindowsAzureStorageEmulator(); 76 | } 77 | } 78 | 79 | private static void StartWindowsAzureStorageEmulator() 80 | { 81 | Process process = Process.GetProcessesByName("DSServiceLDB").FirstOrDefault(); 82 | if (process == null) 83 | { 84 | var processStartInfo = new ProcessStartInfo 85 | { 86 | FileName = @"C:\Program Files\Microsoft SDKs\Windows Azure\Emulator\csrun.exe", 87 | Arguments = "/devstore", 88 | }; 89 | using (Process p = Process.Start(processStartInfo)) 90 | { 91 | p.WaitForExit(); 92 | } 93 | } 94 | } 95 | 96 | private static void StopWindowsAzureStorageEmulator() 97 | { 98 | Process process = Process.GetProcessesByName("DSServiceLDB").FirstOrDefault(); 99 | if (process != null) 100 | { 101 | process.Kill(); 102 | } 103 | } 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /Microsoft.HBase.Client.Tests/Utilities/TestBase.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation 2 | // All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | // use this file except in compliance with the License. You may obtain a copy 6 | // of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 9 | // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 10 | // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 11 | // MERCHANTABLITY OR NON-INFRINGEMENT. 12 | // 13 | // See the Apache Version 2.0 License for specific language governing 14 | // permissions and limitations under the License. 15 | 16 | namespace Microsoft.HBase.Client.Tests.Utilities 17 | { 18 | using System; 19 | using System.Collections.Immutable; 20 | using System.Diagnostics.CodeAnalysis; 21 | using System.IO; 22 | using System.Reflection; 23 | using Microsoft.VisualStudio.TestTools.UnitTesting; 24 | using org.apache.hadoop.hbase.rest.protobuf.generated; 25 | 26 | [TestClass] 27 | public abstract class TestBase 28 | { 29 | /// 30 | /// Steps that are run after each test. 31 | /// 32 | [TestCleanup] 33 | public virtual void TestCleanup() 34 | { 35 | } 36 | 37 | /// 38 | /// Steps that are run before each test. 39 | /// 40 | [TestInitialize] 41 | public virtual void TestInitialize() 42 | { 43 | // reset the current directory to where the tests are running. 44 | 45 | // ReSharper disable AssignNullToNotNullAttribute 46 | Directory.SetCurrentDirectory(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)); 47 | // ReSharper restore AssignNullToNotNullAttribute 48 | } 49 | 50 | /// 51 | /// Gets or sets the test context which provides information about and functionality for the current test run. 52 | /// 53 | public TestContext TestContext { get; set; } 54 | 55 | /// 56 | /// Gets the collection of assemblies under test. 57 | /// 58 | [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] 59 | protected ImmutableHashSet GetAssembliesUnderTest() 60 | { 61 | ImmutableHashSet rv = ImmutableHashSet.Empty; 62 | foreach (Assembly asm in TestAssemblyInitializeCleanup.AssembliesUnderTest) 63 | { 64 | rv = rv.Add(asm); 65 | } 66 | return rv; 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /Microsoft.HBase.Client.Tests/Utilities/TestHelp.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation 2 | // All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | // use this file except in compliance with the License. You may obtain a copy 6 | // of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 9 | // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 10 | // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 11 | // MERCHANTABLITY OR NON-INFRINGEMENT. 12 | // 13 | // See the Apache Version 2.0 License for specific language governing 14 | // permissions and limitations under the License. 15 | 16 | namespace Microsoft.HBase.Client.Tests.Utilities 17 | { 18 | internal static class TestHelp 19 | { 20 | internal static T[] Array(params T[] input) 21 | { 22 | return input; 23 | } 24 | 25 | internal static void DoNothing(params object[] inputs) 26 | { 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Microsoft.HBase.Client.Tests/Utilities/TestRunMode.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation 2 | // All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | // use this file except in compliance with the License. You may obtain a copy 6 | // of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 9 | // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 10 | // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 11 | // MERCHANTABLITY OR NON-INFRINGEMENT. 12 | // 13 | // See the Apache Version 2.0 License for specific language governing 14 | // permissions and limitations under the License. 15 | 16 | namespace Microsoft.HBase.Client.Tests.Utilities 17 | { 18 | internal static class TestRunMode 19 | { 20 | internal const string CheckIn = "CheckIn"; 21 | internal const string LongRunning = "LongRunning"; 22 | internal const string Nightly = "Nightly"; 23 | internal const string Weekly = "Weekly"; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Microsoft.HBase.Client.Tests/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Microsoft.HBase.Client.nuspec: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Microsoft.HBase.Client 5 | 0.2 6 | Microsoft HBase REST Client Library for .NET 7 | Microsoft 8 | maxluk,ashitgosalia,thomasjungblut 9 | https://github.com/hdinsight/hbase-sdk-for-net/blob/master/LICENSE 10 | https://github.com/hdinsight/hbase-sdk-for-net 11 | false 12 | .NET Client Library for Azure HDInsight HBase clusters. 13 | (pre-release) 14 | Copyright © Microsoft Corporation 15 | Microsoft HDInsight HBase 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /Microsoft.HBase.Client/Exceptions/ArgumentContainsNullException.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation 2 | // All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | // use this file except in compliance with the License. You may obtain a copy 6 | // of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 9 | // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 10 | // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 11 | // MERCHANTABLITY OR NON-INFRINGEMENT. 12 | // 13 | // See the Apache Version 2.0 License for specific language governing 14 | // permissions and limitations under the License. 15 | 16 | namespace Microsoft.HBase.Client 17 | { 18 | using System; 19 | using System.Diagnostics.CodeAnalysis; 20 | using System.Runtime.Serialization; 21 | using System.Security; 22 | 23 | /// 24 | /// The exception that is thrown when a collection containing a null reference is passed to a method that does not accept collections 25 | /// that contain null as a valid argument. 26 | /// 27 | [Serializable] 28 | public sealed class ArgumentContainsNullException : ArgumentException 29 | { 30 | /// 31 | /// Initializes a new instance of the class. 32 | /// 33 | public ArgumentContainsNullException() : this(null, null, null) 34 | { 35 | } 36 | 37 | /// 38 | /// Initializes a new instance of the class with the name of the parameter that caused this 39 | /// exception. 40 | /// 41 | /// 42 | /// The error message that explains the reason for this exception. 43 | /// 44 | public ArgumentContainsNullException(string message) : this(null, message, null) 45 | { 46 | } 47 | 48 | /// 49 | /// Initializes a new instance of the class with a specified error message and the exception 50 | /// that is the cause of this exception. 51 | /// 52 | /// 53 | /// The error message that explains the reason for this exception. 54 | /// 55 | /// 56 | /// The exception that is the cause of the current exception, or a null reference if no inner exception is specified. 57 | /// 58 | public ArgumentContainsNullException(string message, Exception innerException) : this(null, message, innerException) 59 | { 60 | } 61 | 62 | /// 63 | /// Initializes an instance of the class with a specified error message and the name of the 64 | /// parameter that causes this exception. 65 | /// 66 | /// 67 | /// The name of the parameter that caused the exception. 68 | /// 69 | /// 70 | /// The error message that explains the reason for this exception. 71 | /// 72 | /// 73 | /// The exception that is the cause of the current exception, or a null reference if no inner exception is specified. 74 | /// 75 | [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "param")] 76 | public ArgumentContainsNullException(string paramName, string message, Exception innerException) 77 | : base(message ?? "The value must not contain null values.", paramName, innerException) 78 | { 79 | } 80 | 81 | /// 82 | /// Initializes a new instance of the class with serialized data. 83 | /// 84 | /// The object that holds the serialized object data. 85 | /// An object that describes the source or destination of the serialized data. 86 | [SecurityCritical] 87 | private ArgumentContainsNullException(SerializationInfo info, StreamingContext context) : base(info, context) 88 | { 89 | } 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /Microsoft.HBase.Client/Exceptions/ArgumentEmptyException.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation 2 | // All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | // use this file except in compliance with the License. You may obtain a copy 6 | // of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 9 | // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 10 | // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 11 | // MERCHANTABLITY OR NON-INFRINGEMENT. 12 | // 13 | // See the Apache Version 2.0 License for specific language governing 14 | // permissions and limitations under the License. 15 | 16 | namespace Microsoft.HBase.Client 17 | { 18 | using System; 19 | using System.Diagnostics.CodeAnalysis; 20 | using System.Runtime.Serialization; 21 | using System.Security; 22 | 23 | /// 24 | /// The exception that is thrown when an empty argument is passed to a method that does not accept it as a valid argument. 25 | /// 26 | [Serializable] 27 | public sealed class ArgumentEmptyException : ArgumentException 28 | { 29 | /// 30 | /// Initializes a new instance of the class. 31 | /// 32 | public ArgumentEmptyException() : this(null, null, null) 33 | { 34 | } 35 | 36 | /// 37 | /// Initializes a new instance of the class. 38 | /// 39 | /// The error message that explains the reason for this exception. 40 | public ArgumentEmptyException(string message) : this(null, message, null) 41 | { 42 | } 43 | 44 | /// 45 | /// Initializes a new instance of the class. 46 | /// 47 | /// The error message that explains the reason for the exception. 48 | /// 49 | /// The exception that is the cause of the current exception, or a null reference if no inner exception is specified. 50 | /// 51 | public ArgumentEmptyException(string message, Exception innerException) : this(null, message, innerException) 52 | { 53 | } 54 | 55 | /// 56 | /// Initializes a new instance of the class. 57 | /// 58 | /// The name of the parameter that caused the exception. 59 | /// The error message that explains the reason for this exception. 60 | /// The inner exception. 61 | [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "param")] 62 | public ArgumentEmptyException(string paramName, string message, Exception innerException) 63 | : base(message ?? "The value must not be empty.", paramName, innerException) 64 | { 65 | } 66 | 67 | [SecurityCritical] 68 | private ArgumentEmptyException(SerializationInfo info, StreamingContext context) : base(info, context) 69 | { 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /Microsoft.HBase.Client/Filters/BinaryComparator.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation 2 | // All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | // use this file except in compliance with the License. You may obtain a copy 6 | // of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 9 | // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 10 | // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 11 | // MERCHANTABLITY OR NON-INFRINGEMENT. 12 | // 13 | // See the Apache Version 2.0 License for specific language governing 14 | // permissions and limitations under the License. 15 | 16 | namespace Microsoft.HBase.Client.Filters 17 | { 18 | using System; 19 | using System.Globalization; 20 | 21 | /// 22 | /// A comparator which lexicographically compares against the specified byte array. 23 | /// 24 | public class BinaryComparator : ByteArrayComparable 25 | { 26 | /// 27 | /// Initializes a new instance of the class. 28 | /// 29 | /// The value. 30 | public BinaryComparator(byte[] value) : base(value) 31 | { 32 | } 33 | 34 | /// 35 | public override string ToEncodedString() 36 | { 37 | const string pattern = @"""type"":""BinaryComparator"",""value"":""{0}"""; 38 | return string.Format(CultureInfo.InvariantCulture, pattern, Convert.ToBase64String(Value)); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Microsoft.HBase.Client/Filters/BinaryPrefixComparator.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation 2 | // All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | // use this file except in compliance with the License. You may obtain a copy 6 | // of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 9 | // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 10 | // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 11 | // MERCHANTABLITY OR NON-INFRINGEMENT. 12 | // 13 | // See the Apache Version 2.0 License for specific language governing 14 | // permissions and limitations under the License. 15 | 16 | namespace Microsoft.HBase.Client.Filters 17 | { 18 | using System; 19 | using System.Globalization; 20 | 21 | /// 22 | /// A comparator which compares against a specified byte array, but only compares up to the length of this byte array. 23 | /// 24 | public class BinaryPrefixComparator : ByteArrayComparable 25 | { 26 | /// 27 | /// Initializes a new instance of the class. 28 | /// 29 | /// The value. 30 | public BinaryPrefixComparator(byte[] value) : base(value) 31 | { 32 | } 33 | 34 | /// 35 | public override string ToEncodedString() 36 | { 37 | const string pattern = @"""type"":""BinaryPrefixComparator"", ""value"":""{0}"""; 38 | return string.Format(CultureInfo.InvariantCulture, pattern, Convert.ToBase64String(Value)); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Microsoft.HBase.Client/Filters/BitComparator.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation 2 | // All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | // use this file except in compliance with the License. You may obtain a copy 6 | // of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 9 | // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 10 | // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 11 | // MERCHANTABLITY OR NON-INFRINGEMENT. 12 | // 13 | // See the Apache Version 2.0 License for specific language governing 14 | // permissions and limitations under the License. 15 | 16 | namespace Microsoft.HBase.Client.Filters 17 | { 18 | using System; 19 | using System.ComponentModel; 20 | using System.Globalization; 21 | using Microsoft.HBase.Client.Internal; 22 | 23 | /// 24 | /// Comparator which performs the specified bitwise operation on each of the bytes with the specified byte array. 25 | /// 26 | public class BitComparator : ByteArrayComparable 27 | { 28 | /// 29 | /// Represents bitwise operations. 30 | /// 31 | public enum BitwiseOp 32 | { 33 | /// 34 | /// And. 35 | /// 36 | And = 0, 37 | 38 | /// 39 | /// Or. 40 | /// 41 | Or = 1, 42 | 43 | /// 44 | /// Exclusive or. 45 | /// 46 | Xor = 2, 47 | } 48 | 49 | /// 50 | /// Initializes a new instance of the class. 51 | /// 52 | /// The value. 53 | /// The bit operator. 54 | /// The value of is not recognized. 55 | public BitComparator(byte[] value, BitwiseOp bitOperator) : base(value) 56 | { 57 | if (!Enum.IsDefined(typeof(BitwiseOp), bitOperator)) 58 | { 59 | throw new InvalidEnumArgumentException("bitOperator", (int)bitOperator, typeof(BitwiseOp)); 60 | } 61 | 62 | BitOperator = bitOperator; 63 | } 64 | 65 | /// 66 | /// Gets the bit operator. 67 | /// 68 | /// 69 | /// The bit operator. 70 | /// 71 | public BitwiseOp BitOperator { get; private set; } 72 | 73 | /// 74 | public override string ToEncodedString() 75 | { 76 | const string pattern = @"""type"":""BitComparator"", ""value"":""{0}"", ""op"":""{1}"""; 77 | return string.Format(CultureInfo.InvariantCulture, pattern, Convert.ToBase64String(Value), BitOperator.ToCodeName()); 78 | } 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /Microsoft.HBase.Client/Filters/ByteArrayComparable.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation 2 | // All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | // use this file except in compliance with the License. You may obtain a copy 6 | // of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 9 | // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 10 | // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 11 | // MERCHANTABLITY OR NON-INFRINGEMENT. 12 | // 13 | // See the Apache Version 2.0 License for specific language governing 14 | // permissions and limitations under the License. 15 | 16 | namespace Microsoft.HBase.Client.Filters 17 | { 18 | using System; 19 | using System.Diagnostics.CodeAnalysis; 20 | using Microsoft.HBase.Client.Internal; 21 | using org.apache.hadoop.hbase.rest.protobuf.generated; 22 | 23 | /// 24 | /// Base class for byte array comparators. 25 | /// 26 | public abstract class ByteArrayComparable 27 | { 28 | private readonly byte[] _value; 29 | 30 | /// 31 | /// Initializes a new instance of the class. 32 | /// 33 | /// The value to compare. 34 | /// Thrown when is null. 35 | protected ByteArrayComparable(byte[] value) 36 | { 37 | value.ArgumentNotNull("value"); 38 | 39 | _value = (byte[])value.Clone(); 40 | } 41 | 42 | /// 43 | /// Gets the value to compare. 44 | /// 45 | /// 46 | /// The value to compare. 47 | /// 48 | [SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")] 49 | public byte[] Value 50 | { 51 | get { return (byte[])_value.Clone(); } 52 | } 53 | 54 | /// 55 | /// Generates an encoded string that can be used to as part of a . 56 | /// 57 | /// 58 | /// A comparer string. 59 | /// 60 | public abstract string ToEncodedString(); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /Microsoft.HBase.Client/Filters/ColumnCountGetFilter.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation 2 | // All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | // use this file except in compliance with the License. You may obtain a copy 6 | // of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 9 | // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 10 | // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 11 | // MERCHANTABLITY OR NON-INFRINGEMENT. 12 | // 13 | // See the Apache Version 2.0 License for specific language governing 14 | // permissions and limitations under the License. 15 | 16 | namespace Microsoft.HBase.Client.Filters 17 | { 18 | using System.Diagnostics.CodeAnalysis; 19 | using System.Globalization; 20 | 21 | /// 22 | /// Simple filter that returns first N columns on row only. 23 | /// 24 | /// 25 | /// Simple filter that returns first N columns on row only. This filter was written to test filters in Get and as soon as it gets its quota 26 | /// of columns, filterAllRemaining() returns true. This makes this filter unsuitable as a Scan filter. 27 | /// 28 | public class ColumnCountGetFilter : Filter 29 | { 30 | /// 31 | /// Initializes a new instance of the class. 32 | /// 33 | /// The n. 34 | [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "n")] 35 | public ColumnCountGetFilter(int n) 36 | { 37 | N = n; 38 | } 39 | 40 | /// 41 | /// Gets the n. 42 | /// 43 | /// 44 | /// The n. 45 | /// 46 | [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "N")] 47 | public int N { get; private set; } 48 | 49 | /// 50 | public override string ToEncodedString() 51 | { 52 | const string filterPattern = @"{{""type"":""ColumnCountGetFilter"",""limit"":{0}}}"; 53 | 54 | return string.Format(CultureInfo.InvariantCulture, filterPattern, N); 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /Microsoft.HBase.Client/Filters/ColumnPaginationFilter.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation 2 | // All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | // use this file except in compliance with the License. You may obtain a copy 6 | // of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 9 | // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 10 | // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 11 | // MERCHANTABLITY OR NON-INFRINGEMENT. 12 | // 13 | // See the Apache Version 2.0 License for specific language governing 14 | // permissions and limitations under the License. 15 | 16 | namespace Microsoft.HBase.Client.Filters 17 | { 18 | using System.Globalization; 19 | 20 | /// 21 | /// A filter, based on the ColumnCountGetFilter, takes two arguments: limit and offset. 22 | /// 23 | /// 24 | /// This filter can be used for row-based indexing, where references to other tables are stored across many columns, in order to efficient lookups 25 | /// and paginated results for end users. Only most recent versions are considered for pagination. 26 | /// 27 | public class ColumnPaginationFilter : Filter 28 | { 29 | // could not get byte[] columnOffset to stringify, so it has been removed. 30 | 31 | /// 32 | /// Initializes a new instance of the class. 33 | /// 34 | /// The limit. 35 | /// The offset. 36 | /// 37 | /// Initializes filter with an integer offset and limit. 38 | /// 39 | public ColumnPaginationFilter(int limit, int offset) 40 | { 41 | Limit = limit; 42 | Offset = offset; 43 | } 44 | 45 | /// 46 | /// Gets the limit. 47 | /// 48 | /// 49 | /// The limit. 50 | /// 51 | public int Limit { get; private set; } 52 | 53 | /// 54 | /// Gets the offset. 55 | /// 56 | /// 57 | /// The offset. 58 | /// 59 | public int Offset { get; private set; } 60 | 61 | /// 62 | public override string ToEncodedString() 63 | { 64 | const string filterPattern = @"{{""type"":""ColumnPaginationFilter"",""limit"":{0},""offset"":{1}}}"; 65 | 66 | return string.Format(CultureInfo.InvariantCulture, filterPattern, Limit, Offset); 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /Microsoft.HBase.Client/Filters/ColumnPrefixFilter.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation 2 | // All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | // use this file except in compliance with the License. You may obtain a copy 6 | // of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 9 | // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 10 | // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 11 | // MERCHANTABLITY OR NON-INFRINGEMENT. 12 | // 13 | // See the Apache Version 2.0 License for specific language governing 14 | // permissions and limitations under the License. 15 | 16 | namespace Microsoft.HBase.Client.Filters 17 | { 18 | using System; 19 | using System.Diagnostics.CodeAnalysis; 20 | using System.Globalization; 21 | using Microsoft.HBase.Client.Internal; 22 | 23 | /// 24 | /// This filter is used for selecting only those keys with columns that matches a particular prefix. 25 | /// 26 | public class ColumnPrefixFilter : Filter 27 | { 28 | private readonly byte[] _prefix; 29 | 30 | /// 31 | /// Initializes a new instance of the class. 32 | /// 33 | /// The prefix. 34 | public ColumnPrefixFilter(byte[] prefix) 35 | { 36 | prefix.ArgumentNotNull("prefix"); 37 | 38 | _prefix = (byte[])prefix.Clone(); 39 | } 40 | 41 | /// 42 | /// Gets the prefix. 43 | /// 44 | /// 45 | /// The prefix. 46 | /// 47 | [SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")] 48 | public byte[] Prefix 49 | { 50 | get { return (byte[])_prefix.Clone(); } 51 | } 52 | 53 | /// 54 | public override string ToEncodedString() 55 | { 56 | const string filterPattern = @"{{""type"":""ColumnPrefixFilter"",""value"":""{0}""}}"; 57 | 58 | return string.Format(CultureInfo.InvariantCulture, filterPattern, Convert.ToBase64String(Prefix)); 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /Microsoft.HBase.Client/Filters/ColumnRangeFilter.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation 2 | // All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | // use this file except in compliance with the License. You may obtain a copy 6 | // of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 9 | // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 10 | // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 11 | // MERCHANTABLITY OR NON-INFRINGEMENT. 12 | // 13 | // See the Apache Version 2.0 License for specific language governing 14 | // permissions and limitations under the License. 15 | 16 | namespace Microsoft.HBase.Client.Filters 17 | { 18 | using System; 19 | using System.Diagnostics.CodeAnalysis; 20 | using System.Globalization; 21 | using Microsoft.HBase.Client.Internal; 22 | 23 | /// 24 | /// This filter is used for selecting only those keys with columns that are between minColumn to maxColumn. 25 | /// 26 | public class ColumnRangeFilter : Filter 27 | { 28 | private readonly byte[] _maxColumn; 29 | private readonly byte[] _minColumn; 30 | 31 | /// 32 | /// Initializes a new instance of the class. 33 | /// 34 | /// The minimum column. 35 | /// if set to true include the minimum column in the range. 36 | /// The maximum column. 37 | /// if set to true include the maximum column in the range. 38 | public ColumnRangeFilter(byte[] minColumn, bool minColumnInclusive, byte[] maxColumn, bool maxColumnInclusive) 39 | { 40 | minColumn.ArgumentNotNull("minColumn"); 41 | maxColumn.ArgumentNotNull("maxColumn"); 42 | 43 | _minColumn = (byte[])minColumn.Clone(); 44 | MinColumnInclusive = minColumnInclusive; 45 | _maxColumn = (byte[])maxColumn.Clone(); 46 | MaxColumnInclusive = maxColumnInclusive; 47 | } 48 | 49 | /// 50 | /// Gets the maximum column. 51 | /// 52 | /// 53 | /// The maximum column. 54 | /// 55 | [SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")] 56 | public byte[] MaxColumn 57 | { 58 | get { return (byte[])_maxColumn.Clone(); } 59 | } 60 | 61 | /// 62 | /// Gets a value indicating whether or not the maximum column is in the range. 63 | /// 64 | /// 65 | /// true if maximum column is in the range; otherwise, false. 66 | /// 67 | public bool MaxColumnInclusive { get; private set; } 68 | 69 | /// 70 | /// Gets the minimum column. 71 | /// 72 | /// 73 | /// The minimum column. 74 | /// 75 | [SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")] 76 | public byte[] MinColumn 77 | { 78 | get { return (byte[])_minColumn.Clone(); } 79 | } 80 | 81 | /// 82 | /// Gets a value indicating whether or not the minimum column is in the range. 83 | /// 84 | /// 85 | /// true if the minimum column is in the range; otherwise, false. 86 | /// 87 | public bool MinColumnInclusive { get; private set; } 88 | 89 | /// 90 | [SuppressMessage("Microsoft.Globalization", "CA1308:NormalizeStringsToUppercase")] 91 | public override string ToEncodedString() 92 | { 93 | const string filterPattern = 94 | @"{{""type"":""ColumnRangeFilter"",""minColumn"":""{0}"",""minColumnInclusive"":{1},""maxColumn"":""{2}"",""maxColumnInclusive"":{3}}}"; 95 | 96 | return string.Format( 97 | CultureInfo.InvariantCulture, 98 | filterPattern, 99 | Convert.ToBase64String(MinColumn), 100 | MinColumnInclusive.ToString(CultureInfo.InvariantCulture).ToLowerInvariant(), 101 | Convert.ToBase64String(MaxColumn), 102 | MaxColumnInclusive.ToString(CultureInfo.InvariantCulture).ToLowerInvariant()); 103 | } 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /Microsoft.HBase.Client/Filters/CompareFilter.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation 2 | // All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | // use this file except in compliance with the License. You may obtain a copy 6 | // of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 9 | // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 10 | // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 11 | // MERCHANTABLITY OR NON-INFRINGEMENT. 12 | // 13 | // See the Apache Version 2.0 License for specific language governing 14 | // permissions and limitations under the License. 15 | 16 | namespace Microsoft.HBase.Client.Filters 17 | { 18 | using System; 19 | using System.ComponentModel; 20 | using Microsoft.HBase.Client.Internal; 21 | 22 | /// 23 | /// This is a generic filter to be used to filter by comparison. 24 | /// 25 | public abstract class CompareFilter : Filter 26 | { 27 | /// 28 | /// Represents comparison operators. 29 | /// 30 | public enum CompareOp 31 | { 32 | /// 33 | /// No operation. 34 | /// 35 | NoOperation = 0, 36 | 37 | /// 38 | /// Equals. 39 | /// 40 | Equal = 1, 41 | 42 | /// 43 | /// Not equal. 44 | /// 45 | NotEqual = 2, 46 | 47 | /// 48 | /// Greater than. 49 | /// 50 | GreaterThan = 3, 51 | 52 | /// 53 | /// Greater than or equal to. 54 | /// 55 | GreaterThanOrEqualTo = 4, 56 | 57 | /// 58 | /// Less than. 59 | /// 60 | LessThan = 5, 61 | 62 | /// 63 | /// Less than or equal to. 64 | /// 65 | LessThanOrEqualTo = 6, 66 | } 67 | 68 | /// 69 | /// Initializes a new instance of the class. 70 | /// 71 | /// The compare op. 72 | /// The comparator. 73 | protected CompareFilter(CompareOp compareOp, ByteArrayComparable comparator) 74 | { 75 | if (!Enum.IsDefined(typeof(CompareOp), compareOp)) 76 | { 77 | throw new InvalidEnumArgumentException("compareOp", (int)compareOp, typeof(CompareOp)); 78 | } 79 | 80 | comparator.ArgumentNotNull("comparator"); 81 | 82 | CompareOperation = compareOp; 83 | Comparator = comparator; 84 | } 85 | 86 | /// 87 | /// Gets the comparator. 88 | /// 89 | /// 90 | /// The comparator. 91 | /// 92 | public ByteArrayComparable Comparator { get; private set; } 93 | 94 | /// 95 | /// Gets the compare operation. 96 | /// 97 | /// 98 | /// The compare operation. 99 | /// 100 | public CompareOp CompareOperation { get; private set; } 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /Microsoft.HBase.Client/Filters/DependentColumnFilter.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation 2 | // All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | // use this file except in compliance with the License. You may obtain a copy 6 | // of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 9 | // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 10 | // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 11 | // MERCHANTABLITY OR NON-INFRINGEMENT. 12 | // 13 | // See the Apache Version 2.0 License for specific language governing 14 | // permissions and limitations under the License. 15 | 16 | namespace Microsoft.HBase.Client.Filters 17 | { 18 | using System; 19 | using System.Diagnostics.CodeAnalysis; 20 | using System.Globalization; 21 | using Microsoft.HBase.Client.Internal; 22 | 23 | /// 24 | /// A filter for adding inter-column timestamp matching Only cells with a correspondingly timestamped entry in the target column will be retained 25 | /// Not compatible with Scan.setBatch as operations need full rows for correct filtering. 26 | /// 27 | public class DependentColumnFilter : CompareFilter 28 | { 29 | private readonly byte[] _family; 30 | private readonly byte[] _qualifier; 31 | 32 | /// 33 | /// Initializes a new instance of the class. 34 | /// 35 | /// The name of the column family. 36 | /// The name of the column qualifier. 37 | /// Specifies whether or not the dependent column should be dropped. 38 | /// The operator. 39 | /// The value comparator. 40 | public DependentColumnFilter( 41 | byte[] family, 42 | byte[] qualifier, 43 | bool dropDependentColumn, 44 | CompareOp valueCompareOp, 45 | ByteArrayComparable valueComparator) : base(valueCompareOp, valueComparator) 46 | { 47 | family.ArgumentNotNull("family"); 48 | qualifier.ArgumentNotNull("qualifier"); 49 | 50 | _family = (byte[])family.Clone(); 51 | _qualifier = (byte[])qualifier.Clone(); 52 | DropDependentColumn = dropDependentColumn; 53 | } 54 | 55 | /// 56 | /// Gets a value indicating whether or not the dependent column should be dropped. 57 | /// 58 | /// 59 | /// true if the dependent column should be dropped; otherwise, false. 60 | /// 61 | public bool DropDependentColumn { get; private set; } 62 | 63 | /// 64 | /// Gets the name of the column family. 65 | /// 66 | /// 67 | /// The name of the column family. 68 | /// 69 | [SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")] 70 | public byte[] Family 71 | { 72 | get { return (byte[])_family.Clone(); } 73 | } 74 | 75 | /// 76 | /// Gets the name of the column qualifier. 77 | /// 78 | /// 79 | /// The name of the column qualifier. 80 | /// 81 | [SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")] 82 | public byte[] Qualifier 83 | { 84 | get { return (byte[])_qualifier.Clone(); } 85 | } 86 | 87 | /// 88 | [SuppressMessage("Microsoft.Globalization", "CA1308:NormalizeStringsToUppercase")] 89 | public override string ToEncodedString() 90 | { 91 | const string filterPattern = 92 | @"{{""type"":""DependentColumnFilter"",""op"":""{0}"",""family"":""{1}"",""qualifier"":""{2}"",""dropDependentColumn"":{3},""comparator"":{{{4}}}}}"; 93 | 94 | return string.Format( 95 | CultureInfo.InvariantCulture, 96 | filterPattern, 97 | CompareOperation.ToCodeName(), 98 | Convert.ToBase64String(Family), 99 | Convert.ToBase64String(Qualifier), 100 | DropDependentColumn.ToString(CultureInfo.InvariantCulture).ToLowerInvariant(), 101 | Comparator.ToEncodedString()); 102 | } 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /Microsoft.HBase.Client/Filters/FamilyFilter.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation 2 | // All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | // use this file except in compliance with the License. You may obtain a copy 6 | // of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 9 | // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 10 | // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 11 | // MERCHANTABLITY OR NON-INFRINGEMENT. 12 | // 13 | // See the Apache Version 2.0 License for specific language governing 14 | // permissions and limitations under the License. 15 | 16 | namespace Microsoft.HBase.Client.Filters 17 | { 18 | using System.Globalization; 19 | using Microsoft.HBase.Client.Internal; 20 | 21 | /// 22 | /// This filter is used to filter based on the column family. 23 | /// 24 | public class FamilyFilter : CompareFilter 25 | { 26 | /// 27 | /// Initializes a new instance of the class. 28 | /// 29 | /// The family compare op. 30 | /// The family comparator. 31 | /// familyCompareOp 32 | public FamilyFilter(CompareOp familyCompareOp, ByteArrayComparable familyComparator) : base(familyCompareOp, familyComparator) 33 | { 34 | } 35 | 36 | /// 37 | public override string ToEncodedString() 38 | { 39 | const string filterPattern = @"{{""type"":""FamilyFilter"",""op"":""{0}"",""comparator"":{{{1}}}}}"; 40 | 41 | return string.Format(CultureInfo.InvariantCulture, filterPattern, CompareOperation.ToCodeName(), Comparator.ToEncodedString()); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Microsoft.HBase.Client/Filters/Filter.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation 2 | // All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | // use this file except in compliance with the License. You may obtain a copy 6 | // of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 9 | // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 10 | // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 11 | // MERCHANTABLITY OR NON-INFRINGEMENT. 12 | // 13 | // See the Apache Version 2.0 License for specific language governing 14 | // permissions and limitations under the License. 15 | 16 | 17 | namespace Microsoft.HBase.Client.Filters 18 | { 19 | using org.apache.hadoop.hbase.rest.protobuf.generated; 20 | 21 | /// 22 | /// Interface for row and column filters directly applied within the regionserver. 23 | /// 24 | public abstract class Filter 25 | { 26 | /// 27 | /// Generates an encoded string that can be applied to a . 28 | /// 29 | /// 30 | /// A filter string. 31 | /// 32 | public abstract string ToEncodedString(); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Microsoft.HBase.Client/Filters/FirstKeyOnlyFilter.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation 2 | // All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | // use this file except in compliance with the License. You may obtain a copy 6 | // of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 9 | // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 10 | // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 11 | // MERCHANTABLITY OR NON-INFRINGEMENT. 12 | // 13 | // See the Apache Version 2.0 License for specific language governing 14 | // permissions and limitations under the License. 15 | namespace Microsoft.HBase.Client.Filters 16 | { 17 | /// 18 | /// A filter that will only return the first KV from each row. 19 | /// 20 | public class FirstKeyOnlyFilter : Filter 21 | { 22 | /// 23 | public override string ToEncodedString() 24 | { 25 | return @"{""type"":""FirstKeyOnlyFilter""}"; 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Microsoft.HBase.Client/Filters/InclusiveStopFilter.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation 2 | // All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | // use this file except in compliance with the License. You may obtain a copy 6 | // of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 9 | // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 10 | // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 11 | // MERCHANTABLITY OR NON-INFRINGEMENT. 12 | // 13 | // See the Apache Version 2.0 License for specific language governing 14 | // permissions and limitations under the License. 15 | 16 | namespace Microsoft.HBase.Client.Filters 17 | { 18 | using System; 19 | using System.Diagnostics.CodeAnalysis; 20 | using System.Globalization; 21 | using Microsoft.HBase.Client.Internal; 22 | 23 | /// 24 | /// A Filter that stops after the given row. 25 | /// 26 | public class InclusiveStopFilter : Filter 27 | { 28 | private readonly byte[] _stopRowKey; 29 | 30 | /// 31 | /// Initializes a new instance of the class. 32 | /// 33 | /// The stop row key. 34 | public InclusiveStopFilter(byte[] stopRowKey) 35 | { 36 | stopRowKey.ArgumentNotNull("stopRowKey"); 37 | 38 | _stopRowKey = (byte[])stopRowKey.Clone(); 39 | } 40 | 41 | /// 42 | /// Gets the stop row key. 43 | /// 44 | /// 45 | /// The stop row key. 46 | /// 47 | [SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")] 48 | public byte[] StopRowKey 49 | { 50 | get 51 | { 52 | var rv = (byte[])_stopRowKey.Clone(); 53 | return rv; 54 | } 55 | } 56 | 57 | /// 58 | public override string ToEncodedString() 59 | { 60 | const string filterPattern = @"{{""type"":""InclusiveStopFilter"",""value"":""{0}""}}"; 61 | return string.Format(CultureInfo.InvariantCulture, filterPattern, Convert.ToBase64String(StopRowKey)); 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /Microsoft.HBase.Client/Filters/KeyOnlyFilter.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation 2 | // All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | // use this file except in compliance with the License. You may obtain a copy 6 | // of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 9 | // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 10 | // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 11 | // MERCHANTABLITY OR NON-INFRINGEMENT. 12 | // 13 | // See the Apache Version 2.0 License for specific language governing 14 | // permissions and limitations under the License. 15 | namespace Microsoft.HBase.Client.Filters 16 | { 17 | /// 18 | /// A filter that will only return the key component of each KV (the value will be rewritten as empty). 19 | /// 20 | /// 21 | /// This filter can be used to grab all of the keys without having to also grab the values. 22 | /// 23 | public class KeyOnlyFilter : Filter 24 | { 25 | // note: could not get "lenAsVal" to stringify, so it has been removed. 26 | 27 | /// 28 | public override string ToEncodedString() 29 | { 30 | return @"{""type"":""KeyOnlyFilter""}"; 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Microsoft.HBase.Client/Filters/MultipleColumnPrefixFilter.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation 2 | // All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | // use this file except in compliance with the License. You may obtain a copy 6 | // of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 9 | // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 10 | // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 11 | // MERCHANTABLITY OR NON-INFRINGEMENT. 12 | // 13 | // See the Apache Version 2.0 License for specific language governing 14 | // permissions and limitations under the License. 15 | namespace Microsoft.HBase.Client.Filters 16 | { 17 | using System; 18 | using System.Collections.Generic; 19 | using System.Globalization; 20 | using System.Text; 21 | using Microsoft.HBase.Client.Internal; 22 | 23 | /// 24 | /// This filter is used for selecting only those keys with columns that matches a particular prefix. 25 | /// 26 | public class MultipleColumnPrefixFilter : Filter 27 | { 28 | private readonly HashSet _prefixes; 29 | 30 | /// 31 | /// Initializes a new instance of the class. 32 | /// 33 | /// The prefixes. 34 | public MultipleColumnPrefixFilter(IEnumerable prefixes) 35 | { 36 | prefixes.ArgumentNotNull("prefixes"); 37 | 38 | _prefixes = new HashSet(new ByteArrayEqualityComparer()); 39 | foreach (byte[] p in prefixes) 40 | { 41 | if (ReferenceEquals(p, null)) 42 | { 43 | throw new ArgumentContainsNullException("prefixes", null, null); 44 | } 45 | _prefixes.Add((byte[])p.Clone()); 46 | } 47 | } 48 | 49 | /// 50 | /// Gets the prefixes. 51 | /// 52 | /// 53 | /// The prefixes. 54 | /// 55 | public IEnumerable Prefixes 56 | { 57 | get 58 | { 59 | var rv = new List(); 60 | foreach (byte[] p in _prefixes) 61 | { 62 | rv.Add((byte[])p.Clone()); 63 | } 64 | 65 | return rv; 66 | } 67 | } 68 | 69 | /// 70 | public override string ToEncodedString() 71 | { 72 | const string filterPattern = @"{{""type"":""MultipleColumnPrefixFilter"",""prefixes"":[{0}]}}"; 73 | return string.Format(CultureInfo.InvariantCulture, filterPattern, ToCsvStringWithDoubleQuotedEncodedValues(_prefixes)); 74 | } 75 | 76 | internal string ToCsvStringWithDoubleQuotedEncodedValues(IEnumerable values) 77 | { 78 | values.ArgumentNotNull("values"); 79 | 80 | var working = new StringBuilder(); 81 | foreach (byte[] v in values) 82 | { 83 | working.AppendFormat(@"""{0}"",", Convert.ToBase64String(v)); 84 | } 85 | 86 | // remove the trailing ',' 87 | return working.ToString(0, working.Length - 1); 88 | } 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /Microsoft.HBase.Client/Filters/NullComparator.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation 2 | // All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | // use this file except in compliance with the License. You may obtain a copy 6 | // of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 9 | // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 10 | // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 11 | // MERCHANTABLITY OR NON-INFRINGEMENT. 12 | // 13 | // See the Apache Version 2.0 License for specific language governing 14 | // permissions and limitations under the License. 15 | 16 | namespace Microsoft.HBase.Client.Filters 17 | { 18 | /// 19 | /// A binary comparator which lexicographically compares against the specified byte array. 20 | /// 21 | public class NullComparator : ByteArrayComparable 22 | { 23 | /// 24 | /// Initializes a new instance of the class. 25 | /// 26 | public NullComparator() : base(new byte[0]) 27 | { 28 | } 29 | 30 | /// 31 | public override string ToEncodedString() 32 | { 33 | return @"""type"":""NullComparator"""; 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Microsoft.HBase.Client/Filters/PageFilter.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation 2 | // All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | // use this file except in compliance with the License. You may obtain a copy 6 | // of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 9 | // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 10 | // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 11 | // MERCHANTABLITY OR NON-INFRINGEMENT. 12 | // 13 | // See the Apache Version 2.0 License for specific language governing 14 | // permissions and limitations under the License. 15 | 16 | namespace Microsoft.HBase.Client.Filters 17 | { 18 | using System.Globalization; 19 | 20 | /// 21 | /// Implementation of Filter interface that limits results to a specific page size. 22 | /// 23 | /// 24 | /// Note that this filter cannot guarantee that the number of results returned to a client are less than or equal to page size. This is because 25 | /// the filter is applied separately on different region servers. It does however optimize the scan of individual HRegions by making sure that 26 | /// the page size is never exceeded locally. 27 | /// 28 | public class PageFilter : Filter 29 | { 30 | /// 31 | /// Initializes a new instance of the class. 32 | /// 33 | /// Size of the page. 34 | public PageFilter(long pageSize) 35 | { 36 | PageSize = pageSize; 37 | } 38 | 39 | /// 40 | /// Gets the maximum size of a page. 41 | /// 42 | /// 43 | /// The maximum size of a page. 44 | /// 45 | public long PageSize { get; private set; } 46 | 47 | /// 48 | public override string ToEncodedString() 49 | { 50 | const string filterPattern = @"{{""type"":""PageFilter"",""value"":""{0}""}}"; 51 | return string.Format(CultureInfo.InvariantCulture, filterPattern, PageSize); 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /Microsoft.HBase.Client/Filters/PrefixFilter.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation 2 | // All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | // use this file except in compliance with the License. You may obtain a copy 6 | // of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 9 | // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 10 | // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 11 | // MERCHANTABLITY OR NON-INFRINGEMENT. 12 | // 13 | // See the Apache Version 2.0 License for specific language governing 14 | // permissions and limitations under the License. 15 | 16 | namespace Microsoft.HBase.Client.Filters 17 | { 18 | using System; 19 | using System.Diagnostics.CodeAnalysis; 20 | using System.Globalization; 21 | using Microsoft.HBase.Client.Internal; 22 | 23 | /// 24 | /// Pass results that have same row prefix. 25 | /// 26 | public class PrefixFilter : Filter 27 | { 28 | private readonly byte[] _prefix; 29 | 30 | /// 31 | /// Initializes a new instance of the class. 32 | /// 33 | /// The prefix. 34 | public PrefixFilter(byte[] prefix) 35 | { 36 | prefix.ArgumentNotNull("prefix"); 37 | 38 | _prefix = (byte[])prefix.Clone(); 39 | } 40 | 41 | /// 42 | /// Gets the prefix. 43 | /// 44 | /// 45 | /// The prefix. 46 | /// 47 | [SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")] 48 | public byte[] Prefix 49 | { 50 | get { return _prefix; } 51 | } 52 | 53 | /// 54 | public override string ToEncodedString() 55 | { 56 | const string filterPattern = @"{{""type"":""PrefixFilter"",""value"":""{0}""}}"; 57 | return string.Format(CultureInfo.InvariantCulture, filterPattern, Convert.ToBase64String(Prefix)); 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /Microsoft.HBase.Client/Filters/QualifierFilter.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation 2 | // All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | // use this file except in compliance with the License. You may obtain a copy 6 | // of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 9 | // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 10 | // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 11 | // MERCHANTABLITY OR NON-INFRINGEMENT. 12 | // 13 | // See the Apache Version 2.0 License for specific language governing 14 | // permissions and limitations under the License. 15 | 16 | namespace Microsoft.HBase.Client.Filters 17 | { 18 | using System.Globalization; 19 | using Microsoft.HBase.Client.Internal; 20 | 21 | /// 22 | /// This filter is used to filter based on the column qualifier. 23 | /// 24 | public class QualifierFilter : CompareFilter 25 | { 26 | /// 27 | /// Initializes a new instance of the class. 28 | /// 29 | /// The op. 30 | /// The qualifier comparator. 31 | public QualifierFilter(CompareOp op, ByteArrayComparable qualifierComparator) : base(op, qualifierComparator) 32 | { 33 | } 34 | 35 | /// 36 | public override string ToEncodedString() 37 | { 38 | const string filterPattern = @"{{""type"":""QualifierFilter"",""op"":""{0}"",""comparator"":{{{1}}}}}"; 39 | return string.Format(CultureInfo.InvariantCulture, filterPattern, CompareOperation.ToCodeName(), Comparator.ToEncodedString()); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Microsoft.HBase.Client/Filters/RandomRowFilter.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation 2 | // All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | // use this file except in compliance with the License. You may obtain a copy 6 | // of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 9 | // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 10 | // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 11 | // MERCHANTABLITY OR NON-INFRINGEMENT. 12 | // 13 | // See the Apache Version 2.0 License for specific language governing 14 | // permissions and limitations under the License. 15 | 16 | namespace Microsoft.HBase.Client.Filters 17 | { 18 | using System.Globalization; 19 | 20 | /// 21 | /// A filter that includes rows based on a chance. 22 | /// 23 | public class RandomRowFilter : Filter 24 | { 25 | /// 26 | /// Initializes a new instance of the class. 27 | /// 28 | /// The chance. 29 | public RandomRowFilter(float chance) 30 | { 31 | Chance = chance; 32 | } 33 | 34 | /// 35 | /// Gets the chance. 36 | /// 37 | /// 38 | /// The chance. 39 | /// 40 | public float Chance { get; private set; } 41 | 42 | /// 43 | public override string ToEncodedString() 44 | { 45 | const string filterPattern = @"{{""type"":""RandomRowFilter"",""chance"":{0}}}"; 46 | return string.Format(CultureInfo.InvariantCulture, filterPattern, Chance); 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Microsoft.HBase.Client/Filters/RegexStringComparator.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation 2 | // All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | // use this file except in compliance with the License. You may obtain a copy 6 | // of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 9 | // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 10 | // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 11 | // MERCHANTABLITY OR NON-INFRINGEMENT. 12 | // 13 | // See the Apache Version 2.0 License for specific language governing 14 | // permissions and limitations under the License. 15 | 16 | namespace Microsoft.HBase.Client.Filters 17 | { 18 | using System.Diagnostics.CodeAnalysis; 19 | using System.Globalization; 20 | using System.Text; 21 | 22 | /// 23 | /// This comparator is for use with CompareFilter implementations, such as RowFilter, QualifierFilter, and 24 | /// ValueFilter, for filtering based on the value of a given column. 25 | /// 26 | public class RegexStringComparator : ByteArrayComparable 27 | { 28 | // note: could not get "flags" to stringify, so it has been removed. 29 | 30 | /// 31 | /// Initializes a new instance of the class. 32 | /// 33 | /// The regular expression as a string. 34 | [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "expr")] 35 | public RegexStringComparator(string expr) : base(expr == null ? null : Encoding.UTF8.GetBytes(expr)) 36 | { 37 | } 38 | 39 | /// 40 | public override string ToEncodedString() 41 | { 42 | const string pattern = @"""type"":""RegexStringComparator"", ""value"":""{0}"""; 43 | return string.Format(CultureInfo.InvariantCulture, pattern, Encoding.UTF8.GetString(Value)); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /Microsoft.HBase.Client/Filters/RowFilter.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation 2 | // All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | // use this file except in compliance with the License. You may obtain a copy 6 | // of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 9 | // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 10 | // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 11 | // MERCHANTABLITY OR NON-INFRINGEMENT. 12 | // 13 | // See the Apache Version 2.0 License for specific language governing 14 | // permissions and limitations under the License. 15 | 16 | namespace Microsoft.HBase.Client.Filters 17 | { 18 | using System.Globalization; 19 | using Microsoft.HBase.Client.Internal; 20 | 21 | /// 22 | /// This filter is used to filter based on the key. 23 | /// 24 | public class RowFilter : CompareFilter 25 | { 26 | /// 27 | /// Initializes a new instance of the class. 28 | /// 29 | /// The row compare op. 30 | /// The row comparator. 31 | public RowFilter(CompareOp rowCompareOp, ByteArrayComparable rowComparator) 32 | : base(rowCompareOp, rowComparator) 33 | { 34 | } 35 | 36 | /// 37 | public override string ToEncodedString() 38 | { 39 | const string filterPattern = @"{{""type"":""RowFilter"",""op"":""{0}"",""comparator"":{{{1}}}}}"; 40 | return string.Format(CultureInfo.InvariantCulture, filterPattern, CompareOperation.ToCodeName(), Comparator.ToEncodedString()); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Microsoft.HBase.Client/Filters/SkipFilter.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation 2 | // All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | // use this file except in compliance with the License. You may obtain a copy 6 | // of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 9 | // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 10 | // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 11 | // MERCHANTABLITY OR NON-INFRINGEMENT. 12 | // 13 | // See the Apache Version 2.0 License for specific language governing 14 | // permissions and limitations under the License. 15 | 16 | namespace Microsoft.HBase.Client.Filters 17 | { 18 | using System.Globalization; 19 | using Microsoft.HBase.Client.Internal; 20 | 21 | /// 22 | /// A wrapper filter that filters an entire row if any of the Cell checks do not pass. 23 | /// 24 | /// 25 | /// A wrapper filter that filters an entire row if any of the Cell checks do not pass. 26 | /// For example, if all columns in a row represent weights of different things, with the values being the actual weights, and we want to filter 27 | /// out the entire row if any of its weights are zero. In this case, we want to prevent rows from being emitted if a single key is filtered. 28 | /// Combine this filter with a . 29 | /// 30 | /// var filter = new SkipFilter(new ValueFilter(CompareFilter.CompareOp.NotEqual, new BinaryComparator(BitConverter.GetBytes(0)))); 31 | /// 32 | /// 33 | public class SkipFilter : Filter 34 | { 35 | /// 36 | /// Initializes a new instance of the class. 37 | /// 38 | /// The filter. 39 | public SkipFilter(Filter filter) 40 | { 41 | filter.ArgumentNotNull("filter"); 42 | 43 | Filter = filter; 44 | } 45 | 46 | /// 47 | /// Gets the filter. 48 | /// 49 | /// 50 | /// The filter. 51 | /// 52 | public Filter Filter { get; private set; } 53 | 54 | /// 55 | public override string ToEncodedString() 56 | { 57 | const string filterPattern = @"{{""type"":""SkipFilter"",""filters"":[{0}]}}"; 58 | return string.Format(CultureInfo.InvariantCulture, filterPattern, Filter.ToEncodedString()); 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /Microsoft.HBase.Client/Filters/SubstringComparator.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation 2 | // All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | // use this file except in compliance with the License. You may obtain a copy 6 | // of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 9 | // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 10 | // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 11 | // MERCHANTABLITY OR NON-INFRINGEMENT. 12 | // 13 | // See the Apache Version 2.0 License for specific language governing 14 | // permissions and limitations under the License. 15 | 16 | namespace Microsoft.HBase.Client.Filters 17 | { 18 | using System.Diagnostics.CodeAnalysis; 19 | using System.Globalization; 20 | using System.Text; 21 | 22 | /// 23 | /// A comparator to use with , for filtering based on the value of a given column. 24 | /// 25 | /// 26 | /// Use it to test if a given substring appears in a cell value in the column. The comparison is case insensitive. 27 | /// Only EQUAL or NOT_EQUAL tests are valid with this comparator. 28 | /// 29 | public class SubstringComparator : ByteArrayComparable 30 | { 31 | /// 32 | /// Initializes a new instance of the class. 33 | /// 34 | /// The substring. 35 | [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "substr")] 36 | public SubstringComparator(string substr) : base(substr == null ? null : Encoding.UTF8.GetBytes(substr)) 37 | { 38 | } 39 | 40 | /// 41 | public override string ToEncodedString() 42 | { 43 | const string pattern = @"""type"":""SubstringComparator"", ""value"":""{0}"""; 44 | return string.Format(CultureInfo.InvariantCulture, pattern, Encoding.UTF8.GetString(Value)); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Microsoft.HBase.Client/Filters/TimestampsFilter.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation 2 | // All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | // use this file except in compliance with the License. You may obtain a copy 6 | // of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 9 | // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 10 | // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 11 | // MERCHANTABLITY OR NON-INFRINGEMENT. 12 | // 13 | // See the Apache Version 2.0 License for specific language governing 14 | // permissions and limitations under the License. 15 | 16 | namespace Microsoft.HBase.Client.Filters 17 | { 18 | using System.Collections.Generic; 19 | using System.Globalization; 20 | using System.Linq; 21 | using System.Text; 22 | using Microsoft.HBase.Client.Internal; 23 | 24 | /// 25 | /// Filter that returns only cells whose timestamp (version) is in the specified list of timestamps (versions). 26 | /// 27 | /// 28 | /// Use of this filter overrides any time range/time stamp options specified using Get.setTimeRange(long, long), Scan.setTimeRange(long, long), 29 | /// Get.setTimeStamp(long), or Scan.setTimeStamp(long). 30 | /// 31 | public class TimestampsFilter : Filter 32 | { 33 | private readonly HashSet _timestamps; 34 | 35 | /// 36 | /// Initializes a new instance of the class. 37 | /// 38 | /// The timestamps. 39 | public TimestampsFilter(IEnumerable timestamps) 40 | { 41 | timestamps.ArgumentNotNull("timestamps"); 42 | 43 | _timestamps = new HashSet(timestamps); 44 | } 45 | 46 | /// 47 | /// Gets the timestamps. 48 | /// 49 | /// 50 | /// The timestamps. 51 | /// 52 | public IEnumerable Timestamps 53 | { 54 | get { return _timestamps.ToList(); } 55 | } 56 | 57 | /// 58 | public override string ToEncodedString() 59 | { 60 | const string filterPattern = @"{{""type"":""TimestampsFilter"",""timestamps"":[{0}]}}"; 61 | return string.Format(CultureInfo.InvariantCulture, filterPattern, ToCsvStringWithDoubleQuotedValues(_timestamps)); 62 | } 63 | 64 | internal string ToCsvStringWithDoubleQuotedValues(IEnumerable values) 65 | { 66 | values.ArgumentNotNull("values"); 67 | 68 | var working = new StringBuilder(); 69 | foreach (long v in values) 70 | { 71 | working.AppendFormat(@"""{0}"",", v); 72 | } 73 | 74 | // remove the trailing ',' 75 | return working.ToString(0, working.Length - 1); 76 | } 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /Microsoft.HBase.Client/Filters/ValueFilter.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation 2 | // All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | // use this file except in compliance with the License. You may obtain a copy 6 | // of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 9 | // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 10 | // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 11 | // MERCHANTABLITY OR NON-INFRINGEMENT. 12 | // 13 | // See the Apache Version 2.0 License for specific language governing 14 | // permissions and limitations under the License. 15 | 16 | namespace Microsoft.HBase.Client.Filters 17 | { 18 | using System.Globalization; 19 | using Microsoft.HBase.Client.Internal; 20 | 21 | /// 22 | /// This filter is used to filter based on column value. 23 | /// 24 | public class ValueFilter : CompareFilter 25 | { 26 | /// 27 | /// Initializes a new instance of the class. 28 | /// 29 | /// The value compare op. 30 | /// The value comparator. 31 | public ValueFilter(CompareOp valueCompareOp, ByteArrayComparable valueComparator) : base(valueCompareOp, valueComparator) 32 | { 33 | } 34 | 35 | /// 36 | public override string ToEncodedString() 37 | { 38 | const string filterPattern = @"{{""type"":""ValueFilter"",""op"":""{0}"",""comparator"":{{{1}}}}}"; 39 | return string.Format(CultureInfo.InvariantCulture, filterPattern, CompareOperation.ToCodeName(), Comparator.ToEncodedString()); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Microsoft.HBase.Client/Filters/WhileMatchFilter.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation 2 | // All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | // use this file except in compliance with the License. You may obtain a copy 6 | // of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 9 | // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 10 | // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 11 | // MERCHANTABLITY OR NON-INFRINGEMENT. 12 | // 13 | // See the Apache Version 2.0 License for specific language governing 14 | // permissions and limitations under the License. 15 | namespace Microsoft.HBase.Client.Filters 16 | { 17 | using System.Globalization; 18 | using Microsoft.HBase.Client.Internal; 19 | 20 | /// 21 | /// 22 | /// 23 | public class WhileMatchFilter : Filter 24 | { 25 | /// 26 | /// Initializes a new instance of the class. 27 | /// 28 | /// The filter. 29 | public WhileMatchFilter(Filter filter) 30 | { 31 | filter.ArgumentNotNull("filter"); 32 | 33 | Filter = filter; 34 | } 35 | 36 | /// 37 | /// Gets the filter. 38 | /// 39 | /// 40 | /// The filter. 41 | /// 42 | public Filter Filter { get; private set; } 43 | 44 | /// 45 | public override string ToEncodedString() 46 | { 47 | const string filterPattern = @"{{""type"":""WhileMatchFilter"",""filters"":[{0}]}}"; 48 | return string.Format(CultureInfo.InvariantCulture, filterPattern, Filter.ToEncodedString()); 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /Microsoft.HBase.Client/GlobalSuppressions.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hdinsight/hbase-sdk-for-net/53f2cfbb689f662bed6dd010afbf69dee63d7d39/Microsoft.HBase.Client/GlobalSuppressions.cs -------------------------------------------------------------------------------- /Microsoft.HBase.Client/Internal/ByteArrayEqualityComparer.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation 2 | // All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | // use this file except in compliance with the License. You may obtain a copy 6 | // of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 9 | // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 10 | // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 11 | // MERCHANTABLITY OR NON-INFRINGEMENT. 12 | // 13 | // See the Apache Version 2.0 License for specific language governing 14 | // permissions and limitations under the License. 15 | namespace Microsoft.HBase.Client.Internal 16 | { 17 | using System.Collections.Generic; 18 | using System.Linq; 19 | 20 | internal class ByteArrayEqualityComparer : IEqualityComparer 21 | { 22 | /// 23 | public bool Equals(byte[] x, byte[] y) 24 | { 25 | if (ReferenceEquals(x, null)) 26 | { 27 | return ReferenceEquals(y, null); 28 | } 29 | 30 | if (ReferenceEquals(y, null)) 31 | { 32 | return false; 33 | } 34 | 35 | return x.SequenceEqual(y); 36 | } 37 | 38 | /// 39 | public int GetHashCode(byte[] obj) 40 | { 41 | if (obj == null || obj.Length == 0) 42 | { 43 | return 0; 44 | } 45 | 46 | return obj[0]; 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Microsoft.HBase.Client/Internal/Extensions/ArgumentGuardExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation 2 | // All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | // use this file except in compliance with the License. You may obtain a copy 6 | // of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 9 | // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 10 | // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 11 | // MERCHANTABLITY OR NON-INFRINGEMENT. 12 | // 13 | // See the Apache Version 2.0 License for specific language governing 14 | // permissions and limitations under the License. 15 | 16 | namespace Microsoft.HBase.Client.Internal 17 | { 18 | using System; 19 | using System.Collections; 20 | using System.Collections.Generic; 21 | using System.Linq; 22 | 23 | internal static class ArgumentGuardExtensions 24 | { 25 | internal static void ArgumentNotNull([ValidatedNotNull] this object value, string argumentName) 26 | { 27 | if (ReferenceEquals(value, null)) 28 | { 29 | throw new ArgumentNullException(argumentName ?? string.Empty); 30 | } 31 | } 32 | 33 | internal static void ArgumentNotNullNorContainsNull([ValidatedNotNull] this IEnumerable value, string paramName) where T : class 34 | { 35 | value.ArgumentNotNull(paramName); 36 | 37 | if ((from v in value where ReferenceEquals(v, null) select v).Any()) 38 | { 39 | throw new ArgumentContainsNullException(paramName ?? string.Empty, null, null); 40 | } 41 | } 42 | 43 | internal static void ArgumentNotNullNorEmpty([ValidatedNotNull] this IEnumerable value, string paramName) 44 | { 45 | value.ArgumentNotNull(paramName); 46 | if (!value.Cast().Any()) 47 | { 48 | throw new ArgumentEmptyException(paramName ?? string.Empty, null, null); 49 | } 50 | } 51 | 52 | internal static void ArgumentNotNegative(int value, string name) 53 | { 54 | if (value < 0) 55 | { 56 | throw new ArgumentException(string.Format("Argument {0} wasn't >= 0! Given: {1}", name, value)); 57 | } 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /Microsoft.HBase.Client/Internal/Extensions/ObjectExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation 2 | // All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | // use this file except in compliance with the License. You may obtain a copy 6 | // of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 9 | // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 10 | // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 11 | // MERCHANTABLITY OR NON-INFRINGEMENT. 12 | // 13 | // See the Apache Version 2.0 License for specific language governing 14 | // permissions and limitations under the License. 15 | 16 | namespace Microsoft.HBase.Client.Internal 17 | { 18 | using System.ComponentModel; 19 | using Microsoft.HBase.Client.Filters; 20 | 21 | /// 22 | /// Provides extensions methods to the Object class. 23 | /// 24 | internal static class ObjectExtensions 25 | { 26 | /// 27 | /// Evaluates type compatibility. 28 | /// 29 | /// 30 | /// The type to evaluate against. 31 | /// 32 | /// 33 | /// The object to evaluate compatibility for. 34 | /// 35 | /// 36 | /// True if the object is compatible otherwise false. 37 | /// 38 | internal static bool Is(this object inputValue) 39 | { 40 | return inputValue is T; 41 | } 42 | 43 | /// 44 | /// Determines whether the specified object is not null. 45 | /// 46 | /// The object. 47 | /// 48 | /// true if the specified object is not null; otherwise, false. 49 | /// 50 | internal static bool IsNotNull([ValidatedNotNull] this object inputValue) 51 | { 52 | return !ReferenceEquals(inputValue, null); 53 | } 54 | 55 | /// 56 | /// Determines whether the specified object is null. 57 | /// 58 | /// The object. 59 | /// 60 | /// true if the specified object is null; otherwise, false. 61 | /// 62 | internal static bool IsNull([ValidatedNotNull] this object inputValue) 63 | { 64 | return ReferenceEquals(inputValue, null); 65 | } 66 | 67 | internal static string ToCodeName(this BitComparator.BitwiseOp value) 68 | { 69 | switch (value) 70 | { 71 | case BitComparator.BitwiseOp.And: 72 | return "AND"; 73 | 74 | case BitComparator.BitwiseOp.Or: 75 | return "OR"; 76 | 77 | case BitComparator.BitwiseOp.Xor: 78 | return "XOR"; 79 | 80 | default: 81 | throw new InvalidEnumArgumentException("value", (int)value, typeof(BitComparator.BitwiseOp)); 82 | } 83 | } 84 | 85 | internal static string ToCodeName(this CompareFilter.CompareOp value) 86 | { 87 | switch (value) 88 | { 89 | case CompareFilter.CompareOp.NoOperation: 90 | return "NO_OP"; 91 | 92 | case CompareFilter.CompareOp.Equal: 93 | return "EQUAL"; 94 | 95 | case CompareFilter.CompareOp.NotEqual: 96 | return "NOT_EQUAL"; 97 | 98 | case CompareFilter.CompareOp.GreaterThan: 99 | return "GREATER"; 100 | 101 | case CompareFilter.CompareOp.GreaterThanOrEqualTo: 102 | return "GREATER_OR_EQUAL"; 103 | 104 | case CompareFilter.CompareOp.LessThan: 105 | return "LESS"; 106 | 107 | case CompareFilter.CompareOp.LessThanOrEqualTo: 108 | return "LESS_OR_EQUAL"; 109 | 110 | default: 111 | throw new InvalidEnumArgumentException("value", (int)value, typeof(CompareFilter.CompareOp)); 112 | } 113 | } 114 | 115 | internal static string ToCodeName(this FilterList.Operator value) 116 | { 117 | switch (value) 118 | { 119 | case FilterList.Operator.MustPassAll: 120 | return "MUST_PASS_ALL"; 121 | 122 | case FilterList.Operator.MustPassOne: 123 | return "MUST_PASS_ONE"; 124 | 125 | default: 126 | throw new InvalidEnumArgumentException("value", (int)value, typeof(FilterList.Operator)); 127 | } 128 | } 129 | } 130 | } 131 | -------------------------------------------------------------------------------- /Microsoft.HBase.Client/Internal/Extensions/StringExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation 2 | // All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | // use this file except in compliance with the License. You may obtain a copy 6 | // of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 9 | // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 10 | // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 11 | // MERCHANTABLITY OR NON-INFRINGEMENT. 12 | // 13 | // See the Apache Version 2.0 License for specific language governing 14 | // permissions and limitations under the License. 15 | 16 | namespace Microsoft.HBase.Client.Internal 17 | { 18 | using System; 19 | using System.Security; 20 | 21 | internal static class StringExtensions 22 | { 23 | /// 24 | /// Determines whether the specified string is not null or empty. 25 | /// 26 | /// The string. 27 | /// 28 | /// true if the specified string is not null or empty; otherwise, false. 29 | /// 30 | public static bool IsNotNullOrEmpty(this string value) 31 | { 32 | return string.IsNullOrEmpty(value); 33 | } 34 | 35 | /// 36 | /// Transforms a string into a SecureString. 37 | /// 38 | /// 39 | /// The string to transform. 40 | /// 41 | /// 42 | /// A secure string representing the contents of the original string. 43 | /// 44 | internal static SecureString ToSecureString(this string value) 45 | { 46 | if (value == null) 47 | { 48 | return null; 49 | } 50 | 51 | var rv = new SecureString(); 52 | try 53 | { 54 | foreach (char c in value) 55 | { 56 | rv.AppendChar(c); 57 | } 58 | 59 | return rv; 60 | } 61 | catch (Exception) 62 | { 63 | rv.Dispose(); 64 | throw; 65 | } 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /Microsoft.HBase.Client/Internal/Helpers/DisposableHelp.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation 2 | // All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | // use this file except in compliance with the License. You may obtain a copy 6 | // of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 9 | // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 10 | // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 11 | // MERCHANTABLITY OR NON-INFRINGEMENT. 12 | // 13 | // See the Apache Version 2.0 License for specific language governing 14 | // permissions and limitations under the License. 15 | namespace Microsoft.HBase.Client.Internal 16 | { 17 | using System; 18 | 19 | /// 20 | /// Helper utilities for working with IDisposable. 21 | /// 22 | internal static class DisposableHelp 23 | { 24 | /// 25 | /// Safely creates a disposable object with a default constructor. 26 | /// 27 | /// 28 | /// The motivation is to avoid CA2000 warnings. 29 | /// 30 | /// 31 | /// Thrown when an exception error condition occurs. 32 | /// 33 | /// 34 | /// The type of object to create. 35 | /// 36 | /// 37 | /// The disposable object that has been safely created. 38 | /// 39 | internal static T SafeCreate() where T : class, IDisposable, new() 40 | { 41 | T rv = null; 42 | try 43 | { 44 | rv = new T(); 45 | } 46 | catch (Exception) 47 | { 48 | if (!ReferenceEquals(rv, null)) 49 | { 50 | rv.Dispose(); 51 | } 52 | throw; 53 | } 54 | return rv; 55 | } 56 | 57 | /// 58 | /// Safely creates a disposable object with a custom constructor. 59 | /// 60 | /// 61 | /// The motivation is to avoid CA2000 warnings. 62 | /// 63 | /// 64 | /// Thrown when an exception error condition occurs. 65 | /// 66 | /// 67 | /// The type of object to create. 68 | /// 69 | /// 70 | /// The factory method used to construct the object. 71 | /// 72 | /// 73 | /// The disposable object that has been safely created. 74 | /// 75 | internal static T SafeCreate(Func factory) where T : class, IDisposable 76 | { 77 | factory.ArgumentNotNull("factory"); 78 | 79 | T rv = null; 80 | try 81 | { 82 | rv = factory(); 83 | } 84 | catch (Exception) 85 | { 86 | if (!ReferenceEquals(rv, null)) 87 | { 88 | rv.Dispose(); 89 | } 90 | throw; 91 | } 92 | 93 | return rv; 94 | } 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /Microsoft.HBase.Client/Internal/Helpers/TaskHelpers.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation 2 | // All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | // use this file except in compliance with the License. You may obtain a copy 6 | // of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 9 | // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 10 | // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 11 | // MERCHANTABLITY OR NON-INFRINGEMENT. 12 | // 13 | // See the Apache Version 2.0 License for specific language governing 14 | // permissions and limitations under the License. 15 | 16 | namespace Microsoft.HBase.Client.Internal.Helpers 17 | { 18 | using System.Threading; 19 | using System; 20 | using System.Threading.Tasks; 21 | 22 | internal static class TaskHelpers 23 | { 24 | internal static CancellationTokenSource CreateLinkedCancellationTokenSource(CancellationToken token) 25 | { 26 | return token.CanBeCanceled ? CancellationTokenSource.CreateLinkedTokenSource(token) : new CancellationTokenSource(); 27 | } 28 | 29 | internal static Task WithTimeout(this Task task, TimeSpan timeout, string errorMessage) 30 | { 31 | return WithTimeout(task, timeout, errorMessage, CancellationToken.None); 32 | } 33 | 34 | internal static async Task WithTimeout(this Task task, TimeSpan timeout, string errorMessage, CancellationToken token) 35 | { 36 | using (CancellationTokenSource cts = CreateLinkedCancellationTokenSource(token)) 37 | { 38 | if (task == await Task.WhenAny(task, Task.Delay(timeout, cts.Token))) 39 | { 40 | cts.Cancel(); 41 | return await task; 42 | } 43 | } 44 | 45 | // Ignore fault from task to avoid UnobservedTaskException 46 | task.IgnoreFault(); 47 | 48 | if (token.IsCancellationRequested) 49 | { 50 | token.ThrowIfCancellationRequested(); 51 | } 52 | throw new TimeoutException(String.Format("{0}. Timeout: {1}.", errorMessage, timeout)); 53 | } 54 | 55 | internal static Task WithTimeout(this Task task, TimeSpan timeout, string errorMessage) 56 | { 57 | return WithTimeout(task, timeout, errorMessage, CancellationToken.None); 58 | } 59 | 60 | internal static async Task WithTimeout(this Task task, TimeSpan timeout, string errorMessage, CancellationToken token) 61 | { 62 | using (CancellationTokenSource cts = CreateLinkedCancellationTokenSource(token)) 63 | { 64 | if (task == await Task.WhenAny(task, Task.Delay(timeout, cts.Token))) 65 | { 66 | cts.Cancel(); 67 | await task; 68 | return; 69 | } 70 | } 71 | 72 | // Ignore fault from task to avoid UnobservedTaskException 73 | task.IgnoreFault(); 74 | 75 | if (token.IsCancellationRequested) 76 | { 77 | token.ThrowIfCancellationRequested(); 78 | } 79 | throw new TimeoutException(String.Format("{0}. Timeout: {1}.", errorMessage, timeout)); 80 | } 81 | 82 | internal static void IgnoreFault(this Task task) 83 | { 84 | if (task.IsCompleted) 85 | { 86 | var ignored = task.Exception; 87 | } 88 | else 89 | { 90 | task.ContinueWith 91 | (t => 92 | { 93 | var ignored = t.Exception; 94 | }, 95 | TaskContinuationOptions.OnlyOnFaulted | TaskContinuationOptions.ExecuteSynchronously 96 | ); 97 | } 98 | } 99 | } 100 | 101 | } 102 | -------------------------------------------------------------------------------- /Microsoft.HBase.Client/Internal/ValidatedNotNullAttribute.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation 2 | // All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | // use this file except in compliance with the License. You may obtain a copy 6 | // of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 9 | // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 10 | // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 11 | // MERCHANTABLITY OR NON-INFRINGEMENT. 12 | // 13 | // See the Apache Version 2.0 License for specific language governing 14 | // permissions and limitations under the License. 15 | namespace Microsoft.HBase.Client.Internal 16 | { 17 | using System; 18 | 19 | /// 20 | /// Instructs Code Analysis to treat a method as a validation method for a given parameter and not fire CA1062 when it is used. 21 | /// 22 | [AttributeUsage(AttributeTargets.Parameter)] 23 | internal sealed class ValidatedNotNullAttribute : Attribute 24 | { 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Microsoft.HBase.Client/LoadBalancing/Constants.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation 2 | // All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | // use this file except in compliance with the License. You may obtain a copy 6 | // of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 9 | // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 10 | // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 11 | // MERCHANTABLITY OR NON-INFRINGEMENT. 12 | // 13 | // See the Apache Version 2.0 License for specific language governing 14 | // permissions and limitations under the License. 15 | 16 | namespace Microsoft.HBase.Client.LoadBalancing 17 | { 18 | public class Constants 19 | { 20 | public const string RestEndpointBase = "hbaserest/"; 21 | public const string RestEndpointBaseZero = "hbaserest0/"; 22 | 23 | public const string RefreshIntervalInMillisecondsConfigKey = "RefreshIntervalInMilliseconds"; 24 | public const int RefreshIntervalInMillisecondsDefault = 15 * 60 * 1000; 25 | 26 | public const string WorkerHostNamePrefixConfigKey = "WorkerHostNamePrefix"; 27 | public const string WorkerHostNamePrefixDefault = "workernode"; 28 | 29 | public const string WorkerRestEndpointPortConfigKey = "WorkerRestEndpointPort"; 30 | public const int WorkerRestEndpointPortDefault = 8090; 31 | 32 | public const int LoadBalancingHelperNumRetriesDefault = 5; 33 | 34 | public const int BackOffIntervalDefault = 10; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Microsoft.HBase.Client/LoadBalancing/IEndpointIgnorePolicy.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation 2 | // All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | // use this file except in compliance with the License. You may obtain a copy 6 | // of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 9 | // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 10 | // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 11 | // MERCHANTABLITY OR NON-INFRINGEMENT. 12 | // 13 | // See the Apache Version 2.0 License for specific language governing 14 | // permissions and limitations under the License. 15 | 16 | using System; 17 | 18 | namespace Microsoft.HBase.Client.LoadBalancing 19 | { 20 | public enum EndpointAccessResult 21 | { 22 | Failure = -1, 23 | Success = 0 24 | } 25 | 26 | public interface IEndpointIgnorePolicy 27 | { 28 | IEndpointIgnorePolicy InnerPolicy { get; } 29 | 30 | void OnEndpointAccessStart(Uri endpointUri); 31 | 32 | void OnEndpointAccessCompletion(Uri endpointUri, EndpointAccessResult accessResult); 33 | 34 | bool ShouldIgnoreEndpoint(Uri endpoint); 35 | 36 | void RefreshIgnoredList(); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Microsoft.HBase.Client/LoadBalancing/ILoadBalancer.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation 2 | // All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | // use this file except in compliance with the License. You may obtain a copy 6 | // of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 9 | // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 10 | // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 11 | // MERCHANTABLITY OR NON-INFRINGEMENT. 12 | // 13 | // See the Apache Version 2.0 License for specific language governing 14 | // permissions and limitations under the License. 15 | 16 | using System; 17 | 18 | namespace Microsoft.HBase.Client.LoadBalancing 19 | { 20 | public interface ILoadBalancer 21 | { 22 | Uri GetEndpoint(); 23 | void RecordSuccess(Uri endpoint); 24 | void RecordFailure(Uri endpoint); 25 | int GetNumAvailableEndpoints(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Microsoft.HBase.Client/Microsoft.HBase.Client.csproj.DotSettings: -------------------------------------------------------------------------------- 1 |  2 | True 3 | True 4 | True 5 | True 6 | True -------------------------------------------------------------------------------- /Microsoft.HBase.Client/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation 2 | // All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | // use this file except in compliance with the License. You may obtain a copy 6 | // of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 9 | // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 10 | // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 11 | // MERCHANTABLITY OR NON-INFRINGEMENT. 12 | // 13 | // See the Apache Version 2.0 License for specific language governing 14 | // permissions and limitations under the License. 15 | using System; 16 | using System.Reflection; 17 | using System.Runtime.CompilerServices; 18 | using System.Runtime.InteropServices; 19 | 20 | [assembly: AssemblyTitle("Microsoft.HBase.Client")] 21 | [assembly: AssemblyDescription("")] 22 | [assembly: AssemblyConfiguration("")] 23 | [assembly: AssemblyCompany("Microsoft Corporation")] 24 | [assembly: AssemblyProduct("Microsoft.HBase.Client")] 25 | [assembly: AssemblyCopyright("Copyright © Microsoft Corporation 2014")] 26 | [assembly: AssemblyTrademark("")] 27 | [assembly: AssemblyCulture("")] 28 | 29 | [assembly: ComVisible(false)] 30 | [assembly: CLSCompliant(true)] 31 | 32 | [assembly: AssemblyVersion("0.2.0.0")] 33 | [assembly: AssemblyFileVersion("0.2.0.0")] 34 | 35 | [assembly: InternalsVisibleTo("Microsoft.HBase.Client.Tests")] 36 | -------------------------------------------------------------------------------- /Microsoft.HBase.Client/RequestOptions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation 2 | // All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | // use this file except in compliance with the License. You may obtain a copy 6 | // of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 9 | // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 10 | // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 11 | // MERCHANTABLITY OR NON-INFRINGEMENT. 12 | // 13 | // See the Apache Version 2.0 License for specific language governing 14 | // permissions and limitations under the License. 15 | 16 | namespace Microsoft.HBase.Client 17 | { 18 | using System.Collections.Generic; 19 | using Microsoft.HBase.Client.Internal; 20 | using Microsoft.HBase.Client.LoadBalancing; 21 | using Microsoft.Practices.EnterpriseLibrary.TransientFaultHandling; 22 | 23 | public class RequestOptions 24 | { 25 | public RetryPolicy RetryPolicy { get; set; } 26 | public string AlternativeEndpoint { get; set; } 27 | public bool KeepAlive { get; set; } 28 | public int TimeoutMillis { get; set; } 29 | public int SerializationBufferSize { get; set; } 30 | public int ReceiveBufferSize { get; set; } 31 | public bool UseNagle { get; set; } 32 | public int Port { get; set; } 33 | public Dictionary AdditionalHeaders { get; set; } 34 | public string AlternativeHost { get; set; } 35 | 36 | public void Validate() 37 | { 38 | RetryPolicy.ArgumentNotNull("RetryPolicy"); 39 | ArgumentGuardExtensions.ArgumentNotNegative(TimeoutMillis, "TimeoutMillis"); 40 | ArgumentGuardExtensions.ArgumentNotNegative(ReceiveBufferSize, "ReceiveBufferSize"); 41 | ArgumentGuardExtensions.ArgumentNotNegative(SerializationBufferSize, "SerializationBufferSize"); 42 | ArgumentGuardExtensions.ArgumentNotNegative(Port, "Port"); 43 | } 44 | 45 | public static RequestOptions GetDefaultOptions() 46 | { 47 | return new RequestOptions() 48 | { 49 | RetryPolicy = RetryPolicy.NoRetry, 50 | KeepAlive = true, 51 | TimeoutMillis = 30000, 52 | ReceiveBufferSize = 1024 * 1024 * 1, 53 | SerializationBufferSize = 1024 * 1024 * 1, 54 | UseNagle = false, 55 | AlternativeEndpoint = Constants.RestEndpointBase, 56 | Port = 443, 57 | AlternativeHost = null 58 | }; 59 | } 60 | 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /Microsoft.HBase.Client/Requester/IWebRequester.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation 2 | // All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | // use this file except in compliance with the License. You may obtain a copy 6 | // of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 9 | // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 10 | // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 11 | // MERCHANTABLITY OR NON-INFRINGEMENT. 12 | // 13 | // See the Apache Version 2.0 License for specific language governing 14 | // permissions and limitations under the License. 15 | 16 | namespace Microsoft.HBase.Client.Requester 17 | { 18 | using System; 19 | using System.IO; 20 | using System.Net; 21 | using System.Threading.Tasks; 22 | 23 | public interface IWebRequester 24 | { 25 | Response IssueWebRequest(string endpoint, string query, string method, Stream input, RequestOptions options); 26 | 27 | Task IssueWebRequestAsync(string endpoint, string query, string method, Stream input, RequestOptions options); 28 | } 29 | 30 | public class Response : IDisposable 31 | { 32 | public HttpWebResponse WebResponse { get; set; } 33 | public TimeSpan RequestLatency { get; set; } 34 | public Action PostRequestAction { get; set; } 35 | 36 | /// 37 | /// Used to detect redundant calls to . 38 | /// 39 | private bool _isDisposed; // To detect redundant calls 40 | 41 | /// 42 | /// Releases unmanaged and - optionally - managed resources. 43 | /// 44 | /// 45 | /// to release both managed and unmanaged resources; to release only unmanaged resources. 47 | /// 48 | protected virtual void Dispose(bool disposing) 49 | { 50 | if (!_isDisposed) 51 | { 52 | if (disposing) 53 | { 54 | if (PostRequestAction != null) 55 | { 56 | PostRequestAction(this); 57 | PostRequestAction = null; 58 | } 59 | WebResponse.Dispose(); 60 | WebResponse = null; 61 | } 62 | _isDisposed = true; 63 | } 64 | } 65 | 66 | /// 67 | /// Performs application-defined tasks associated with freeing, releasing, or resetting 68 | /// unmanaged resources. 69 | /// 70 | public void Dispose() 71 | { 72 | Dispose(true); 73 | // Since this class is not sealed, derived classes may introduce unmanaged resources, so 74 | // suppress Finalize calls if the instance has been disposed. 75 | GC.SuppressFinalize(this); 76 | } 77 | } 78 | } -------------------------------------------------------------------------------- /Microsoft.HBase.Client/ScannerInformation.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation 2 | // All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | // use this file except in compliance with the License. You may obtain a copy 6 | // of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 9 | // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 10 | // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 11 | // MERCHANTABLITY OR NON-INFRINGEMENT. 12 | // 13 | // See the Apache Version 2.0 License for specific language governing 14 | // permissions and limitations under the License. 15 | 16 | namespace Microsoft.HBase.Client 17 | { 18 | using System; 19 | using System.Net; 20 | using Microsoft.HBase.Client.Internal; 21 | 22 | /// 23 | /// 24 | /// 25 | [Serializable] 26 | public sealed class ScannerInformation 27 | { 28 | /// 29 | /// Initializes a new instance of the class. 30 | /// 31 | /// The location. 32 | /// Name of the table. 33 | /// additional header information from the response 34 | public ScannerInformation(Uri location, string tableName, WebHeaderCollection responseHeaderCollection) 35 | { 36 | location.ArgumentNotNull("location"); 37 | tableName.ArgumentNotNullNorEmpty("tableName"); 38 | responseHeaderCollection.ArgumentNotNull("responseHeaderCollection"); 39 | 40 | Location = location; 41 | TableName = tableName; 42 | ResponseHeaderCollection = responseHeaderCollection; 43 | } 44 | 45 | /// 46 | /// Gets the location. 47 | /// 48 | /// 49 | /// The location. 50 | /// 51 | public Uri Location { get; private set; } 52 | 53 | /// 54 | /// Gets the scanner identifier. 55 | /// 56 | /// 57 | /// The scanner identifier. 58 | /// 59 | public string ScannerId 60 | { 61 | get { return Location.PathAndQuery.Substring(Location.PathAndQuery.LastIndexOf('/') + 1); } 62 | } 63 | 64 | /// 65 | /// Additional headers from the CreateScanner response. 66 | /// This can be used to implement a sticky load balancing, e.g. by supplying a remote identifier. 67 | /// 68 | public WebHeaderCollection ResponseHeaderCollection { get; private set; } 69 | 70 | /// 71 | /// Gets the name of the table. 72 | /// 73 | /// 74 | /// The name of the table. 75 | /// 76 | public string TableName { get; private set; } 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /Microsoft.HBase.Client/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /Production.FxCop.ruleset: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /Test.FxCop.ruleset: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /TestSettings.testsettings: -------------------------------------------------------------------------------- 1 |  2 | 3 | These are default test settings for a local test run. This file is required to be included in your *.sln file in order execute tests with the R# test runner. 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 |
17 |
18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /schemas/ProtoBuf/CellMessage.proto: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to the Apache Software Foundation (ASF) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. The ASF licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | 18 | package org.apache.hadoop.hbase.rest.protobuf.generated; 19 | 20 | message Cell { 21 | optional bytes row = 1; // unused if Cell is in a CellSet 22 | optional bytes column = 2; 23 | optional int64 timestamp = 3; 24 | optional bytes data = 4; 25 | } 26 | -------------------------------------------------------------------------------- /schemas/ProtoBuf/CellSetMessage.proto: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to the Apache Software Foundation (ASF) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. The ASF licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | 18 | import "CellMessage.proto"; 19 | 20 | package org.apache.hadoop.hbase.rest.protobuf.generated; 21 | 22 | message CellSet { 23 | message Row { 24 | required bytes key = 1; 25 | repeated Cell values = 2; 26 | } 27 | repeated Row rows = 1; 28 | } 29 | -------------------------------------------------------------------------------- /schemas/ProtoBuf/ColumnSchemaMessage.proto: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to the Apache Software Foundation (ASF) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. The ASF licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | 18 | package org.apache.hadoop.hbase.rest.protobuf.generated; 19 | 20 | message ColumnSchema { 21 | optional string name = 1; 22 | message Attribute { 23 | required string name = 1; 24 | required string value = 2; 25 | } 26 | repeated Attribute attrs = 2; 27 | // optional helpful encodings of commonly used attributes 28 | optional int32 ttl = 3; 29 | optional int32 maxVersions = 4; 30 | optional string compression = 5; 31 | } 32 | -------------------------------------------------------------------------------- /schemas/ProtoBuf/Generated/CellMessage.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // 5 | // Changes to this file may cause incorrect behavior and will be lost if 6 | // the code is regenerated. 7 | // 8 | //------------------------------------------------------------------------------ 9 | 10 | // Generated from: CellMessage.proto 11 | namespace org.apache.hadoop.hbase.rest.protobuf.generated 12 | { 13 | [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"Cell")] 14 | public partial class Cell : global::ProtoBuf.IExtensible 15 | { 16 | public Cell() {} 17 | 18 | private byte[] _row = null; 19 | [global::ProtoBuf.ProtoMember(1, IsRequired = false, Name=@"row", DataFormat = global::ProtoBuf.DataFormat.Default)] 20 | [global::System.ComponentModel.DefaultValue(null)] 21 | public byte[] row 22 | { 23 | get { return _row; } 24 | set { _row = value; } 25 | } 26 | private byte[] _column = null; 27 | [global::ProtoBuf.ProtoMember(2, IsRequired = false, Name=@"column", DataFormat = global::ProtoBuf.DataFormat.Default)] 28 | [global::System.ComponentModel.DefaultValue(null)] 29 | public byte[] column 30 | { 31 | get { return _column; } 32 | set { _column = value; } 33 | } 34 | private long _timestamp = default(long); 35 | [global::ProtoBuf.ProtoMember(3, IsRequired = false, Name=@"timestamp", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)] 36 | [global::System.ComponentModel.DefaultValue(default(long))] 37 | public long timestamp 38 | { 39 | get { return _timestamp; } 40 | set { _timestamp = value; } 41 | } 42 | private byte[] _data = null; 43 | [global::ProtoBuf.ProtoMember(4, IsRequired = false, Name=@"data", DataFormat = global::ProtoBuf.DataFormat.Default)] 44 | [global::System.ComponentModel.DefaultValue(null)] 45 | public byte[] data 46 | { 47 | get { return _data; } 48 | set { _data = value; } 49 | } 50 | private global::ProtoBuf.IExtension extensionObject; 51 | global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing) 52 | { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); } 53 | } 54 | 55 | } -------------------------------------------------------------------------------- /schemas/ProtoBuf/Generated/CellSetMessage.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // 5 | // Changes to this file may cause incorrect behavior and will be lost if 6 | // the code is regenerated. 7 | // 8 | //------------------------------------------------------------------------------ 9 | 10 | // Generated from: CellSetMessage.proto 11 | // Note: requires additional types generated from: CellMessage.proto 12 | namespace org.apache.hadoop.hbase.rest.protobuf.generated 13 | { 14 | [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"CellSet")] 15 | public partial class CellSet : global::ProtoBuf.IExtensible 16 | { 17 | public CellSet() {} 18 | 19 | private readonly global::System.Collections.Generic.List _rows = new global::System.Collections.Generic.List(); 20 | [global::ProtoBuf.ProtoMember(1, Name=@"rows", DataFormat = global::ProtoBuf.DataFormat.Default)] 21 | public global::System.Collections.Generic.List rows 22 | { 23 | get { return _rows; } 24 | } 25 | 26 | [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"Row")] 27 | public partial class Row : global::ProtoBuf.IExtensible 28 | { 29 | public Row() {} 30 | 31 | private byte[] _key; 32 | [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"key", DataFormat = global::ProtoBuf.DataFormat.Default)] 33 | public byte[] key 34 | { 35 | get { return _key; } 36 | set { _key = value; } 37 | } 38 | private readonly global::System.Collections.Generic.List _values = new global::System.Collections.Generic.List(); 39 | [global::ProtoBuf.ProtoMember(2, Name=@"values", DataFormat = global::ProtoBuf.DataFormat.Default)] 40 | public global::System.Collections.Generic.List values 41 | { 42 | get { return _values; } 43 | } 44 | 45 | private global::ProtoBuf.IExtension extensionObject; 46 | global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing) 47 | { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); } 48 | } 49 | 50 | private global::ProtoBuf.IExtension extensionObject; 51 | global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing) 52 | { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); } 53 | } 54 | 55 | } -------------------------------------------------------------------------------- /schemas/ProtoBuf/Generated/ColumnSchemaMessage.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // 5 | // Changes to this file may cause incorrect behavior and will be lost if 6 | // the code is regenerated. 7 | // 8 | //------------------------------------------------------------------------------ 9 | 10 | // Generated from: ColumnSchemaMessage.proto 11 | namespace org.apache.hadoop.hbase.rest.protobuf.generated 12 | { 13 | [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"ColumnSchema")] 14 | public partial class ColumnSchema : global::ProtoBuf.IExtensible 15 | { 16 | public ColumnSchema() {} 17 | 18 | private string _name = ""; 19 | [global::ProtoBuf.ProtoMember(1, IsRequired = false, Name=@"name", DataFormat = global::ProtoBuf.DataFormat.Default)] 20 | [global::System.ComponentModel.DefaultValue("")] 21 | public string name 22 | { 23 | get { return _name; } 24 | set { _name = value; } 25 | } 26 | private readonly global::System.Collections.Generic.List _attrs = new global::System.Collections.Generic.List(); 27 | [global::ProtoBuf.ProtoMember(2, Name=@"attrs", DataFormat = global::ProtoBuf.DataFormat.Default)] 28 | public global::System.Collections.Generic.List attrs 29 | { 30 | get { return _attrs; } 31 | } 32 | 33 | private int _ttl = default(int); 34 | [global::ProtoBuf.ProtoMember(3, IsRequired = false, Name=@"ttl", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)] 35 | [global::System.ComponentModel.DefaultValue(default(int))] 36 | public int ttl 37 | { 38 | get { return _ttl; } 39 | set { _ttl = value; } 40 | } 41 | private int _maxVersions = default(int); 42 | [global::ProtoBuf.ProtoMember(4, IsRequired = false, Name=@"maxVersions", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)] 43 | [global::System.ComponentModel.DefaultValue(default(int))] 44 | public int maxVersions 45 | { 46 | get { return _maxVersions; } 47 | set { _maxVersions = value; } 48 | } 49 | private string _compression = ""; 50 | [global::ProtoBuf.ProtoMember(5, IsRequired = false, Name=@"compression", DataFormat = global::ProtoBuf.DataFormat.Default)] 51 | [global::System.ComponentModel.DefaultValue("")] 52 | public string compression 53 | { 54 | get { return _compression; } 55 | set { _compression = value; } 56 | } 57 | [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"Attribute")] 58 | public partial class Attribute : global::ProtoBuf.IExtensible 59 | { 60 | public Attribute() {} 61 | 62 | private string _name; 63 | [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"name", DataFormat = global::ProtoBuf.DataFormat.Default)] 64 | public string name 65 | { 66 | get { return _name; } 67 | set { _name = value; } 68 | } 69 | private string _value; 70 | [global::ProtoBuf.ProtoMember(2, IsRequired = true, Name=@"value", DataFormat = global::ProtoBuf.DataFormat.Default)] 71 | public string value 72 | { 73 | get { return _value; } 74 | set { _value = value; } 75 | } 76 | private global::ProtoBuf.IExtension extensionObject; 77 | global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing) 78 | { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); } 79 | } 80 | 81 | private global::ProtoBuf.IExtension extensionObject; 82 | global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing) 83 | { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); } 84 | } 85 | 86 | } -------------------------------------------------------------------------------- /schemas/ProtoBuf/Generated/ScannerMessage.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // 5 | // Changes to this file may cause incorrect behavior and will be lost if 6 | // the code is regenerated. 7 | // 8 | //------------------------------------------------------------------------------ 9 | 10 | // Generated from: ScannerMessage.proto 11 | namespace org.apache.hadoop.hbase.rest.protobuf.generated 12 | { 13 | [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"Scanner")] 14 | public partial class Scanner : global::ProtoBuf.IExtensible 15 | { 16 | public Scanner() {} 17 | 18 | private byte[] _startRow = null; 19 | [global::ProtoBuf.ProtoMember(1, IsRequired = false, Name=@"startRow", DataFormat = global::ProtoBuf.DataFormat.Default)] 20 | [global::System.ComponentModel.DefaultValue(null)] 21 | public byte[] startRow 22 | { 23 | get { return _startRow; } 24 | set { _startRow = value; } 25 | } 26 | private byte[] _endRow = null; 27 | [global::ProtoBuf.ProtoMember(2, IsRequired = false, Name=@"endRow", DataFormat = global::ProtoBuf.DataFormat.Default)] 28 | [global::System.ComponentModel.DefaultValue(null)] 29 | public byte[] endRow 30 | { 31 | get { return _endRow; } 32 | set { _endRow = value; } 33 | } 34 | private readonly global::System.Collections.Generic.List _columns = new global::System.Collections.Generic.List(); 35 | [global::ProtoBuf.ProtoMember(3, Name=@"columns", DataFormat = global::ProtoBuf.DataFormat.Default)] 36 | public global::System.Collections.Generic.List columns 37 | { 38 | get { return _columns; } 39 | } 40 | 41 | private int _batch = default(int); 42 | [global::ProtoBuf.ProtoMember(4, IsRequired = false, Name=@"batch", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)] 43 | [global::System.ComponentModel.DefaultValue(default(int))] 44 | public int batch 45 | { 46 | get { return _batch; } 47 | set { _batch = value; } 48 | } 49 | private long _startTime = default(long); 50 | [global::ProtoBuf.ProtoMember(5, IsRequired = false, Name=@"startTime", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)] 51 | [global::System.ComponentModel.DefaultValue(default(long))] 52 | public long startTime 53 | { 54 | get { return _startTime; } 55 | set { _startTime = value; } 56 | } 57 | private long _endTime = default(long); 58 | [global::ProtoBuf.ProtoMember(6, IsRequired = false, Name=@"endTime", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)] 59 | [global::System.ComponentModel.DefaultValue(default(long))] 60 | public long endTime 61 | { 62 | get { return _endTime; } 63 | set { _endTime = value; } 64 | } 65 | private int _maxVersions = default(int); 66 | [global::ProtoBuf.ProtoMember(7, IsRequired = false, Name=@"maxVersions", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)] 67 | [global::System.ComponentModel.DefaultValue(default(int))] 68 | public int maxVersions 69 | { 70 | get { return _maxVersions; } 71 | set { _maxVersions = value; } 72 | } 73 | private string _filter = ""; 74 | [global::ProtoBuf.ProtoMember(8, IsRequired = false, Name=@"filter", DataFormat = global::ProtoBuf.DataFormat.Default)] 75 | [global::System.ComponentModel.DefaultValue("")] 76 | public string filter 77 | { 78 | get { return _filter; } 79 | set { _filter = value; } 80 | } 81 | private int _caching = default(int); 82 | [global::ProtoBuf.ProtoMember(9, IsRequired = false, Name=@"caching", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)] 83 | [global::System.ComponentModel.DefaultValue(default(int))] 84 | public int caching 85 | { 86 | get { return _caching; } 87 | set { _caching = value; } 88 | } 89 | private global::ProtoBuf.IExtension extensionObject; 90 | global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing) 91 | { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); } 92 | } 93 | 94 | } -------------------------------------------------------------------------------- /schemas/ProtoBuf/Generated/TableInfoMessage.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // 5 | // Changes to this file may cause incorrect behavior and will be lost if 6 | // the code is regenerated. 7 | // 8 | //------------------------------------------------------------------------------ 9 | 10 | // Generated from: TableInfoMessage.proto 11 | namespace org.apache.hadoop.hbase.rest.protobuf.generated 12 | { 13 | [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"TableInfo")] 14 | public partial class TableInfo : global::ProtoBuf.IExtensible 15 | { 16 | public TableInfo() {} 17 | 18 | private string _name; 19 | [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"name", DataFormat = global::ProtoBuf.DataFormat.Default)] 20 | public string name 21 | { 22 | get { return _name; } 23 | set { _name = value; } 24 | } 25 | private readonly global::System.Collections.Generic.List _regions = new global::System.Collections.Generic.List(); 26 | [global::ProtoBuf.ProtoMember(2, Name=@"regions", DataFormat = global::ProtoBuf.DataFormat.Default)] 27 | public global::System.Collections.Generic.List regions 28 | { 29 | get { return _regions; } 30 | } 31 | 32 | [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"Region")] 33 | public partial class Region : global::ProtoBuf.IExtensible 34 | { 35 | public Region() {} 36 | 37 | private string _name; 38 | [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"name", DataFormat = global::ProtoBuf.DataFormat.Default)] 39 | public string name 40 | { 41 | get { return _name; } 42 | set { _name = value; } 43 | } 44 | private byte[] _startKey = null; 45 | [global::ProtoBuf.ProtoMember(2, IsRequired = false, Name=@"startKey", DataFormat = global::ProtoBuf.DataFormat.Default)] 46 | [global::System.ComponentModel.DefaultValue(null)] 47 | public byte[] startKey 48 | { 49 | get { return _startKey; } 50 | set { _startKey = value; } 51 | } 52 | private byte[] _endKey = null; 53 | [global::ProtoBuf.ProtoMember(3, IsRequired = false, Name=@"endKey", DataFormat = global::ProtoBuf.DataFormat.Default)] 54 | [global::System.ComponentModel.DefaultValue(null)] 55 | public byte[] endKey 56 | { 57 | get { return _endKey; } 58 | set { _endKey = value; } 59 | } 60 | private long _id = default(long); 61 | [global::ProtoBuf.ProtoMember(4, IsRequired = false, Name=@"id", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)] 62 | [global::System.ComponentModel.DefaultValue(default(long))] 63 | public long id 64 | { 65 | get { return _id; } 66 | set { _id = value; } 67 | } 68 | private string _location = ""; 69 | [global::ProtoBuf.ProtoMember(5, IsRequired = false, Name=@"location", DataFormat = global::ProtoBuf.DataFormat.Default)] 70 | [global::System.ComponentModel.DefaultValue("")] 71 | public string location 72 | { 73 | get { return _location; } 74 | set { _location = value; } 75 | } 76 | private global::ProtoBuf.IExtension extensionObject; 77 | global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing) 78 | { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); } 79 | } 80 | 81 | private global::ProtoBuf.IExtension extensionObject; 82 | global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing) 83 | { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); } 84 | } 85 | 86 | } -------------------------------------------------------------------------------- /schemas/ProtoBuf/Generated/TableListMessage.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // 5 | // Changes to this file may cause incorrect behavior and will be lost if 6 | // the code is regenerated. 7 | // 8 | //------------------------------------------------------------------------------ 9 | 10 | // Generated from: TableListMessage.proto 11 | namespace org.apache.hadoop.hbase.rest.protobuf.generated 12 | { 13 | [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"TableList")] 14 | public partial class TableList : global::ProtoBuf.IExtensible 15 | { 16 | public TableList() {} 17 | 18 | private readonly global::System.Collections.Generic.List _name = new global::System.Collections.Generic.List(); 19 | [global::ProtoBuf.ProtoMember(1, Name=@"name", DataFormat = global::ProtoBuf.DataFormat.Default)] 20 | public global::System.Collections.Generic.List name 21 | { 22 | get { return _name; } 23 | } 24 | 25 | private global::ProtoBuf.IExtension extensionObject; 26 | global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing) 27 | { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); } 28 | } 29 | 30 | } -------------------------------------------------------------------------------- /schemas/ProtoBuf/Generated/TableSchemaMessage.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // 5 | // Changes to this file may cause incorrect behavior and will be lost if 6 | // the code is regenerated. 7 | // 8 | //------------------------------------------------------------------------------ 9 | 10 | // Generated from: TableSchemaMessage.proto 11 | // Note: requires additional types generated from: ColumnSchemaMessage.proto 12 | namespace org.apache.hadoop.hbase.rest.protobuf.generated 13 | { 14 | [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"TableSchema")] 15 | public partial class TableSchema : global::ProtoBuf.IExtensible 16 | { 17 | public TableSchema() {} 18 | 19 | private string _name = ""; 20 | [global::ProtoBuf.ProtoMember(1, IsRequired = false, Name=@"name", DataFormat = global::ProtoBuf.DataFormat.Default)] 21 | [global::System.ComponentModel.DefaultValue("")] 22 | public string name 23 | { 24 | get { return _name; } 25 | set { _name = value; } 26 | } 27 | private readonly global::System.Collections.Generic.List _attrs = new global::System.Collections.Generic.List(); 28 | [global::ProtoBuf.ProtoMember(2, Name=@"attrs", DataFormat = global::ProtoBuf.DataFormat.Default)] 29 | public global::System.Collections.Generic.List attrs 30 | { 31 | get { return _attrs; } 32 | } 33 | 34 | private readonly global::System.Collections.Generic.List _columns = new global::System.Collections.Generic.List(); 35 | [global::ProtoBuf.ProtoMember(3, Name=@"columns", DataFormat = global::ProtoBuf.DataFormat.Default)] 36 | public global::System.Collections.Generic.List columns 37 | { 38 | get { return _columns; } 39 | } 40 | 41 | private bool _inMemory = default(bool); 42 | [global::ProtoBuf.ProtoMember(4, IsRequired = false, Name=@"inMemory", DataFormat = global::ProtoBuf.DataFormat.Default)] 43 | [global::System.ComponentModel.DefaultValue(default(bool))] 44 | public bool inMemory 45 | { 46 | get { return _inMemory; } 47 | set { _inMemory = value; } 48 | } 49 | private bool _readOnly = default(bool); 50 | [global::ProtoBuf.ProtoMember(5, IsRequired = false, Name=@"readOnly", DataFormat = global::ProtoBuf.DataFormat.Default)] 51 | [global::System.ComponentModel.DefaultValue(default(bool))] 52 | public bool readOnly 53 | { 54 | get { return _readOnly; } 55 | set { _readOnly = value; } 56 | } 57 | [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"Attribute")] 58 | public partial class Attribute : global::ProtoBuf.IExtensible 59 | { 60 | public Attribute() {} 61 | 62 | private string _name; 63 | [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"name", DataFormat = global::ProtoBuf.DataFormat.Default)] 64 | public string name 65 | { 66 | get { return _name; } 67 | set { _name = value; } 68 | } 69 | private string _value; 70 | [global::ProtoBuf.ProtoMember(2, IsRequired = true, Name=@"value", DataFormat = global::ProtoBuf.DataFormat.Default)] 71 | public string value 72 | { 73 | get { return _value; } 74 | set { _value = value; } 75 | } 76 | private global::ProtoBuf.IExtension extensionObject; 77 | global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing) 78 | { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); } 79 | } 80 | 81 | private global::ProtoBuf.IExtension extensionObject; 82 | global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing) 83 | { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); } 84 | } 85 | 86 | } -------------------------------------------------------------------------------- /schemas/ProtoBuf/Generated/VersionMessage.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // 5 | // Changes to this file may cause incorrect behavior and will be lost if 6 | // the code is regenerated. 7 | // 8 | //------------------------------------------------------------------------------ 9 | 10 | // Generated from: VersionMessage.proto 11 | namespace org.apache.hadoop.hbase.rest.protobuf.generated 12 | { 13 | [global::System.Serializable, global::ProtoBuf.ProtoContract(Name = @"Version")] 14 | public partial class Version : global::ProtoBuf.IExtensible 15 | { 16 | public Version() { } 17 | 18 | private string _restVersion = ""; 19 | [global::ProtoBuf.ProtoMember(1, IsRequired = false, Name = @"restVersion", DataFormat = global::ProtoBuf.DataFormat.Default)] 20 | [global::System.ComponentModel.DefaultValue("")] 21 | public string restVersion 22 | { 23 | get { return _restVersion; } 24 | set { _restVersion = value; } 25 | } 26 | private string _jvmVersion = ""; 27 | [global::ProtoBuf.ProtoMember(2, IsRequired = false, Name = @"jvmVersion", DataFormat = global::ProtoBuf.DataFormat.Default)] 28 | [global::System.ComponentModel.DefaultValue("")] 29 | public string jvmVersion 30 | { 31 | get { return _jvmVersion; } 32 | set { _jvmVersion = value; } 33 | } 34 | private string _osVersion = ""; 35 | [global::ProtoBuf.ProtoMember(3, IsRequired = false, Name = @"osVersion", DataFormat = global::ProtoBuf.DataFormat.Default)] 36 | [global::System.ComponentModel.DefaultValue("")] 37 | public string osVersion 38 | { 39 | get { return _osVersion; } 40 | set { _osVersion = value; } 41 | } 42 | private string _serverVersion = ""; 43 | [global::ProtoBuf.ProtoMember(4, IsRequired = false, Name = @"serverVersion", DataFormat = global::ProtoBuf.DataFormat.Default)] 44 | [global::System.ComponentModel.DefaultValue("")] 45 | public string serverVersion 46 | { 47 | get { return _serverVersion; } 48 | set { _serverVersion = value; } 49 | } 50 | private string _jerseyVersion = ""; 51 | [global::ProtoBuf.ProtoMember(5, IsRequired = false, Name = @"jerseyVersion", DataFormat = global::ProtoBuf.DataFormat.Default)] 52 | [global::System.ComponentModel.DefaultValue("")] 53 | public string jerseyVersion 54 | { 55 | get { return _jerseyVersion; } 56 | set { _jerseyVersion = value; } 57 | } 58 | private global::ProtoBuf.IExtension extensionObject; 59 | global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing) 60 | { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); } 61 | 62 | public override string ToString() 63 | { 64 | return string.Format("RestVersion: {0}, JvmVersion: {1}, OsVersion: {2}, ServerVersion: {3}, JerseyVersion: {4}, ExtensionObject: {5}", _restVersion, _jvmVersion, _osVersion, _serverVersion, _jerseyVersion, extensionObject); 65 | } 66 | } 67 | 68 | } -------------------------------------------------------------------------------- /schemas/ProtoBuf/ProtoGen/Licence.txt: -------------------------------------------------------------------------------- 1 | The core Protocol Buffers technology is provided courtesy of Google. 2 | At the time of writing, this is released under the BSD license. 3 | Full details can be found here: 4 | 5 | http://code.google.com/p/protobuf/ 6 | 7 | 8 | This .NET implementation is Copyright 2008 Marc Gravell 9 | 10 | Licensed under the Apache License, Version 2.0 (the "License"); 11 | you may not use this file except in compliance with the License. 12 | You may obtain a copy of the License at 13 | 14 | http://www.apache.org/licenses/LICENSE-2.0 15 | 16 | Unless required by applicable law or agreed to in writing, software 17 | distributed under the License is distributed on an "AS IS" BASIS, 18 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | See the License for the specific language governing permissions and 20 | limitations under the License. 21 | -------------------------------------------------------------------------------- /schemas/ProtoBuf/ProtoGen/protobuf-net.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hdinsight/hbase-sdk-for-net/53f2cfbb689f662bed6dd010afbf69dee63d7d39/schemas/ProtoBuf/ProtoGen/protobuf-net.dll -------------------------------------------------------------------------------- /schemas/ProtoBuf/ProtoGen/protoc-license.txt: -------------------------------------------------------------------------------- 1 | Protocol Buffers - Google's data interchange format 2 | Copyright 2008 Google Inc. 3 | http://code.google.com/p/protobuf/ 4 | 5 | This package contains a precompiled Win32 binary version of the protocol buffer 6 | compiler (protoc). This binary is intended for Windows users who want to 7 | use Protocol Buffers in Java or Python but do not want to compile protoc 8 | themselves. To install, simply place this binary somewhere in your PATH. 9 | 10 | This binary was built using MinGW, but the output is the same regardless of 11 | the C++ compiler used. 12 | 13 | You will still need to download the source code package in order to obtain the 14 | Java or Python runtime libraries. Get it from: 15 | http://code.google.com/p/protobuf/downloads/ 16 | -------------------------------------------------------------------------------- /schemas/ProtoBuf/ProtoGen/protogen.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hdinsight/hbase-sdk-for-net/53f2cfbb689f662bed6dd010afbf69dee63d7d39/schemas/ProtoBuf/ProtoGen/protogen.exe -------------------------------------------------------------------------------- /schemas/ProtoBuf/ProtoGen/protogen.exe.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /schemas/ProtoBuf/ProtoGen/xml.xslt: -------------------------------------------------------------------------------- 1 |  2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | Xml template for protobuf-net. 13 | 14 | This template writes the proto descriptor as xml. 15 | No options available. 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /schemas/ProtoBuf/ScannerMessage.proto: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to the Apache Software Foundation (ASF) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. The ASF licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | 18 | package org.apache.hadoop.hbase.rest.protobuf.generated; 19 | 20 | message Scanner { 21 | optional bytes startRow = 1; 22 | optional bytes endRow = 2; 23 | repeated bytes columns = 3; 24 | optional int32 batch = 4; 25 | optional int64 startTime = 5; 26 | optional int64 endTime = 6; 27 | optional int32 maxVersions = 7; 28 | optional string filter = 8; 29 | optional int32 caching = 9; 30 | } 31 | -------------------------------------------------------------------------------- /schemas/ProtoBuf/StorageClusterStatusMessage.proto: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to the Apache Software Foundation (ASF) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. The ASF licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | 18 | package org.apache.hadoop.hbase.rest.protobuf.generated; 19 | 20 | message StorageClusterStatus { 21 | message Region { 22 | required bytes name = 1; 23 | optional int32 stores = 2; 24 | optional int32 storefiles = 3; 25 | optional int32 storefileSizeMB = 4; 26 | optional int32 memstoreSizeMB = 5; 27 | optional int32 storefileIndexSizeMB = 6; 28 | optional int64 readRequestsCount = 7; 29 | optional int64 writeRequestsCount = 8; 30 | optional int32 rootIndexSizeKB = 9; 31 | optional int32 totalStaticIndexSizeKB = 10; 32 | optional int32 totalStaticBloomSizeKB = 11; 33 | optional int64 totalCompactingKVs = 12; 34 | optional int64 currentCompactedKVs = 13; 35 | } 36 | message Node { 37 | required string name = 1; // name:port 38 | optional int64 startCode = 2; 39 | optional int32 requests = 3; 40 | optional int32 heapSizeMB = 4; 41 | optional int32 maxHeapSizeMB = 5; 42 | repeated Region regions = 6; 43 | } 44 | // node status 45 | repeated Node liveNodes = 1; 46 | repeated string deadNodes = 2; 47 | // summary statistics 48 | optional int32 regions = 3; 49 | optional int32 requests = 4; 50 | optional double averageLoad = 5; 51 | } 52 | -------------------------------------------------------------------------------- /schemas/ProtoBuf/TableInfoMessage.proto: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to the Apache Software Foundation (ASF) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. The ASF licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | 18 | package org.apache.hadoop.hbase.rest.protobuf.generated; 19 | 20 | message TableInfo { 21 | required string name = 1; 22 | message Region { 23 | required string name = 1; 24 | optional bytes startKey = 2; 25 | optional bytes endKey = 3; 26 | optional int64 id = 4; 27 | optional string location = 5; 28 | } 29 | repeated Region regions = 2; 30 | } 31 | -------------------------------------------------------------------------------- /schemas/ProtoBuf/TableListMessage.proto: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to the Apache Software Foundation (ASF) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. The ASF licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | 18 | package org.apache.hadoop.hbase.rest.protobuf.generated; 19 | 20 | message TableList { 21 | repeated string name = 1; 22 | } 23 | -------------------------------------------------------------------------------- /schemas/ProtoBuf/TableSchemaMessage.proto: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to the Apache Software Foundation (ASF) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. The ASF licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | 18 | import "ColumnSchemaMessage.proto"; 19 | 20 | package org.apache.hadoop.hbase.rest.protobuf.generated; 21 | 22 | message TableSchema { 23 | optional string name = 1; 24 | message Attribute { 25 | required string name = 1; 26 | required string value = 2; 27 | } 28 | repeated Attribute attrs = 2; 29 | repeated ColumnSchema columns = 3; 30 | // optional helpful encodings of commonly used attributes 31 | optional bool inMemory = 4; 32 | optional bool readOnly = 5; 33 | } 34 | -------------------------------------------------------------------------------- /schemas/ProtoBuf/VersionMessage.proto: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to the Apache Software Foundation (ASF) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. The ASF licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | 18 | package org.apache.hadoop.hbase.rest.protobuf.generated; 19 | 20 | message Version { 21 | optional string restVersion = 1; 22 | optional string jvmVersion = 2; 23 | optional string osVersion = 3; 24 | optional string serverVersion = 4; 25 | optional string jerseyVersion = 5; 26 | } 27 | --------------------------------------------------------------------------------