Example #1
0
        /// <summary>
        /// Handles the OnDemandDataSourceLoad event of the dataPager control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="Syncfusion.Windows.Controls.Grid.GridDataOnDemandPageLoadingEventArgs"/> instance containing the event data.</param>
        private async void dataPager_OnDemandDataSourceLoad(object sender, GridDataOnDemandPageLoadingEventArgs e)
        {
            DataPagerExt ex          = e.Source as DataPagerExt;
            ViewModel    dataContext = this.AssociatedObject.DataContext as ViewModel;
            bool         IsCache     = false;

            //Assigning number of rows to be fetched from HBase
            HBaseOperation.FetchSize = 5000;

            if (!dataContext.ResultCollection.ContainsKey(ex.PageIndex) && HBaseOperation.HasRows)
            {
                dataContext.OrderDetails = await HBaseOperation.ScanTableAsync(dataContext.TableName, dataContext.Connection);

                dataContext.ResultCollection.Add(ex.PageIndex == -1 ? 1 : ex.PageIndex, dataContext.OrderDetails);
                IsCache = false;
            }
            else
            {
                dataContext.OrderDetails = dataContext.ResultCollection[ex.PageIndex];
                IsCache = true;
            }

            bool IsPrevious = PreviousPageIndex > ex.PageIndex;

            if (!IsPrevious && HBaseOperation.HasRows && !IsCache)
            {
                if (ex.PageIndex != -1)
                {
                    ex.PageCount = ex.PageCount + 1;
                }
            }

            PreviousPageIndex = ex.PageIndex == -1 ? 1 : ex.PageIndex;
        }
Example #2
0
 /// <summary>
 /// Create a new table and insert the value on it
 /// </summary>
 /// <param name="host">Host name</param>
 /// <param name="port">Port number</param>
 private static void PopulateTable(string host, int port)
 {
     if (HBaseOperation.IsTableExists("http://" + host + ":" + port + "/", "Customer"))
     {
         HBaseOperation.DeleteTable("http://" + host + ":" + port + "/", "Customer");
     }
     HBaseOperation.CreateTable("http://" + host + ":" + port + "/", "Customer", "Info");
     ////Row 1
     HbaseTableInsertRow(host, port, "ALFKI", "CompanyName", "Alfreds Futterkiste");
     HbaseTableInsertRow(host, port, "ALFKI", "contactName", "Maria Anders");
     HbaseTableInsertRow(host, port, "ALFKI", "contactTIT", "Sales Representative");
     HbaseTableInsertRow(host, port, "ALFKI", "country", "Germany");
     ////Row 2
     HbaseTableInsertRow(host, port, "DRACD", "CompanyName", "Drachenblut Delikatessen");
     HbaseTableInsertRow(host, port, "DRACD", "contactName", "Sven Ottlieb");
     HbaseTableInsertRow(host, port, "DRACD", "contactTIT", "Order Administrator");
     HbaseTableInsertRow(host, port, "DRACD", "country", "Germany");
     ////Row 3
     HbaseTableInsertRow(host, port, "BONAP", "CompanyName", "Bon app");
     HbaseTableInsertRow(host, port, "BONAP", "contactName", "Laurence Lebihan");
     HbaseTableInsertRow(host, port, "BONAP", "contactTIT", "Owner");
     HbaseTableInsertRow(host, port, "BONAP", "country", "France");
     ////Row 4
     HbaseTableInsertRow(host, port, "BOTTM", "CompanyName", "Bottom-Dollar Markets");
     HbaseTableInsertRow(host, port, "BOTTM", "contactName", "Elizabeth Lincoln");
     HbaseTableInsertRow(host, port, "BOTTM", "contactTIT", "Accounting Manager");
     HbaseTableInsertRow(host, port, "BOTTM", "country", "Canada");
     ////Row 5
     HbaseTableInsertRow(host, port, "FRANR", "CompanyName", "France restauration");
     HbaseTableInsertRow(host, port, "FRANR", "contactName", "Carine Schmitt");
     HbaseTableInsertRow(host, port, "FRANR", "contactTIT", "Marketing Manager");
     HbaseTableInsertRow(host, port, "FRANR", "country", "Austria");
 }
Example #3
0
        public static IList <Customer> list(string tableName, HBaseConnection con)
        {
            List <Customer> results = new List <Customer>();

            //Initializing the fetch size
            HBaseOperation.FetchSize = 12;

            //Fetches the given amount of data from the HBase
            HBaseResultSet table = HBaseOperation.ScanTable(tableName, con);
            //  HSchema a = HBaseOperation.DescribeTable(tableName, con);
            //HBaseOperation.
            List <Customers> resultTable = new List <Customers>();

            //Read each row from the fetched result
            foreach (HBaseRecord cellValue in table)
            {
                Customer customer = new Customer();
                customer.ContactId    = cellValue["rowKey"] != null ? cellValue["rowKey"].ToString() : "";
                customer.FullName     = cellValue["info:FULLNAME"] != null ? cellValue["info:FULLNAME"].ToString() : "";
                customer.Age          = cellValue["info:AGE"] != null ? cellValue["info:AGE"].ToString() : "";
                customer.EmailId      = cellValue["contact:EMAILID"] != null ? cellValue["contact:EMAILID"].ToString() : "";
                customer.PhoneNumber  = cellValue["contact:PHONE"] != null ? cellValue["contact:PHONE"].ToString() : "";
                customer.ModifiedDate = cellValue["others:MODIFIEDDATE"] != null ? cellValue["others:MODIFIEDDATE"].ToString() : "";
                results.Add(customer);
            }


            return(results);
        }
Example #4
0
        /// <summary>
        /// Wires the paging helper with GridGroupingControl.
        /// </summary>
        /// <param name="groupingGrid">GridGroupingControl</param>
        /// <param name="table">DataTable</param>
        public async void Wire(GridGroupingControl groupingGrid, String tableName, HBaseConnection con, Panel loaderPic)
        {
            commonLoaderPic = loaderPic;
            _grid           = groupingGrid;
            this.tableName  = tableName;
            this.con        = con;
            ResultSet       = await HBaseOperation.ScanTableAsync(tableName, con);

            InitializePager();
        }
Example #5
0
        //<summary>
        //A method that was invoked on clicking arrow buttons in pager control.
        //</summary>
        //<param name="sender">The source of the event.</param>
        //<param name="e">An <see cref="T:Syncfusion.Windows.Forms.ArrowButtonEventArgs">ArrowButtonEventArgs</see> that contains the event data.</param>
        async void RecordNavigationBar_ArrowButtonClicked(object sender, ArrowButtonEventArgs e)
        {
            switch (e.Arrow)
            {
            case ArrowType.Previous:

                _currentPage -= 1;
                if (resultCollection.ContainsKey(_currentPage))
                {
                    ResultSet = resultCollection[_currentPage];
                }
                FillPage(ResultSet);
                break;

            case ArrowType.Next:
            {
                _currentPage += 1;
                if (!HBaseOperation.HasRows && !resultCollection.ContainsKey(_currentPage))
                {
                    _currentPage -= 1;
                }
                else if (resultCollection.ContainsKey(_currentPage))
                {
                    ResultSet = resultCollection[_currentPage];
                }
                else
                {
                    if (HBaseOperation.HasRows)
                    {
                        _grid.Enabled            = false;
                        commonLoaderPic.Visible  = true;
                        HBaseOperation.FetchSize = 5000;
                        ResultSet = await HBaseOperation.ScanTableAsync(tableName, con);

                        commonLoaderPic.Visible = false;
                        _grid.Enabled           = true;
                    }
                }

                FillPage(ResultSet);
                DisplayPageInfo();
            }
            break;
            }
        }
