Help Center/
CloudTable Service/
Developer Guide/
HBase Application Development Guide/
Developing Term Index Applications/
Sample Code Description/
Writing Data
Updated on 2024-11-28 GMT+08:00
Writing Data
The data write API is the same as the native HBase API.
Below is an example of the code implementation.
Sample Code
public void testPut() { LOG.info("Entering testPut."); try(Table table = conn.getTable(tableName)) { List<Put> puts = new ArrayList<>(); Arrays.stream(SPLIT.split(LemonConstants.COMMA)) .forEach(startkey -> { // Instantiate a Put object. Put put = new Put(Bytes.toBytes(startkey + "-rowkey001")); put.addColumn(FAM_M, QUA_M, Bytes.toBytes("bachelor")); put.addColumn(FAM_N, QUA_N, Bytes.toBytes("xiaowang")); puts.add(put); Put put1 = new Put(Bytes.toBytes(startkey + "-rowkey0012")); put1.addColumn(FAM_M, QUA_M, Bytes.toBytes("master")); put1.addColumn(FAM_N, QUA_N, Bytes.toBytes("xiaoming")); puts.add(put1); // Submit a put request. try { table.put(puts); } catch (IOException e) { LOG.info("put exception", e); } }); LOG.info("Put successfully."); } catch (IOException e) { LOG.error("Put failed ", e); } LOG.info("Exiting testPut."); }
Parent topic: Sample Code Description
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
The system is busy. Please try again later.
For any further questions, feel free to contact us through the chatbot.
Chatbot