当前位置: 首页>>代码示例>>C#>>正文


C# HBaseClient.CreateTable方法代码示例

本文整理汇总了C#中HBaseClient.CreateTable方法的典型用法代码示例。如果您正苦于以下问题:C# HBaseClient.CreateTable方法的具体用法?C# HBaseClient.CreateTable怎么用?C# HBaseClient.CreateTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HBaseClient的用法示例。


在下文中一共展示了HBaseClient.CreateTable方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: HBaseWriter

 public HBaseWriter()
 {
     //Get the Hadoop Cluster info and create connection
     this.ClusterName = ConfigurationManager.AppSettings["ClusterName"];
     this.HadoopUserName = ConfigurationManager.AppSettings["HadoopUserName"];
     string HadoopUserPassword = ConfigurationManager.AppSettings["HadoopUserPassword"];
     this.HBaseTableName = ConfigurationManager.AppSettings["HBaseTableName"];
     SecureString pw = new SecureString();
     for(int i = 0; i < HadoopUserPassword.Length; i++){
         pw.InsertAt(i, HadoopUserPassword[i]);
     }
     Uri clusterUri = new Uri(this.ClusterName);
     ClusterCredentials creds = new ClusterCredentials(clusterUri, this.HadoopUserName, pw);
     this.client = new HBaseClient(creds);
     //create table and enable the hbase writer
     if (!client.ListTables().name.Contains(this.HBaseTableName))
     {
         // Create the table
         var tableSchema = new TableSchema();
         tableSchema.name = this.HBaseTableName;
         tableSchema.columns.Add(new ColumnSchema { name = "d" });
         client.CreateTable(tableSchema);
         Console.WriteLine("Table \"{0}\" created.", this.HBaseTableName);
     }
     WriterThread = new Thread(new ThreadStart(WriterThreadFunction));
     WriterThread.Start();
 }
开发者ID:anytimecnc,项目名称:ProjectTeddy,代码行数:27,代码来源:HBaseWriter.cs

示例2: EventHBaseWriter

        /// <summary>
        /// 
        /// </summary>
        /// <param name="context"></param>
        /// <param name="tablename"></param>
        public EventHBaseWriter(Context context, Dictionary<string, Object> parms = null)
        {
            this.context = context;

            this.appConfig = new AppConfig();

            Dictionary<string, List<Type>> inputSchema = new Dictionary<string, List<Type>>();
            inputSchema.Add(Constants.DEFAULT_STREAM_ID, AggregatedTupleFields);

            this.context.DeclareComponentSchema(new ComponentStreamSchema(inputSchema, null));

            //Setup the credentials for HBase cluster
            HBaseClusterCredentials = 
                new ClusterCredentials(
                    new Uri(this.appConfig.HBaseClusterUrl), 
                    this.appConfig.HBaseClusterUserName, 
                    this.appConfig.HBaseClusterUserPassword);

            HBaseClusterClient = new HBaseClient(HBaseClusterCredentials);

            //Query HBase for existing tables
            var tabs = HBaseClusterClient.ListTables();
            Context.Logger.Info("HBase Tables (" + tabs.name.Count + "): " + String.Join(", ", tabs.name));

            this.PrimaryKey = this.appConfig.PrimaryKey;
            this.SecondaryKey = this.appConfig.SecondaryKey;

            this.HBaseTableName =
                this.appConfig.HBaseTableNamePrefix +
                this.appConfig.PrimaryKey + this.appConfig.SecondaryKey +
                this.appConfig.HBaseTableNameSuffix;

            Context.Logger.Info("HBaseTableName = " + this.HBaseTableName);

            //Create a HBase table if it not exists
            if (!tabs.name.Contains(this.HBaseTableName))
            {
                var tableSchema = new TableSchema();
                tableSchema.name = this.HBaseTableName;
                tableSchema.columns.Add(new ColumnSchema() { name = "v" });
                HBaseClusterClient.CreateTable(tableSchema);
                Context.Logger.Info("Created HBase Table: " + this.HBaseTableName);
            }

            Context.Logger.Info("HBaseOverwrite: " + this.appConfig.HBaseOverwrite);

            globalstopwatch = new Stopwatch();
            globalstopwatch.Start();

            emitstopwatch = new Stopwatch();
            emitstopwatch.Start();
        }
