Domanda

Come posso utilizzare un database HBase con C # / VB.NET? (Uso = connect, interrogare, ottenere il risultato, inserimento, aggiornamento, cancellazione)

Non trovare risposte utili con google.

È stato utile?

Soluzione

Ho appena pubblicato HBase C # Thrift vincolante package NuGet. In alternativa si può afferrare codice / binari dai bitbucket: https://bitbucket.org/vadim/hbase-sharp / download

Altri suggerimenti

descrizione :

  

A REST-ful gateway di servizio Web che   supporta XML, Protobuf, e binari   dati opzioni di codifica

C'è un href="http://code.google.com/p/protobuf-net/" rel="nofollow noreferrer"> protobuf porta e ci sono molte API di manipolazione XML built-in.

HBase C # Thrift funziona bene. Basta scaricare l'ultima parsimonia-0.9.2.exe, thrift.dll e il file Hbase.thrift sulla vostra macchina Windows. È possibile generare i file # c richieste con il seguente comando:

thrift-0.9.2.exe -gen csharp Hbase.thrift

Si otterrà i seguenti file come risultato:

AlreadyExists.cs
BatchMutation.cs
ColumnDescriptor.cs
Hbase.cs
IllegalArgument.cs
IOError.cs
Mutation.cs
TAppend.cs
TCell.cs
TColumn.cs
TIncrement.cs
TRegionInfo.cs
TRowResult.cs
TScan.cs

includerli nel progetto e aggiungere thrift.dll ai vostri riferimenti del progetto. codice di esempio Breve (tabelle di riepilogo e di inserimento / aggiornamento di un valore di una cella):

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Thrift.Protocol;
using Thrift.Transport;

namespace bdc
{
    class Program
    {
        static void Main(string[] args)
        {            
            // Connection
            var socket = new TSocket("hdp1.localdomain", 9090);
            var transport =new TBufferedTransport(socket);
            var protocol = new TBinaryProtocol(transport);
            Hbase.Client hba = new Hbase.Client(protocol);
            transport.Open();            

            // Get table names
            Console.WriteLine("<-GET LIST OF TABLES->");      
            var tableNames = hba.getTableNames();
            foreach (var tableName in tableNames)
            Console.WriteLine(Encoding.UTF8.GetString(tableName, 0, tableName.Length));            

            // Insert rows       
            Console.WriteLine("<-INSERT->");      
            Mutation _mutation = new Mutation();
            _mutation.IsDelete = false;
            _mutation.Column = Encoding.UTF8.GetBytes("image:bodyimage");
            _mutation.Value = Encoding.UTF8.GetBytes("newnew image 2.jpg");

            hba.mutateRow(Encoding.UTF8.GetBytes("blogposts"), Encoding.UTF8.GetBytes("post1"), new List<Mutation> { _mutation }, null);

            // Finished
            Console.WriteLine("<-FINISHED->");  
            Console.ReadKey();                        
        }        
    }
}

Il codice sopra funziona bene con l'installazione HBase della più recente piattaforma dati Hortonworks, in esecuzione su CentOS 7.

scroll top