private void lbSchema_SelectedIndexChanged(object sender, EventArgs e) { var schema = TableSchemaManager.GetInstance().Schemas[this.lbSchema.SelectedItem.ToString()]; this.dgvColumn.Rows.Clear(); this.cboRowKeyType.SelectedItem = schema.RowKeyType; this.cboRowKeyFormat.SelectedItem = schema.RowKeyFormat; foreach (var column in schema.ColumnTypeAndFormats) { int index = this.dgvColumn.Rows.Add(column.Key, column.Value.Item1, null); if (column.Value.Item1 == "string") { (this.dgvColumn.Rows[index].Cells[2] as DataGridViewComboBoxCell).Items.AddRange(new string[] { "ASCII", "UTF-8", "Unicode", "GBK", "GB2312" }); } else if (column.Value.Item1 == "int" || column.Value.Item1 == "long" || column.Value.Item1 == "float" || column.Value.Item1 == "double") { (this.dgvColumn.Rows[index].Cells[2] as DataGridViewComboBoxCell).Items.AddRange(new string[] { "Big-Endian", "Little-Endian" }); } else { (this.dgvColumn.Rows[index].Cells[2] as DataGridViewComboBoxCell).Items.AddRange(new string[] { "None" }); } this.dgvColumn.Rows[index].Cells[2].Value = column.Value.Item2; } }
private void btnDelete_Click(object sender, EventArgs e) { if (this.lbSchema.SelectedItem != null) { TableSchemaManager.GetInstance().Schemas.Remove(this.lbSchema.SelectedItem.ToString()); this.LoadSchema(); } }
public static TableSchemaManager GetInstance() { if (TableSchemaManager._instance == null) { TableSchemaManager._instance = new TableSchemaManager(); } return(TableSchemaManager._instance); }
private void LoadSchema() { this.lbSchema.Items.Clear(); this.dgvColumn.Rows.Clear(); foreach (var schema in TableSchemaManager.GetInstance().Schemas) { this.lbSchema.Items.Add(schema.Key); } }
private void tsmiOperateData_Click(object sender, EventArgs e) { if (TableSchemaManager.GetInstance().Schemas.ContainsKey(this.tvMain.SelectedNode.Text)) { MainForm.AddDataManagementForm(this.tvMain.SelectedNode.Text, this.tvMain.SelectedNode.Tag as ColumnDescriptor[]); } else { MessageBoxOperator.ShowWarning("Please Set Table Schema First!"); } }
private void btnAdd_Click(object sender, EventArgs e) { if (!string.IsNullOrWhiteSpace(this.txtSchemaName.Text)) { string tablename = this.txtSchemaName.Text.Trim(); if (!TableSchemaManager.GetInstance().Schemas.ContainsKey(tablename)) { TableSchemaManager.GetInstance().Schemas.Add(tablename, new TableSchema() { RowKeyType = "string", RowKeyFormat = "UTF-8" }); this.LoadSchema(); } } }
private void btnRefresh_Click(object sender, EventArgs e) { this.Enabled = false; try { HBaseThriftClient client = SetThriftServerForm.GetHBaseThriftClient(); var tables = client.GetAllTableDefinition(); this.tvMain.Nodes[0].Nodes[0].Nodes.Clear(); foreach (var table in tables) { var tn = this.tvMain.Nodes[0].Nodes[0].Nodes.Add(table.Key); tn.SetImageIndex(table.Value.Item2 ? 2 : 3); tn.Tag = table.Value.Item1; var schema = TableSchemaManager.GetInstance().Get(table.Key); if (schema != null) { var ktn = tn.Nodes.Add("Row", string.Concat("Row", "(", schema.RowKeyType, ")")); ktn.SetImageIndex(6); } foreach (var column in table.Value.Item1) { var stn = tn.Nodes.Add(column.StringName, string.Concat(column.StringName, "(", column.Compression, ")", "[", column.MaxVersions, "]")); stn.SetImageIndex(4); stn.Tag = column; if (schema != null && schema.ColumnQualifierTypeAndFormats.ContainsKey(column.StringName)) { foreach (var qualifier in schema.ColumnQualifierTypeAndFormats[column.StringName]) { var qtn = stn.Nodes.Add(qualifier.Key, string.Concat(qualifier.Key, "(", qualifier.Value, ")")); qtn.SetImageIndex(5); } } } } this.tvMain.ExpandAll(); } catch (Exception ex) { LogOperator.Get().Error(ex.ToString()); MessageBoxOperator.ShowError(ex.Message); } finally { this.Enabled = true; } }
private void btnSave_Click(object sender, EventArgs e) { this.dgvColumn.EndEdit(); Dictionary <string, Tuple <string, string> > newcolumns = new Dictionary <string, Tuple <string, string> >(); foreach (DataGridViewRow row in this.dgvColumn.Rows) { if (row.Cells[0].Value != null && !string.IsNullOrWhiteSpace(row.Cells[0].Value.ToString()) && row.Cells[1].Value != null && !string.IsNullOrWhiteSpace(row.Cells[1].Value.ToString()) && row.Cells[2].Value != null && !string.IsNullOrWhiteSpace(row.Cells[2].Value.ToString())) { if (row.Cells[0].Value.ToString().Trim().Contains(":")) { if (row.Cells[0].Value.ToString().Trim().IndexOf(':') != row.Cells[0].Value.ToString().Trim().Length - 1) { newcolumns.Add(row.Cells[0].Value.ToString().Trim(), new Tuple <string, string>(row.Cells[1].Value.ToString(), row.Cells[2].Value.ToString())); } else { MessageBoxOperator.ShowError("Empty Qualifier,like Family:Qualifier!"); return; } } else { MessageBoxOperator.ShowError("ColumnName Must Contain ':',like Family:Qualifier!"); return; } } } if (this.cboRowKeyType.SelectedItem != null) { TableSchemaManager.GetInstance().Schemas[this.lbSchema.SelectedItem.ToString()] = new TableSchema() { RowKeyType = this.cboRowKeyType.SelectedItem.ToString(), RowKeyFormat = this.cboRowKeyFormat.SelectedItem.ToString(), ColumnTypeAndFormats = newcolumns }; } else { MessageBoxOperator.ShowError("Must select row key type!"); return; } }
private void btnScanNext_Click(object sender, EventArgs e) { try { this.ClearScanQuery(); var result = HBaseThriftClient.DoScan(_scanID, (int)_maxScanCount.Value); if (result != null) { this.txtScanResult.Text = TableSchemaManager.GetInstance().ProcessTRowResultToString(this.TableName, result); this.txtScanRowCount.Text = result.Count.ToString(); } } catch (Exception ex) { MessageBoxOperator.ShowError(ex.Message); LogOperator.Get().Error(ex.ToString()); } }
public SetTableSchemaForm(string tableName) { InitializeComponent(); this.TableName = tableName; this.ColDataType.Items.AddRange(TableSchemaManager.ColumnDataTypes.Keys.ToArray()); this.cboRowKeyType.Items.AddRange(TableSchemaManager.ColumnDataTypes.Keys.Where(k => !k.StartsWith("OPC")).ToArray()); var schema = TableSchemaManager.GetInstance().Get(tableName); if (schema != null) { this.cboRowKeyType.SelectedItem = schema.RowKeyType; this.cboRowKeyFormat.SelectedItem = schema.RowKeyFormat; foreach (var column in schema.ColumnTypeAndFormats) { int index = this.dgvColumn.Rows.Add(column.Key, column.Value.Item1, null); if (column.Value.Item1 == "string") { (this.dgvColumn.Rows[index].Cells[2] as DataGridViewComboBoxCell).Items.AddRange(new string[] { "ASCII", "UTF-8", "Unicode", "GBK", "GB2312" }); } else if (column.Value.Item1 == "int" || column.Value.Item1 == "long" || column.Value.Item1 == "float" || column.Value.Item1 == "double") { (this.dgvColumn.Rows[index].Cells[2] as DataGridViewComboBoxCell).Items.AddRange(new string[] { "Big-Endian", "Little-Endian" }); } else { (this.dgvColumn.Rows[index].Cells[2] as DataGridViewComboBoxCell).Items.AddRange(new string[] { "None" }); } this.dgvColumn.Rows[index].Cells[2].Value = column.Value.Item2; } } else { this.cboRowKeyType.SelectedItem = "string"; } }
private void tsmiSetTableSchema_Click(object sender, EventArgs e) { new SetTableSchemaForm(this.tvMain.SelectedNode.Text).ShowDialog(); TableSchemaManager.GetInstance().Save(); this.btnRefresh_Click(null, null); }
private void tsbSchemaManagement_Click(object sender, EventArgs e) { new ManageSchemaForm().ShowDialog(); TableSchemaManager.GetInstance().Save(); this.btnRefresh_Click(null, null); }
public TableDataManagementFrame(string tableName, ColumnDescriptor[] columns) { InitializeComponent(); this.Text = tableName; this.TableName = tableName; this.Columns = columns; var schema = TableSchemaManager.GetInstance().Get(this.TableName); foreach (var column in columns) { TreeNode node = this.tvQueryColumn.Nodes[0].Nodes.Add(column.StringName); TreeNode node2 = this.tvScanColumns.Nodes[0].Nodes.Add(column.StringName); if (schema != null) { if (schema.ColumnQualifierTypeAndFormats.ContainsKey(column.StringName)) { foreach (var qualifier in schema.ColumnQualifierTypeAndFormats[column.StringName]) { node.Nodes.Add(qualifier.Key); node2.Nodes.Add(qualifier.Key); } } } } this.tvQueryColumn.ExpandAll(); this.tvScanColumns.ExpandAll(); _maxPrefixQueryCount = new NumericUpDown(); _maxPrefixQueryCount.Maximum = 1000; _maxPrefixQueryCount.Minimum = 1; _maxPrefixQueryCount.Value = 100; var host = new ToolStripControlHost(_maxPrefixQueryCount); host.Visible = false; this.tsSingleQuery.Items.Insert(2, host); host.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); _maxPrefixQueryCount.Width = 80; _enableSingleQueryTS = new CheckBox(); _enableSingleQueryTS.Text = "TS:"; _enableSingleQueryTS.Checked = false; _enableSingleQueryTS.CheckedChanged += EnableSingleQueryTS_CheckedChanged; host = new ToolStripControlHost(_enableSingleQueryTS); this.tsSingleQuery.Items.Insert(3, host); host.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); _singleQueryTS = new DateTimePicker(); _singleQueryTS.Enabled = false; host = new ToolStripControlHost(_singleQueryTS); this.tsSingleQuery.Items.Insert(4, host); host.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); _singleQueryTS.Width = 130; _maxScanCount = new NumericUpDown(); _maxScanCount.Maximum = 1000; _maxScanCount.Minimum = 1; _maxScanCount.Value = 100; host = new ToolStripControlHost(_maxScanCount); this.tsScan.Items.Insert(6, host); host.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); _maxPrefixQueryCount.Width = 80; this.cboScanMode.SelectedIndex = 0; ChangeScanStatus(false); }
private void btnSingleQuery_Click(object sender, EventArgs e) { if (!string.IsNullOrWhiteSpace(this.txtSingleQueryRowKey.Text)) { this.Enabled = false; try { this.ClearSingleQuery(); var schema = TableSchemaManager.GetInstance().Get(this.TableName); Type t = TableSchemaManager.ColumnDataTypes[schema.RowKeyType]; object v = Convert.ChangeType(this.txtSingleQueryRowKey.Text, t); byte[] rowkey = Extension.GetBytes(v, schema.RowKeyType, schema.RowKeyFormat); List <string> checkedcolumns = new List <string>(); foreach (TreeNode cnode in this.tvQueryColumn.Nodes[0].Nodes) { if (cnode.Checked) { checkedcolumns.Add(cnode.Text.Substring(0, cnode.Text.Length - 1)); } else { foreach (TreeNode qnode in cnode.Nodes) { if (qnode.Checked) { checkedcolumns.Add(string.Concat(cnode.Text, qnode.Text)); } } } } if (checkedcolumns.Count != 0) { List <TRowResult> result = null; long timestamp = 0; if (_enableSingleQueryTS.Checked) { timestamp = _singleQueryTS.Value.GetHBaseTimestamp(); } result = SetThriftServerForm.GetHBaseThriftClient().SingleQuery(this.TableName, rowkey, checkedcolumns, timestamp); if (result != null) { this.txtSingleQueryResult.Text = TableSchemaManager.GetInstance().ProcessTRowResultToString(this.TableName, result); this.txtSingleQueryRowCount.Text = result.Count.ToString(); } } else { MessageBoxOperator.ShowInfo("Please Check one Column at least"); } } catch (Exception ex) { MessageBoxOperator.ShowError(ex.Message); LogOperator.Get().Error(ex.ToString()); } finally { this.Enabled = true; } } }