开发者ID:cleydson,项目名称:hdinsight-storm-examples,代码行数:57,代码来源:EventHBaseWriter.cs

示例3: HBaseStore

        public HBaseStore()
        {
            // Initialize HBase connection
            var credentials = CreateFromFile(@"credentials.txt");
            client = new HBaseClient(credentials);

            if (!client.ListTables().name.Contains(TABLE_BY_WORDS_NAME))
            {
                // Create the table
                var tableSchema = new TableSchema();
                tableSchema.name = TABLE_BY_WORDS_NAME;
                tableSchema.columns.Add(new ColumnSchema { name = "d" });
                client.CreateTable(tableSchema);
            }
        }
开发者ID:mkellerman,项目名称:tweet-sentiment,代码行数:15,代码来源:HBaseStore.cs

示例4: CreateHBaseTable

 /// <summary>
 /// Create a new HBase table
 /// </summary>
 /// <param name="hbaseClient">client used to connect to HBase</param>
 public static void CreateHBaseTable(HBaseClient hbaseClient)
 {
     //Define the 'cf family
     //Set versions to retain to 5
     ColumnSchema cf = new ColumnSchema() {
         name = Properties.Settings.Default.HBaseTableColumnFamily,
         maxVersions = 5
     };
     //Define the table
     TableSchema tableSchema = new TableSchema();
     tableSchema.name = Properties.Settings.Default.HBaseTableName;
     tableSchema.columns.Add(cf);
     //Create the table
     hbaseClient.CreateTable(tableSchema);
     Console.WriteLine("Table created.");
 }
开发者ID:Blackmist,项目名称:hdinsight-storm-dotnet-event-correlation,代码行数:20,代码来源:Program.cs

示例5: Context

        protected override void Context()
        {
            _credentials = ClusterCredentialsFactory.CreateFromFile(@".\credentials.txt");
            var client = new HBaseClient(_credentials);

            // ensure tables from previous tests are cleaned up
            
            TableList tables = client.ListTables();
            foreach (string name in tables.name)
            {
                if (name.StartsWith(TestTablePrefix, StringComparison.Ordinal))
                {
                    client.DeleteTable(name);
                }
            }

            // add a table specific to this test
            _testTableName = TestTablePrefix + _random.Next(10000);
            _testTableSchema = new TableSchema();
            _testTableSchema.name = _testTableName;
            _testTableSchema.columns.Add(new ColumnSchema { name = "d" });
           
            client.CreateTable(_testTableSchema);
        }
开发者ID:gitter-badger,项目名称:hbase-sdk-for-net,代码行数:24,代码来源:HBaseClientTests.cs

示例6: HBaseWriter

        public HBaseWriter()
        {
            var credentials = CreateFromFile(@"..\..\credentials.txt");
            client = new HBaseClient(credentials);

            if (!client.ListTables().name.Contains(TABLE_BY_WORDS_NAME))
            {
                // Create the table
                var tableSchema = new TableSchema();
                tableSchema.name = TABLE_BY_WORDS_NAME;
                tableSchema.columns.Add(new ColumnSchema { name = "d" });
                client.CreateTable(tableSchema);
                Console.WriteLine("Table \"{0}\" created.", TABLE_BY_WORDS_NAME);
            }

            // Read current row count cell
            rowCount = GetRowCount();

            // Load sentiment dictionary file
            LoadDictionary();

            writerThread = new Thread(new ThreadStart(WriterThreadFunction));
            writerThread.Start();
        }
开发者ID:mkellerman,项目名称:tweet-sentiment,代码行数:24,代码来源:HBaseWriter.cs

示例7: HBaseWriter

        // This function connects to HBase, loads the sentiment dictionary, and starts the thread for writting.
        public HBaseWriter()
        {
            ClusterCredentials credentials = new ClusterCredentials(new Uri(CLUSTERNAME), HADOOPUSERNAME, HADOOPUSERPASSWORD);
            client = new HBaseClient(credentials);

            // create the HBase table if it doesn't exist
            if (!client.ListTables().name.Contains(HBASETABLENAME))
            {
                TableSchema tableSchema = new TableSchema();
                tableSchema.name = HBASETABLENAME;
                tableSchema.columns.Add(new ColumnSchema { name = "d" });
                client.CreateTable(tableSchema);
                Console.WriteLine("Table \"{0}\" is created.", HBASETABLENAME);
            }

            // Load sentiment dictionary from a file
            LoadDictionary();

            // Start a thread for writting to HBase
            writerThread = new Thread(new ThreadStart(WriterThreadFunction));
            writerThread.Start();
        }
