private void jButton9ActionPerformed(java.awt.event.ActionEvent evt) { String tableName = null; List<Put> putList = null; for (int i = 0; i < listRestoreSelectedTables.getModel().getSize(); i++) { try { tableName = (String) listRestoreSelectedTables.getModel().getElementAt(i); listRestoreSelectedTables.setSelectedValue(tableName, true); hbTable = tableObjects.get(tableName); tableData = hbTable.getTableData(); tableStructure = hbTable.getTableStructure(); HTableDescriptor descriptor = tableStructure.createReadTableStructure(); byte[][] family = createTable(descriptor); putList = createPutList(tableData, family); HbaseManagerTableGetter.setTable(tableStructure.getHTableName()); HbaseManagerTableGetter._insert(putList); listRestoreSelectedTables.setSelectedValue(tableName, false); } catch (Exception e) { System.out.print("Restore of " + tableName + " Failed"); break; } } }
public void insertRowToDb(String[][] tableData, String colFamily) { String rowKey = tableData[0][0]; Put resourcePut = new Put(Bytes.toBytes(rowKey)); String[] userDataList = new String[tableData.length]; String[] userColList = new String[tableData.length]; String valueString = null; byte[] putValue = null; String action = null; for (int i = 0; i < tableData.length; i++) { userDataList[i] = tableData[i][0]; userColList[i] = tableData[i][1]; } for (int i = 1; i < userDataList.length; i++) { valueString = userDataList[i]; if (HBaseManagerViewTable.coloumnTypeList.containsKey(userColList[i])) { action = HBaseManagerViewTable.coloumnTypeList.get(userColList[i]); putValue = HBaseTableManager.getConvertedValue(valueString, action, userColList[i]); } else { putValue = Bytes.toBytes(userDataList[i]); } resourcePut.add(Bytes.toBytes(colFamily), Bytes.toBytes(userColList[i]), putValue); } _insert(resourcePut); }