Example #6
0
        public static List <List <Customers> > list(String path)
        {
            #region creating connection

            HBaseConnection con = new HBaseConnection("localhost", 10003);
            con.Open();

            #endregion creating connection

            #region parsing csv input file

            csv csvObj = new csv();
            object[,] cells;
            cells = null;

            cells = csvObj.Table(path, false, ',');

            #endregion parsing csv input file

            #region creating table
            String        tableName      = "AdventureWorks_Person_Contact";
            List <string> columnFamilies = new List <string>();
            columnFamilies.Add("info");
            columnFamilies.Add("contact");
            columnFamilies.Add("others");
            if (!HBaseOperation.IsTableExists(tableName, con))
            {
                if (columnFamilies.Count > 0)
                {
                    HBaseOperation.CreateTable(tableName, columnFamilies, con);
                }
                else
                {
                    throw new HBaseException("ERROR: Table must have at least one column family");
                }
            }

            # endregion
Example #7
0
        private void Form1_Load(object sender, EventArgs e)
        {
            try
            {
                #region creating connection
                con = new HBaseConnection("localhost", 10003);
                con.Open();
                #endregion creating connection

                #region parsing csv input file
                csv csvObj = new csv();
                object[,] cells;
                cells = null;
                string path = System.AppDomain.CurrentDomain.BaseDirectory;
                cells = csvObj.Table(path + "..\\..\\..\\..\\..\\..\\..\\..\\Data\\AdventureWorks\\AdventureWorks_Person_Contact.csv", false, ',');

                #endregion parsing csv input file

                #region creating table
                tableName = "AdventureWorks_Person_Contact";
                List <string> columnFamilies = new List <string>();
                columnFamilies.Add("info");
                columnFamilies.Add("contact");
                columnFamilies.Add("others");
                if (!HBaseOperation.IsTableExists(tableName, con))
                {
                    if (columnFamilies.Count > 0)
                    {
                        HBaseOperation.CreateTable(tableName, columnFamilies, con);
                    }
                    else
                    {
                        throw new HBaseException("ERROR: Table must have at least one column family");
                    }
                }

                # endregion

                #region Inserting Values
                string[] column = new string[] { "CONTACTID", "FULLNAME", "AGE", "EMAILID", "PHONE", "MODIFIEDDATE" };
                Dictionary <string, IList <HMutation> > rowCollection = new Dictionary <string, IList <HMutation> >();
                string rowKey;
                for (int i = 0; i < cells.GetLength(0); i++)
                {
                    List <HMutation> mutations = new List <HMutation>();
                    rowKey = cells[i, 0].ToString();
                    for (int j = 1; j < column.Length; j++)
                    {
                        HMutation mutation = new HMutation();
                        mutation.ColumnFamily = j < 3 ? "info" : j < 5 ? "contact" : "others";
                        mutation.ColumnName   = column[j];
                        mutation.Value        = cells[i, j].ToString();
                        mutations.Add(mutation);
                    }
                    rowCollection[rowKey] = mutations;
                }
                HBaseOperation.InsertRows(tableName, rowCollection, con);
                #endregion Inserting Values


                ////Executes the Hql query
                //HqlDataReader reader = command.ExecuteReader();

                //Assigning number of records to be fetched from HBase
                HBaseOperation.FetchSize = 5000;


                //#endregion

                // Paging enabled in grid
                var pager = new Pager();
                pager.Wire(_gridGroupingControl2, tableName, con, commonLoaderPicPanel);

                _gridGroupingControl2.TopLevelGroupOptions.ShowFilterBar = false;
                foreach (var col in _gridGroupingControl2.TableDescriptor.Columns)
                {
                    col.AllowFilter = false;
                }

                int topRow = this._gridGroupingControl2.TableControl.TopRowIndex;
                this._gridGroupingControl2.TableControl.CurrentCell.Activate(topRow, 1);
            }
Example #8
0
        private void BindDataSource()
        {
            ErrorMessage.InnerText = "";
            string path = string.Format("{0}\\..\\Data\\AdventureWorks\\AdventureWorks_Person_Contact.csv", Request.PhysicalPath.ToLower().Split(new string[] { "\\c# hbase samples" }, StringSplitOptions.None));

            try
            {
                #region creating connection

                HBaseConnection con = new HBaseConnection("localhost", 10003);
                con.Open();

                #endregion creating connection

                #region parsing csv input file

                csv csvObj = new csv();
                object[,] cells;
                cells = null;

                cells = csvObj.Table(path, false, ',');

                #endregion parsing csv input file

                #region creating table
                String        tableName      = "AdventureWorks_Person_Contact";
                List <string> columnFamilies = new List <string>();
                columnFamilies.Add("info");
                columnFamilies.Add("contact");
                columnFamilies.Add("others");
                if (!HBaseOperation.IsTableExists(tableName, con))
                {
                    if (columnFamilies.Count > 0)
                    {
                        HBaseOperation.CreateTable(tableName, columnFamilies, con);
                    }
                    else
                    {
                        throw new HBaseException("ERROR: Table must have at least one column family");
                    }
                }
                # endregion

                #region Inserting Values
                string[] column = new string[] { "CONTACTID", "FULLNAME", "AGE", "EMAILID", "PHONE", "MODIFIEDDATE" };
                Dictionary <string, IList <HMutation> > rowCollection = new Dictionary <string, IList <HMutation> >();
                string rowKey;
                for (int i = 0; i < cells.GetLength(0); i++)
                {
                    List <HMutation> mutations = new List <HMutation>();
                    rowKey = cells[i, 0].ToString();
                    for (int j = 1; j < column.Length; j++)
                    {
                        HMutation mutation = new HMutation();
                        mutation.ColumnFamily = j < 3 ? "info" : j < 5 ? "contact" : "others";
                        mutation.ColumnName   = column[j];
                        mutation.Value        = cells[i, j].ToString();
                        mutations.Add(mutation);
                    }
                    rowCollection[rowKey] = mutations;
                }
                HBaseOperation.InsertRows(tableName, rowCollection, con);
                #endregion Inserting Values

                #region scan values

                HBaseOperation.FetchSize = 100;
                HBaseResultSet table = HBaseOperation.ScanTable(tableName, con);

                //Initialize the list to add elements in each row
                BindingList <Customers> resultList = new BindingList <Customers>();

                //Read each row from the fetched result
                foreach (HBaseRecord rows in table)
                {
                    //Adding element of each row to the list
                    resultList = new BindingList <Customers>(table.Select(row => new Customers
                    {
                        ContactId    = row["rowKey"] != null?row["rowKey"].ToString():"",
                        FullName     = row["info:FULLNAME"] != null ? row["info:FULLNAME"].ToString() : "",
                        Age          = row["info:AGE"] != null ? row["info:AGE"].ToString() : "",
                        EmailId      = row["contact:EMAILID"] != null ? row["contact:EMAILID"].ToString() : "",
                        PhoneNumber  = row["contact:PHONE"] != null ? row["contact:PHONE"].ToString() : "",
                        ModifiedDate = row["others:MODIFIEDDATE"] != null ? row["others:MODIFIEDDATE"].ToString() : "",
                    }).ToList());
                }
                //Binding the result to the grid
                this.FlatGrid.DataSource = resultList;
                this.FlatGrid.DataBind();
                #endregion scan values

                #region close connection
                //Closing the hbase connection
                con.Close();
                #endregion close connection
            }
Example #9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string path = string.Format("{0}\\..\\Data\\AdventureWorks\\AdventureWorks_Person_Contact.csv", Request.PhysicalPath.ToLower().Split(new string[] { "\\c# hbase samples" }, StringSplitOptions.None));

            try
            {
                #region creating connection
                con = new HBaseConnection("localhost", 10003);
                con.Open();
                #endregion creating connection

                #region parsing csv input file
                csv csvObj = new csv();
                object[,] cells;
                cells = null;
                cells = csvObj.Table(path, false, ',');

                #endregion parsing csv input file

                #region creating table
                tableName = "asyncHbaseCustomer3";
                List <string> columnFamilies = new List <string>();
                columnFamilies.Add("info");
                columnFamilies.Add("contact");
                columnFamilies.Add("others");
                if (!HBaseOperation.IsTableExists(tableName, con))
                {
                    if (columnFamilies.Count > 0)
                    {
                        HBaseOperation.CreateTable(tableName, columnFamilies, con);
                    }
                    else
                    {
                        error = "ERROR: Table must have at least one column family";
                        throw new HBaseException(error);
                    }
                }

                # endregion

                #region Inserting Values
                string[] column = new string[] { "CONTACTID", "FULLNAME", "AGE", "EMAILID", "PHONE", "MODIFIEDDATE" };
                Dictionary <string, IList <HMutation> > rowCollection = new Dictionary <string, IList <HMutation> >();
                string rowKey;
                for (int i = 0; i < cells.GetLength(0); i++)
                {
                    List <HMutation> mutations = new List <HMutation>();
                    rowKey = cells[i, 0].ToString();
                    for (int j = 1; j < column.Length; j++)
                    {
                        HMutation mutation = new HMutation();
                        mutation.ColumnFamily = j < 3 ? "info" : j < 5 ? "contact" : "others";
                        mutation.ColumnName   = column[j];
                        mutation.Value        = cells[i, j].ToString();
                        mutations.Add(mutation);
                    }
                    rowCollection[rowKey] = mutations;
                }
                HBaseOperation.InsertRows(tableName, rowCollection, con);
                #endregion Inserting Values

                page = 0;
                Skip = -1;

                DataCollection = new Dictionary <int, DataResult>();
            }
Example #10
0
        private void Form1_Load(object sender, EventArgs e)
        {
            try
            {
                #region creating connection

                HBaseConnection con = new HBaseConnection("localhost", 10003);
                con.Open();

                #endregion creating connection

                #region parsing csv input file

                csv csvObj = new csv();
                object[,] cells;
                cells = null;
                string path = System.AppDomain.CurrentDomain.BaseDirectory;
                cells = csvObj.Table(path + "..\\..\\..\\..\\..\\..\\..\\..\\Data\\AdventureWorks\\AdventureWorks_Person_Contact.csv", false, ',');

                #endregion parsing csv input file

                #region creating table
                String        tableName      = "AdventureWorks_Person_Contact";
                List <string> columnFamilies = new List <string>();
                columnFamilies.Add("info");
                columnFamilies.Add("contact");
                columnFamilies.Add("others");

                if (!HBaseOperation.IsTableExists(tableName, con))
                {
                    if (columnFamilies.Count > 0)
                    {
                        HBaseOperation.CreateTable(tableName, columnFamilies, con);
                    }
                    else
                    {
                        throw new HBaseException("ERROR: Table must have at least one column family");
                    }
                }

                # endregion

                #region Inserting Values

                string[] column = new string[] { "CONTACTID", "FULLNAME", "AGE", "EMAILID", "PHONE", "MODIFIEDDATE" };
                Dictionary <string, IList <HMutation> > rowCollection = new Dictionary <string, IList <HMutation> >();
                string rowKey;

                for (int i = 0; i < cells.GetLength(0); i++)
                {
                    List <HMutation> mutations = new List <HMutation>();
                    rowKey = cells[i, 0].ToString();

                    for (int j = 1; j < column.Length; j++)
                    {
                        HMutation mutation = new HMutation();
                        mutation.ColumnFamily = j < 3 ? "info" : j < 5 ? "contact" : "others";
                        mutation.ColumnName   = column[j];
                        mutation.Value        = cells[i, j].ToString();
                        mutations.Add(mutation);
                    }

                    rowCollection[rowKey] = mutations;
                }

                HBaseOperation.InsertRows(tableName, rowCollection, con);

                #endregion Inserting Values

                #region Fetch result

                HBaseOperation.FetchSize = 100;
                HBaseResultSet table = HBaseOperation.ScanTable(tableName, con);

                #endregion Fetch result

                //Binding the fetched result to the grid
                gridGroupingControl1.DataSource = table;
                gridGroupingControl1.TableDescriptor.Columns["rowKey"].Width              = 85;
                gridGroupingControl1.TableDescriptor.Columns["info:FULLNAME"].Width       = 170;
                gridGroupingControl1.TableDescriptor.Columns["info:AGE"].Width            = 90;
                gridGroupingControl1.TableDescriptor.Columns["contact:EMAILID"].Width     = 230;
                gridGroupingControl1.TableDescriptor.Columns["contact:PHONE"].Width       = 170;
                gridGroupingControl1.TableDescriptor.Columns["others:MODIFIEDDATE"].Width = 170;

                #region closing connection
                //closing the hive connection
                con.Close();
                #endregion closing connection
            }
Example #11
0
        public MainWindow()
        {
            InitializeComponent();
            try
            {
                string path = System.AppDomain.CurrentDomain.BaseDirectory;
                path = path + "..\\..\\..\\..\\..\\..\\..\\..\\Data\\AdventureWorks\\AdventureWorks_Person_Contact.csv";

                #region Creating connection

                con = new HBaseConnection("localhost", 10003);
                con.Open();

                #endregion Creating connection

                #region Creating table

                string        tableName      = "AdventureWorks_Person_Contact";
                List <string> columnFamilies = new List <string>();
                columnFamilies.Add("info");
                columnFamilies.Add("contact");
                columnFamilies.Add("others");

                if (!HBaseOperation.IsTableExists(tableName, con))
                {
                    if (columnFamilies.Count > 0)
                    {
                        HBaseOperation.CreateTable(tableName, columnFamilies, con);
                    }
                    else
                    {
                        throw new HBaseException("ERROR: Table must have at least one column family");
                    }
                }

                #endregion Creating table

                #region Inserting Values

                #region Parsing csv input file

                csv csvObj = new csv();
                object[,] cells = csvObj.Table(path, false, ',');

                #endregion Parsing csv input file

                string[] column = new string[] { "CONTACTID", "FULLNAME", "AGE", "EMAILID", "PHONE", "MODIFIEDDATE" };
                Dictionary <string, IList <HMutation> > rowCollection = new Dictionary <string, IList <HMutation> >();
                string rowKey;

                for (int i = 0; i < cells.GetLength(0); i++)
                {
                    List <HMutation> mutations = new List <HMutation>();
                    rowKey = cells[i, 0].ToString();

                    for (int j = 1; j < column.Length; j++)
                    {
                        HMutation mutation = new HMutation();
                        mutation.ColumnFamily = j < 3 ? "info" : j < 5 ? "contact" : "others";
                        mutation.ColumnName   = column[j];
                        mutation.Value        = cells[i, j].ToString();
                        mutations.Add(mutation);
                    }

                    rowCollection[rowKey] = mutations;
                }

                HBaseOperation.InsertRows(tableName, rowCollection, con);

                #endregion Inserting Values

                //Fetches the result from the reader and store it in a object
                HBaseOperation.FetchSize = 100;
                result = HBaseOperation.ScanTable(tableName, con);

                //Closing the HBase connection
                con.Close();
            }
            catch (HBaseConnectionException)
            {
                if (MessageBox.Show("Could not establish a connection to the HBase thrift server. Please run HBase thrift server from the Syncfusion service manager dashboard.", "Could not establish a connection to the HBase thrift server", MessageBoxButton.OK, MessageBoxImage.Warning) == MessageBoxResult.OK)
                {
                    Application.Current.Shutdown();
                }
            }
            catch (HBaseException hbase_ex)
            {
                if (MessageBox.Show(hbase_ex.Message.ToString(), "HBaseException", MessageBoxButton.OK, MessageBoxImage.Warning) == MessageBoxResult.OK)
                {
                    Application.Current.Shutdown();
                }
            }
            catch (Exception ex)
            {
                if (MessageBox.Show(ex.Message.ToString(), "Exception", MessageBoxButton.OK, MessageBoxImage.Warning) == MessageBoxResult.OK)
                {
                    Application.Current.Shutdown();
                }
            }
        }
Example #12
0
 /// <summary>
 /// Insert rows values in HBase table
 /// </summary>
 /// <param name="host">host name of running HBase rest server</param>
 /// <param name="port">port number</param>
 /// <param name="rowKey">HBase table row value</param>
 /// <param name="columnFamily">column name</param>
 /// <param name="cellValue">cell value</param>
 private static void HbaseTableInsertRow(string host, int port, string rowKey, string columnFamily, string cellValue)
 {
     ////For Azure basic Authentication cluster -> HBaseOperation.InsertRow("https://" + host + ":" + port + "/", rowKey,"Customer" ,"Info", columnFamily, cellValue, userName, password);
     ////For Secured Cluster -> HBaseOperation.InsertRow("https://" + host + ":" + port + "/", rowKey,"Customer" ,"Info", columnFamily, cellValue, userName, password);
     HBaseOperation.InsertRow("http://" + host + ":" + port + "/", rowKey, "Customer", "Info", columnFamily, cellValue);
 }
Example #13
0
        //  public static string userName = ""; // For Secure (add domain with user name e.g. [email protected]) & Azure Cluster (e.g. admin)
        //  public static string password = ""; // For Secure & Azure Cluster
        static void Main(string[] args)
        {
            try
            {
                // For Cluster aasign host="<ipaddress/hostname>";
                // For Azure cluster assign host="<FQDN Name of Azure cluster>"
                // Use FQN(host name with domain name) for secure cluster
                string host = "localhost";

                int port = 10005; // For Azure cluster assign port =8006
                int i;
                do
                {
                    Console.WriteLine("\nEnter any operation");
                    Console.WriteLine("1. NewTable");
                    Console.WriteLine("2. DeleteTable");
                    Console.WriteLine("3. InsertValue");
                    Console.WriteLine("4. GetSingleRow");
                    Console.WriteLine("5. ScanTable");
                    Console.WriteLine("6. Exit");
                    i = int.Parse(Console.ReadLine());
                    switch (i)
                    {
                    case 1:                                                                                // Create a new table
                        if (HBaseOperation.IsTableExists("http://" + host + ":" + port + "/", "Customer")) // Add UserName & Password for secure/ Azure Cluster.
                        {
                            HBaseOperation.DeleteTable("http://" + host + ":" + port + "/", "Customer");
                        }
                        Console.WriteLine("Creating Table....");
                        HBaseOperation.CreateTable("http://" + host + ":" + port + "/", "Customer", "Info");
                        //// For Azure basic Authentication cluster - HBaseOperation.CreateTable("https://" + host + ":" + port + "/", "Customer", "Info", userName, password);
                        //// For Secured Cluster - HBaseOperation.CreateTable("https://" + host + ":" + port + "/", "Customer", "Info", userName, password);
                        Console.WriteLine("Table Created");
                        break;

                    case 2:                                                                                 // Delete the table
                        if (!HBaseOperation.IsTableExists("http://" + host + ":" + port + "/", "Customer")) // Add UserName & Password for secure/ Azure Cluster.
                        {
                            HBaseOperation.CreateTable("http://" + host + ":" + port + "/", "Customer", "Info");
                        }
                        Console.WriteLine("Deleting Table....");
                        HBaseOperation.DeleteTable("http://" + host + ":" + port + "/", "Customer");
                        ////For Azure basic Authentication cluster -  HBaseOperation.DeleteTable("https://" + host + ":" + port + "/", "Customer",userName, password);
                        ////For Secured Cluser -  HBaseOperation.DeleteTable("https://" + host + ":" + port + "/", "Customer", userName , password);
                        Console.WriteLine("Table Deleted");
                        break;

                    case 3:         // Insert the row values in the table
                        Console.WriteLine("Inserting values into the table....");
                        PopulateTable(host, port);
                        Console.WriteLine("Value Inserted");
                        break;

                    case 4:         // Get the single row from the table
                        Console.WriteLine("Fetching single row from the table....");
                        PopulateTable(host, port);
                        Console.WriteLine(HBaseOperation.GetRow("http://" + host + ":" + port + "/", "Customer", "FRANR"));
                        ////For Azure basic Authentication cluster -  HBaseOperation.GetRow("https://" + host + ":" + port + "/", "Customer", "FRANR",userName, password);
                        ////For Secured Cluster - HBaseOperation.GetRow("https://" + host + ":" + port + "/", "Customer", "FRANR", userName, password);
                        break;

                    case 5:         // Scan the table
                        Console.WriteLine("Fetching all the rows from the table....");
                        PopulateTable(host, port);
                        Console.WriteLine(HBaseOperation.ScanTable("http://" + host + ":" + port + "/", "Customer"));
                        ////For Azure basic Authentication cluster - > HBaseOperation.ScanTable("https://" + host + ":" + port + "/", "Customer", userName, password);
                        ////For Secured Cluster - >HBaseOperation.ScanTable("https://" + host + ":" + port + "/", "Customer", userName, password);
                        break;

                    case 6:
                        break;

                    default:
                        Console.WriteLine("Enter valid Option");
                        break;
                    }
                } while (i != 6);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }
Example #14
0
        public ActionResult AsynchronousDefault()
        {
            ErrorMessage = "";
            string path = new System.IO.DirectoryInfo(Request.PhysicalPath + "..\\..\\..\\..\\..\\..\\..\\Data\\AdventureWorks\\AdventureWorks_Person_Contact.csv").FullName;

            try
            {
                #region creating connection
                con = new HBaseConnection("localhost", 10003);
                con.Open();
                #endregion creating connection

                #region parsing csv input file
                csv csvObj = new csv();
                object[,] cells;
                cells = null;
                cells = csvObj.Table(path, false, ',');

                #endregion parsing csv input file

                #region creating table
                tableName = "adventureworks_person_contact";
                List <string> columnFamilies = new List <string>();
                columnFamilies.Add("info");
                columnFamilies.Add("contact");
                columnFamilies.Add("others");
                if (!HBaseOperation.IsTableExists(tableName, con))
                {
                    if (columnFamilies.Count > 0)
                    {
                        HBaseOperation.CreateTable(tableName, columnFamilies, con);
                    }
                    else
                    {
                        throw new HBaseException("ERROR: Table must have at least one column family");
                    }
                }

                # endregion

                #region Inserting Values
                string[] column = new string[] { "CONTACTID", "FULLNAME", "AGE", "EMAILID", "PHONE", "MODIFIEDDATE" };
                Dictionary <string, IList <HMutation> > rowCollection = new Dictionary <string, IList <HMutation> >();
                string rowKey;
                for (int i = 0; i < cells.GetLength(0); i++)
                {
                    List <HMutation> mutations = new List <HMutation>();
                    rowKey = cells[i, 0].ToString();
                    for (int j = 1; j < column.Length; j++)
                    {
                        HMutation mutation = new HMutation();
                        mutation.ColumnFamily = j < 3 ? "info" : j < 5 ? "contact" : "others";
                        mutation.ColumnName   = column[j];
                        mutation.Value        = cells[i, j].ToString();
                        mutations.Add(mutation);
                    }
                    rowCollection[rowKey] = mutations;
                }
                HBaseOperation.InsertRows(tableName, rowCollection, con);
                #endregion Inserting Values

                page           = 0;
                skip           = -1;
                DataCollection = new Dictionary <int, DataResult>();
                ErrorMessage   = "";
            }
Example #15
0
        public void Form1_Load(object sender, EventArgs e)
        {
            rdbExcel.Checked  = true;
            groupBox1.Visible = true;
            groupBox2.Visible = false;
            button1.Visible   = true;
            try
            {
                //Initializing the HBase server connection

                #region creating connection

                con = new HBaseConnection("localhost", 10003);
                con.Open();

                #endregion creating connection

                #region parsing csv input file

                csv csvObj = new csv();
                object[,] cells;
                cells = null;
                string path = System.AppDomain.CurrentDomain.BaseDirectory;
                cells = csvObj.Table(path + "..\\..\\..\\..\\..\\..\\..\\..\\Data\\AdventureWorks\\AdventureWorks_Person_Contact.csv", false, ',');

                #endregion parsing csv input file

                #region creating table
                String        tableName      = "AdventureWorks_Person_Contact";
                List <string> columnFamilies = new List <string>();
                columnFamilies.Add("info");
                columnFamilies.Add("contact");
                columnFamilies.Add("others");

                if (!HBaseOperation.IsTableExists(tableName, con))
                {
                    if (columnFamilies.Count > 0)
                    {
                        HBaseOperation.CreateTable(tableName, columnFamilies, con);
                    }
                    else
                    {
                        throw new HBaseException("ERROR: Table must have at least one column family");
                    }
                }

                # endregion

                #region Inserting Values

                string[] column = new string[] { "CONTACTID", "FULLNAME", "AGE", "EMAILID", "PHONE", "MODIFIEDDATE" };
                Dictionary <string, IList <HMutation> > rowCollection = new Dictionary <string, IList <HMutation> >();
                string rowKey;
                for (int i = 0; i < cells.GetLength(0); i++)
                {
                    List <HMutation> mutations = new List <HMutation>();
                    rowKey = cells[i, 0].ToString();

                    for (int j = 1; j < column.Length; j++)
                    {
                        HMutation mutation = new HMutation();
                        mutation.ColumnFamily = j < 3 ? "info" : j < 5 ? "contact" : "others";
                        mutation.ColumnName   = column[j];
                        mutation.Value        = cells[i, j].ToString();
                        mutations.Add(mutation);
                    }

                    rowCollection[rowKey] = mutations;
                }
                HBaseOperation.InsertRows(tableName, rowCollection, con);

                #endregion Inserting Values

                #region scan values

                HBaseOperation.FetchSize = 100;
                table = HBaseOperation.ScanTable(tableName, con);

                #endregion scan values

                #region closing connection

                //closing the HBase connection
                con.Close();

                #endregion closing connection
            }
Example #16
0
        public MainWindow()
        {
            InitializeComponent();

            try
            {
                #region Creating connection

                HBaseConnection con = new HBaseConnection("localhost", 10003);
                con.Open();

                #endregion Creating connection

                #region Creating table

                string        tableName      = "AdventureWorks_Person_Contact";
                List <string> columnFamilies = new List <string>();
                columnFamilies.Add("info");
                columnFamilies.Add("contact");
                columnFamilies.Add("others");

                if (!HBaseOperation.IsTableExists(tableName, con))
                {
                    if (columnFamilies.Count > 0)
                    {
                        HBaseOperation.CreateTable(tableName, columnFamilies, con);
                    }
                    else
                    {
                        throw new HBaseException("ERROR: Table must have at least one column family");
                    }
                }

                # endregion

                #region Inserting Values

                #region Parsing csv input file

                csv csvObj = new csv();
                object[,] cells;
                cells = null;
                string path = System.AppDomain.CurrentDomain.BaseDirectory;
                cells = csvObj.Table(path + "..\\..\\..\\..\\..\\..\\..\\..\\Data\\AdventureWorks\\AdventureWorks_Person_Contact.csv", false, ',');

                #endregion Parsing csv input file

                string[] column = new string[] { "CONTACTID", "FULLNAME", "AGE", "EMAILID", "PHONE", "MODIFIEDDATE" };
                Dictionary <string, IList <HMutation> > rowCollection = new Dictionary <string, IList <HMutation> >();
                string rowKey;

                for (int i = 0; i < cells.GetLength(0); i++)
                {
                    List <HMutation> mutations = new List <HMutation>();
                    rowKey = cells[i, 0].ToString();

                    for (int j = 1; j < column.Length; j++)
                    {
                        HMutation mutation = new HMutation();
                        mutation.ColumnFamily = j < 3 ? "info" : j < 5 ? "contact" : "others";
                        mutation.ColumnName   = column[j];
                        mutation.Value        = cells[i, j].ToString();
                        mutations.Add(mutation);
                    }

                    rowCollection[rowKey] = mutations;
                }

                HBaseOperation.InsertRows(tableName, rowCollection, con);

                #endregion Inserting Values

                #region Fetch result

                HBaseOperation.FetchSize = 100;
                HBaseResultSet result = HBaseOperation.ScanTable(tableName, con);

                #endregion Fetch result

                //Binding the fetched result to the grid
                gridData1.ItemsSource = result;

                //closing the HBase connection
                con.Close();
            }
Example #17
0
        protected void Page_Load(object sender, EventArgs e)
        {
            ErrorMessage.InnerText = "";
            string path = string.Format("{0}\\..\\Data\\AdventureWorks\\AdventureWorks_Person_Contact.csv", Request.PhysicalPath.ToLower().Split(new string[] { "\\c# hbase samples" }, StringSplitOptions.None));

            try
            {
                #region creating connection

                HBaseConnection con = new HBaseConnection("localhost", 10003);
                con.Open();

                #endregion creating connection

                #region parsing csv input file

                csv csvObj = new csv();
                object[,] cells;
                cells = null;

                cells = csvObj.Table(path, false, ',');

                #endregion parsing csv input file

                #region creating table
                String        tableName      = "AdventureWorks_Person_Contact";
                List <string> columnFamilies = new List <string>();
                columnFamilies.Add("info");
                columnFamilies.Add("contact");
                columnFamilies.Add("others");
                if (!HBaseOperation.IsTableExists(tableName, con))
                {
                    if (columnFamilies.Count > 0)
                    {
                        HBaseOperation.CreateTable(tableName, columnFamilies, con);
                    }
                    else
                    {
                        throw new HBaseException("ERROR: Table must have at least one column family");
                    }
                }
                # endregion

                #region Inserting Values
                string[] column = new string[] { "CONTACTID", "FULLNAME", "AGE", "EMAILID", "PHONE", "MODIFIEDDATE" };
                Dictionary <string, IList <HMutation> > rowCollection = new Dictionary <string, IList <HMutation> >();
                string rowKey;
                for (int i = 0; i < cells.GetLength(0); i++)
                {
                    List <HMutation> mutations = new List <HMutation>();
                    rowKey = cells[i, 0].ToString();
                    for (int j = 1; j < column.Length; j++)
                    {
                        HMutation mutation = new HMutation();
                        mutation.ColumnFamily = j < 3 ? "info" : j < 5 ? "contact" : "others";
                        mutation.ColumnName   = column[j];
                        mutation.Value        = cells[i, j].ToString();
                        mutations.Add(mutation);
                    }
                    rowCollection[rowKey] = mutations;
                }
                HBaseOperation.InsertRows(tableName, rowCollection, con);
                #endregion Inserting Values

                #region scan values
                HBaseOperation.FetchSize = 100;
                String rowFilter = new FilterString().RowFilter(CompareOperator.Equal, Comparator.BinaryPrefix("1002")).Query();

                RowFilter = HBaseOperation.ScanTable(tableName, rowFilter, con);

                HBaseOperation.FetchSize = 100;
                String singleColumnValueFilter = new FilterString().SingleColumnValueFilter("info", "FULLNAME", CompareOperator.Equal, Comparator.BinaryPrefix("Katherine")).Query();
                SingleColumnValueFilter   = HBaseOperation.ScanTable(tableName, singleColumnValueFilter, con);
                this.FlatGrid1.DataSource = RowFilter;
                this.FlatGrid1.DataBind();
                this.FlatGrid2.DataSource = SingleColumnValueFilter;
                this.FlatGrid2.DataBind();
                #endregion scan values

                #region close connection
                //Closing the hive connection
                con.Close();
                #endregion close connection
            }
Example #18
0
        protected void Page_Load(object sender, EventArgs e)
        {
            ErrorMessage.InnerText = "";
            string path = string.Format("{0}\\..\\Data\\AdventureWorks\\AdventureWorks_Person_Contact.csv", Request.PhysicalPath.ToLower().Split(new string[] { "\\c# hbase samples" }, StringSplitOptions.None));

            try
            {
                #region creating connection

                HBaseConnection con = new HBaseConnection("localhost", 10003);
                con.Open();

                #endregion creating connection

                #region parsing csv input file

                csv csvObj = new csv();
                object[,] cells;
                cells = null;

                cells = csvObj.Table(path, false, ',');

                #endregion parsing csv input file

                #region creating table
                String        tableName      = "AdventureWorks_Person_Contact";
                List <string> columnFamilies = new List <string>();
                columnFamilies.Add("info");
                columnFamilies.Add("contact");
                columnFamilies.Add("others");
                if (!HBaseOperation.IsTableExists(tableName, con))
                {
                    if (columnFamilies.Count > 0)
                    {
                        HBaseOperation.CreateTable(tableName, columnFamilies, con);
                    }
                    else
                    {
                        throw new HBaseException("ERROR: Table must have at least one column family");
                    }
                }
                # endregion

                #region Inserting Values
                string[] column = new string[] { "CONTACTID", "FULLNAME", "AGE", "EMAILID", "PHONE", "MODIFIEDDATE" };
                Dictionary <string, IList <HMutation> > rowCollection = new Dictionary <string, IList <HMutation> >();
                string rowKey;
                for (int i = 0; i < cells.GetLength(0); i++)
                {
                    List <HMutation> mutations = new List <HMutation>();
                    rowKey = cells[i, 0].ToString();
                    for (int j = 1; j < column.Length; j++)
                    {
                        HMutation mutation = new HMutation();
                        mutation.ColumnFamily = j < 3 ? "info" : j < 5 ? "contact" : "others";
                        mutation.ColumnName   = column[j];
                        mutation.Value        = cells[i, j].ToString();
                        mutations.Add(mutation);
                    }
                    rowCollection[rowKey] = mutations;
                }
                HBaseOperation.InsertRows(tableName, rowCollection, con);
                #endregion Inserting Values

                #region scan values

                HBaseOperation.FetchSize = 100;
                HBaseResultSet table = HBaseOperation.ScanTable(tableName, con);


                StringWriter stringWriter = new StringWriter();
                //Htmlwriter for creating table to append the HiveResults
                using (HtmlTextWriter writer = new HtmlTextWriter(stringWriter))
                {
                    writer.AddAttribute(HtmlTextWriterAttribute.Border, "1");
                    writer.AddStyleAttribute(HtmlTextWriterStyle.BorderCollapse, "collapse");
                    writer.RenderBeginTag(HtmlTextWriterTag.Table);

                    writer.RenderBeginTag(HtmlTextWriterTag.Tr);

                    writer.RenderBeginTag(HtmlTextWriterTag.Th);
                    writer.Write("ContactId");
                    writer.RenderEndTag();

                    writer.RenderBeginTag(HtmlTextWriterTag.Th);
                    writer.Write("contact:EmailId");
                    writer.RenderEndTag();

                    writer.RenderBeginTag(HtmlTextWriterTag.Th);
                    writer.Write("contact:PhoneNo");
                    writer.RenderEndTag();

                    writer.RenderBeginTag(HtmlTextWriterTag.Th);
                    writer.Write("info:Age");
                    writer.RenderEndTag();

                    writer.RenderBeginTag(HtmlTextWriterTag.Th);
                    writer.Write("info:FullName");
                    writer.RenderEndTag();

                    writer.RenderBeginTag(HtmlTextWriterTag.Th);
                    writer.Write("others:ModifiedDate");
                    writer.RenderEndTag();

                    writer.RenderEndTag();
                    int count = table.Count();
                    for (int i = 0; i < count; i++)
                    {
                        writer.RenderBeginTag(HtmlTextWriterTag.Tr);
                        HBaseRecord records = table[i];

                        for (int j = 0; j < records.Count; j++)
                        {
                            Object fields = records[j];
                            writer.RenderBeginTag(HtmlTextWriterTag.Td);
                            writer.Write(fields);
                            writer.RenderEndTag();
                        }
                        writer.RenderEndTag();
                    }
                    writer.RenderEndTag();
                }
                //Binding the result to the RTE control
                string results = stringWriter.ToString();
                rteControl.RTEContent.InnerHtml = results;
                #endregion scan values

                #region close connection
                //Closing the hive connection
                con.Close();
                #endregion close connection
            }
Example #19
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            ErrorMessage.InnerText = "";
            if (hdnGroup.Value == "Word")
            {
                string path = string.Format("{0}\\..\\Data\\AdventureWorks\\AdventureWorks_Person_Contact.csv", Request.PhysicalPath.ToLower().Split(new string[] { "\\c# hbase samples" }, StringSplitOptions.None));
                try
                {
                    //Create a new document
                    WordDocument document = new WordDocument();

                    //Adding new table to the document
                    WTable doctable = new WTable(document);

                    //Adding a new section to the document.
                    WSection section = document.AddSection() as WSection;

                    //Set Margin of the section
                    section.PageSetup.Margins.All = 72;

                    //Set page size of the section
                    section.PageSetup.PageSize = new SizeF(800, 792);

                    //Create Paragraph styles
                    WParagraphStyle style = document.AddParagraphStyle("Normal") as WParagraphStyle;
                    style.CharacterFormat.FontName = "Calibri";
                    style.CharacterFormat.FontSize = 11f;

                    //Create a character format for declaring font color and style for the text inside the cell
                    WCharacterFormat charFormat = new WCharacterFormat(document);
                    charFormat.TextColor = System.Drawing.Color.White;
                    charFormat.Bold      = true;

                    #region creating connection
                    HBaseConnection con = new HBaseConnection("localhost", 10003);
                    con.Open();

                    #endregion creating connection

                    #region parsing csv input file

                    csv csvObj = new csv();
                    object[,] cells;
                    cells = null;

                    cells = csvObj.Table(path, false, ',');

                    #endregion parsing csv input file

                    #region creating table
                    String        tableName      = "AdventureWorks_Person_Contact";
                    List <string> columnFamilies = new List <string>();
                    columnFamilies.Add("info");
                    columnFamilies.Add("contact");
                    columnFamilies.Add("others");
                    if (!HBaseOperation.IsTableExists(tableName, con))
                    {
                        if (columnFamilies.Count > 0)
                        {
                            HBaseOperation.CreateTable(tableName, columnFamilies, con);
                        }
                        else
                        {
                            throw new HBaseException("ERROR: Table must have at least one column family");
                        }
                    }
                    # endregion

                    #region Inserting Values
                    string[] column = new string[] { "CONTACTID", "FULLNAME", "AGE", "EMAILID", "PHONE", "MODIFIEDDATE" };
                    Dictionary <string, IList <HMutation> > rowCollection = new Dictionary <string, IList <HMutation> >();
                    string rowKey;
                    for (int i = 0; i < cells.GetLength(0); i++)
                    {
                        List <HMutation> mutations = new List <HMutation>();
                        rowKey = cells[i, 0].ToString();
                        for (int j = 1; j < column.Length; j++)
                        {
                            HMutation mutation = new HMutation();
                            mutation.ColumnFamily = j < 3 ? "info" : j < 5 ? "contact" : "others";
                            mutation.ColumnName   = column[j];
                            mutation.Value        = cells[i, j].ToString();
                            mutations.Add(mutation);
                        }
                        rowCollection[rowKey] = mutations;
                    }
                    HBaseOperation.InsertRows(tableName, rowCollection, con);
                    #endregion Inserting Values

                    #region scan values

                    HBaseOperation.FetchSize = 100;
                    HBaseResultSet table = HBaseOperation.ScanTable(tableName, con);

                    //Adding headertext for the table
                    doctable.AddRow(true, false);
                    //Creating new cell
                    WTableCell cell = new WTableCell(document);
                    cell.AddParagraph().AppendText("ContactId").ApplyCharacterFormat(charFormat);
                    cell.Width = 100;
                    //Adding cell to the row
                    doctable.Rows[0].Cells.Add(cell);
                    cell = new WTableCell(document);
                    cell.AddParagraph().AppendText("contact:EmailId").ApplyCharacterFormat(charFormat);
                    cell.Width = 200;
                    doctable.Rows[0].Cells.Add(cell);
                    cell = new WTableCell(document);
                    cell.AddParagraph().AppendText("contact:PhoneNo").ApplyCharacterFormat(charFormat);
                    cell.Width = 150;
                    doctable.Rows[0].Cells.Add(cell);
                    cell = new WTableCell(document);
                    cell.AddParagraph().AppendText("info:Age").ApplyCharacterFormat(charFormat);
                    cell.Width = 100;
                    doctable.Rows[0].Cells.Add(cell);
                    cell = new WTableCell(document);
                    cell.AddParagraph().AppendText("info:FullName").ApplyCharacterFormat(charFormat);
                    cell.Width = 150;
                    doctable.Rows[0].Cells.Add(cell);
                    cell = new WTableCell(document);
                    cell.AddParagraph().AppendText("others:ModifiedDate").ApplyCharacterFormat(charFormat);
                    cell.Width = 200;
                    doctable.Rows[0].Cells.Add(cell);


                    //Reading each row from the fetched result
                    for (int i = 0; i < table.Count(); i++)
                    {
                        HBaseRecord records = table[i];
                        doctable.AddRow(true, false);

                        //Reading each data from the row
                        for (int j = 0; j < records.Count; j++)
                        {
                            Object fields = records[j];

                            //Adding new cell to the document
                            cell = new WTableCell(document);

                            //Adding each data to the cell
                            cell.AddParagraph().AppendText(fields.ToString());
                            if (j != 1 && j != 2 && j != 4 && j != 5)
                            {
                                cell.Width = 100;
                            }
                            else if (j == 2 || j == 4)
                            {
                                cell.Width = 150;
                            }
                            else
                            {
                                cell.Width = 200;
                            }

                            //Adding cell to the table
                            doctable.Rows[i + 1].Cells.Add(cell);
                            doctable.Rows[0].Cells[j].CellFormat.BackColor = Color.FromArgb(51, 153, 51);
                        }
                    }
                    //Adding table to the section
                    section.Tables.Add(doctable);
                    //Save as word 2007 format
                    if (rBtnWord2003.Checked == true)
                    {
                        document.Save("Sample.doc", FormatType.Doc, Response, HttpContentDisposition.Attachment);
                    }
                    else if (rBtnWord2007.Checked == true)
                    {
                        document.Save("Sample.docx", FormatType.Word2007, Response, HttpContentDisposition.Attachment);
                    }
                    //Save as word 2010 format
                    else if (rbtnWord2010.Checked == true)
                    {
                        document.Save("Sample.docx", FormatType.Word2010, Response, HttpContentDisposition.Attachment);
                    }
                    //Save as word 2013 format
                    else if (rbtnWord2013.Checked == true)
                    {
                        document.Save("Sample.docx", FormatType.Word2013, Response, HttpContentDisposition.Attachment);
                    }
                    #endregion scan values

                    #region close connection
                    //Closing the hive connection
                    con.Close();
                    #endregion close connection
                }
Example #20
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ViewModel"/> class.
        /// </summary>
        public ViewModel()
        {
            TableName = "AdventureWorks_Person_Contact";

            try
            {
                #region Creating connection

                //Initialize hbase thrift server connection
                Connection = new HBaseConnection("localhost", 10003);
                Connection.Open();

                #endregion Creating connection

                #region Creating table

                string        tableName      = "AdventureWorks_Person_Contact";
                List <string> columnFamilies = new List <string>();
                columnFamilies.Add("info");
                columnFamilies.Add("contact");
                columnFamilies.Add("others");

                if (!HBaseOperation.IsTableExists(tableName, Connection))
                {
                    if (columnFamilies.Count > 0)
                    {
                        HBaseOperation.CreateTable(tableName, columnFamilies, Connection);
                    }
                    else
                    {
                        throw new HBaseException("ERROR: Table must have at least one column family");
                    }
                }

                # endregion

                #region Inserting Values

                string path = System.AppDomain.CurrentDomain.BaseDirectory;
                path = path + "..\\..\\..\\..\\..\\..\\..\\..\\Data\\AdventureWorks\\AdventureWorks_Person_Contact.csv";

                #region Parsing csv input file

                csv csvObj = new csv();
                object[,] cells = csvObj.Table(path, false, ',');

                #endregion Parsing csv input file

                string[] column = new string[] { "CONTACTID", "FULLNAME", "AGE", "EMAILID", "PHONE", "MODIFIEDDATE" };
                Dictionary <string, IList <HMutation> > rowCollection = new Dictionary <string, IList <HMutation> >();
                string rowKey;

                for (int i = 0; i < cells.GetLength(0); i++)
                {
                    List <HMutation> mutations = new List <HMutation>();
                    rowKey = cells[i, 0].ToString();

                    for (int j = 1; j < column.Length; j++)
                    {
                        HMutation mutation = new HMutation();
                        mutation.ColumnFamily = j < 3 ? "info" : j < 5 ? "contact" : "others";
                        mutation.ColumnName   = column[j];
                        mutation.Value        = cells[i, j].ToString();
                        mutations.Add(mutation);
                    }

                    rowCollection[rowKey] = mutations;
                }

                HBaseOperation.InsertRows(tableName, rowCollection, Connection);

                #endregion Inserting Values
            }
Example #21
0
        private void BindDataSource()
        {
            ErrorMessage.InnerText = "";

            try
            {
                #region creating connection

                HBaseConnection con = new HBaseConnection("localhost", 10003);
                con.Open();

                #endregion creating connection

                #region parsing csv input file

                csv csvObj = new csv();
                object[,] cells;
                cells = null;

                cells = csvObj.Table(path, false, ',');

                #endregion parsing csv input file

                #region creating table
                String        tableName      = "AdventureWorks_Person_Contact";
                List <string> columnFamilies = new List <string>();
                columnFamilies.Add("info");
                columnFamilies.Add("contact");
                columnFamilies.Add("others");
                if (!HBaseOperation.IsTableExists(tableName, con))
                {
                    if (columnFamilies.Count > 0)
                    {
                        HBaseOperation.CreateTable(tableName, columnFamilies, con);
                    }
                    else
                    {
                        throw new HBaseException("ERROR: Table must have at least one column family");
                    }
                }
                # endregion

                #region Inserting Values
                string[] column = new string[] { "CONTACTID", "FULLNAME", "AGE", "EMAILID", "PHONE", "MODIFIEDDATE" };
                Dictionary <string, IList <HMutation> > rowCollection = new Dictionary <string, IList <HMutation> >();
                string rowKey;
                for (int i = 0; i < cells.GetLength(0); i++)
                {
                    List <HMutation> mutations = new List <HMutation>();
                    rowKey = cells[i, 0].ToString();
                    for (int j = 1; j < column.Length; j++)
                    {
                        HMutation mutation = new HMutation();
                        mutation.ColumnFamily = j < 3 ? "info" : j < 5 ? "contact" : "others";
                        mutation.ColumnName   = column[j];
                        mutation.Value        = cells[i, j].ToString();
                        mutations.Add(mutation);
                    }
                    rowCollection[rowKey] = mutations;
                }
                HBaseOperation.InsertRows(tableName, rowCollection, con);
                #endregion Inserting Values


                #region scan values

                HBaseOperation.FetchSize = 100;
                HBaseResultSet table = HBaseOperation.ScanTable(tableName, con);
                this.FlatGrid.DataSource = table;
                this.FlatGrid.DataBind();
                #endregion scan values

                #region close connection
                //Closing the hbase connection
                con.Close();
                #endregion close connection
            }