开发者ID:datasciencedojo,项目名称:TwitterHBaseLab,代码行数:23,代码来源:HBaseWriter.cs

示例8: Main

            private static void Main(string[] args)
            {
                const string clusterURL = "http://localhost:5555";
                const string hadoopUsername = "root";
                const string hadoopUserPassword = "hadoop";
                var serializer = new JsonDotNetSerializer();
                // Create a new instance of an HBase client.
                var hbaseClient = new HBaseClient(new ClusterCredentials(new Uri(clusterURL), hadoopUsername, hadoopUserPassword));
                var itemMapper = new ItemMapper(serializer);
                hbaseClient.DeleteTable("Items");
                var tableSchema = itemMapper.CreateTableSchema("Items");
                hbaseClient.CreateTable(tableSchema);

                //var perfCheck = new PerformanceChecksManager(hbaseClient, "Items", itemMapper, new ItemsGenerator(),50,100);
                //perfCheck.RunPerformanceLoad();
                
                //Generating item.
                var itemsGenerator = new ItemsGenerator();
                var item = itemsGenerator.CreateItem("mycode");

                //Generating cells relevant to the generate item and saving the entity to Hbae.
                var itemCellSet = itemMapper.GetCells(item, "en-US");
                var stausCell = itemCellSet.rows.Single().values.Single(cell => Encoding.UTF8.GetString(cell.column).Equals("CF1:Status"));
                stausCell.data = new byte[0];
                hbaseClient.StoreCells("Items", itemCellSet);

                //making sure item stored well.
                var originalItemCells = hbaseClient.GetCells("Items", item.Code);
                var originalItemFetchedFromDb = itemMapper.GetDto(originalItemCells, "en-US");

                if (!string.IsNullOrEmpty(originalItemFetchedFromDb.Status))
                    throw new Exception();

                //Describing the conditional update expression.
                var cellToCheck = new Cell { column = Encoding.UTF8.GetBytes("CF1:Status"), data = new byte[0] };

                //manipulating original item.
                stausCell = itemCellSet.rows.Single().values.Single(cell => Encoding.UTF8.GetString(cell.column).Equals("CF1:Status"));
                var newStatusValue = Encoding.UTF8.GetBytes("new");
                stausCell.data = newStatusValue;
                
                //Testing new functionality...

                hbaseClient.CheckAndPutCells("Items", itemCellSet, cellToCheck);
                //Thread.Sleep(1);
                itemCellSet = hbaseClient.GetCells("Items", item.Code);
                var itemFromDb = itemMapper.GetDto(itemCellSet, "en-US");

                if (!itemFromDb.Status.Equals(Encoding.UTF8.GetString(newStatusValue)))
                    throw new Exception();


                #region Old-Helper
                //string clusterURL = "http://localhost:5555";
                //string hadoopUsername = "root";
                //string hadoopUserPassword = "hadoop";
                //string hbaseTableName = "MyCoolTable";

                //// Create a new instance of an HBase client.
                //ClusterCredentials creds = new ClusterCredentials(new Uri(clusterURL), hadoopUsername, hadoopUserPassword);
                //HBaseClient hbaseClient = new HBaseClient(creds);

                //var hbaseHelper = new Helper(hbaseClient, "ThisIsJustATableForShirly1", "DummyKey1ForShirly1");
                //hbaseHelper.CreateTable();
                //var myClass = new Dto()
                //{
                //    Field1 = "1",
                //    Field2 = "2",
                //    Field3 = "3",
                //    Field4 = "4",
                //    Field5 = "5",
                //    NestedData = new NestedDto() { Field1 = "n1", Field2 = "n2" }
                //};

                //hbaseHelper.SaveMyDto(myClass);

                //var dto = hbaseHelper.GetMyDto();
#endregion
            }
开发者ID:gitter-badger,项目名称:hbase-sdk-for-net,代码行数:79,代码来源:Program.cs

示例9: InitializeHBase

        /// <summary>
        /// Initialize the HBase settings and connections
        /// </summary>
        public void InitializeHBase()
        {
            this.HBaseClusterUrl = ConfigurationManager.AppSettings["HBaseClusterUrl"];
            if (String.IsNullOrWhiteSpace(this.HBaseClusterUrl))
            {
                throw new ArgumentException("A required AppSetting cannot be null or empty", "HBaseClusterUrl");
            }

            this.HBaseClusterUserName = ConfigurationManager.AppSettings["HBaseClusterUserName"];
            if (String.IsNullOrWhiteSpace(this.HBaseClusterUserName))
            {
                throw new ArgumentException("A required AppSetting cannot be null or empty", "HBaseClusterUserName");
            }

            this.HBaseClusterPassword = ConfigurationManager.AppSettings["HBaseClusterPassword"];
            if (String.IsNullOrWhiteSpace(this.HBaseClusterPassword))
            {
                throw new ArgumentException("A required AppSetting cannot be null or empty", "HBaseClusterPassword");
            }

            this.HBaseTableName = ConfigurationManager.AppSettings["HBaseTableName"];
            if (String.IsNullOrWhiteSpace(this.HBaseTableName))
            {
                throw new ArgumentException("A required AppSetting cannot be null or empty", "HBaseTableName");
            }

            this.HBaseTableColumnFamily = ConfigurationManager.AppSettings["HBaseTableColumnFamily"];
            if (String.IsNullOrWhiteSpace(this.HBaseTableColumnFamily))
            {
                throw new ArgumentException("A required AppSetting cannot be null or empty", "HBaseTableColumnFamily");
            }

            //TODO - DO NOT include the ROWKEY field in the column list as it is assumed to be at index 0 in tuple fields
            //Rest of the tuple fields are mapped with the column names provided
            var hbaseTableColumnNames = ConfigurationManager.AppSettings["HBaseTableColumnNames"];
            if (String.IsNullOrWhiteSpace(hbaseTableColumnNames))
            {
                throw new ArgumentException("A required AppSetting cannot be null or empty", "HBaseTableColumnNames");
            }

            //Setup the credentials for HBase cluster
            this.HBaseClusterCredentials =
                new ClusterCredentials(
                    new Uri(this.HBaseClusterUrl),
                    this.HBaseClusterUserName,
                    this.HBaseClusterPassword);

            this.HBaseClusterClient = new HBaseClient(this.HBaseClusterCredentials);

            //Query HBase for existing tables
            var tables = this.HBaseClusterClient.ListTables();
            Context.Logger.Info("Existing HBase tables - Count: {0}, Tables: {1}", tables.name.Count, String.Join(", ", tables.name));

            //Read the HBaseTable Columns and convert them to byte[]
            this.HBaseTableColumns = hbaseTableColumnNames.Split(new char[] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries).
                Select(c => c.Trim()).ToList();

            //Create a HBase table if it not exists
            if (!tables.name.Contains(this.HBaseTableName))
            {
                var tableSchema = new TableSchema();
                tableSchema.name = this.HBaseTableName;
                tableSchema.columns.Add(new ColumnSchema() { name = this.HBaseTableColumnFamily });
                HBaseClusterClient.CreateTable(tableSchema);
                Context.Logger.Info("Created HBase table: {0}", this.HBaseTableName);
            }
            else
            {
                Context.Logger.Info("Found an existing HBase table: {0}", this.HBaseTableName);
            }
        }
开发者ID:cleydson,项目名称:hdinsight-storm-examples,代码行数:74,代码来源:HBaseBolt.cs

示例10: AddTable

        private void AddTable()
        {
            // add a table specific to this test
            var client = new HBaseClient(_credentials);
            _tableName = TableNamePrefix + Guid.NewGuid().ToString("N");
            _tableSchema = new TableSchema { name = _tableName };
            _tableSchema.columns.Add(new ColumnSchema { name = ColumnFamilyName1 });
            _tableSchema.columns.Add(new ColumnSchema { name = ColumnFamilyName2 });

            client.CreateTable(_tableSchema);
        }
开发者ID:gitter-badger,项目名称:hbase-sdk-for-net,代码行数:11,代码来源:FilterTests.cs


注:本文中的HBaseClient.CreateTable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。