当前位置:网站首页>[tcapulusdb knowledge base] [list table] sample code for inserting data into the specified position in the list
[tcapulusdb knowledge base] [list table] sample code for inserting data into the specified position in the list
2022-06-23 03:41:00 【Tcapulus Jun】
【TcaplusDB The knowledge base 】[List surface ] Sample code for inserting data into a specified location in a list
See Chapter : preparation .
Sample code
Sample code
import com.tencent.tcaplus.client.Client;
import com.tencent.tcaplus.client.ClientFactory;
import com.tencent.tcaplus.client.Record;
import com.tencent.tcaplus.client.Request;
import com.tencent.tcaplus.client.Response;
import com.tencent.tdr.tcaplus_protocol_cs.TcaplusProtocolCsConstants;
import java.util.ArrayList;
import java.util.List;
public class Example {
public static void main(String[] arguments) {
// 1. Prepare environmental information
// 1.1. Directory service address list
List<String> dirList = new ArrayList<String>();
dirList.add("tcp://x.x.x.x:9999");
dirList.add("tcp://y.y.y.y:9999");
// 1.2. Business ID
int appId = 1;
// 1.3. Business password
String appPassword = "****************";
// 1.4. Table group ID
int tableGroupId = 1;
// 1.5. Table name
String tableName = "test";
// 2. Create client
Client client = ClientFactory.createClient(appId, tableGroupId, appPassword, dirList);
try {
// 3. Construct a request to insert data
// 3.1. Get request object . In order to improve SDK performance ,Request Objects are reusable
Request request = client.acquireRequest();
// 3.2. Set request type and target table name . Be careful : Target table must be List surface
request.setCmd(TcaplusProtocolCsConstants.TCAPLUS_CMD_LIST_ADDAFTER_REQ);
request.setTableName(tableName);
// 3.3. Specify where to insert the new data into the list
// In this case -1, Indicates insertion at the end of the list . If 0, Represents the... Inserted into the list 1 After strip data , And so on
Record record = request.addRecord(-1);
// 3.4. Set the value of each data field . Be careful :Key Fields and Value Field , Different methods are used to set field values
record.setKeyInt("gameid", 1);
record.setKeyInt("itemid", 1);
record.setKeyString("name", "test");
record.setValueByte("typeid", (byte) 1);
record.setValueByte("Data", (byte) 1);
record.setValueString("uname", "test");
// 4. Send a request , And get the results
Response response = client.poll(request);
// 5. Processing results
if (response.getResult() == 0) {
// Insert data succeeded
// TODO You can add the subsequent processing code of successful data insertion here
} else {
// Insert data failed
// TODO You can add the subsequent processing code of data insertion failure here
}
} finally {
// 6. Destroy client objects
ClientFactory.destroyClient(client);
}
}
}TcaplusDB It's a distributed product of Tencent NoSQL database , The code for storage and scheduling is completely self-developed . With cache + Landing fusion architecture 、PB Levels of storage 、 Millisecond delay 、 Lossless horizontal expansion and complex data structure . At the same time, it has rich ecological environment 、 Easy migration 、 Extremely low operation and maintenance costs and five nine high availability features . Customer coverage game 、 Internet 、 government affairs 、 Finance 、 Manufacturing and the Internet of things .
边栏推荐
- 1-1VMware介绍
- mysql常用指令
- JS remove first character of string
- [burning] Tencent cloud high tech computing platform HTPC cloud elastic cluster release!
- How to get started with apiccloud app and multi terminal development of applet based on zero Foundation
- Official announcement! The Hong Kong Zhuhai Macao Bridge is finally here!
- 【LeetCode】23. Merge K ascending linked lists
- Easygbs solution to video playback failure caused by tcp/udp configuration problems
- 【机器学习】 吴恩达机器学习作业 ex2逻辑回归 Matlab实现
- What is the reason why anonymous live OBS streaming is successful but flv video cannot be played?
猜你喜欢
![[OWT] OWT client native P2P E2E test vs2017 construction 4: Construction and link of third-party databases p2pmfc exe](/img/cd/7f896a0f05523a07b5dd04a8737879.png)
[OWT] OWT client native P2P E2E test vs2017 construction 4: Construction and link of third-party databases p2pmfc exe
![[quick view] Analysis on the development status and future development trend of the global and Chinese diamond cultivation industry in 2021 [figure]](/img/f1/972a760459a6d599b5681aa634df09.jpg)
[quick view] Analysis on the development status and future development trend of the global and Chinese diamond cultivation industry in 2021 [figure]

【owt】owt-client-native-p2p-e2e-test vs2017构建2 :测试单元构建及运行

mysql常用指令

R tree of search tree

Hierarchical attention graph convolution network for interpretable recommendation based on knowledge graph

Banknext microservice: a case study

【机器学习】 吴恩达机器学习作业 ex2逻辑回归 Matlab实现
![Analysis on the development prospect of China's brain computer interface industry in 2021: wide application prospect, sustained and rapid growth of market scale [figure]](/img/84/192d152ceb760264b6b555b321f129.jpg)
Analysis on the development prospect of China's brain computer interface industry in 2021: wide application prospect, sustained and rapid growth of market scale [figure]

JS Part 4
随机推荐
The compatibility of remotefx schemes is related to multiple factors
JS Part 4
选择排序法
[machine learning] wuenda's machine learning assignment ex2 logistic regression matlab implementation
Goframe framework: quick creation of static file download web service
How to print multiple barcode labels on one sheet of paper
Easysearcher cannot find the IP address of easynvr hardware. How to solve it?
How to batch generate jan13 barcode
Goframe framework: log configuration management
Form submit onclick and onsubmit
One of the touchdesigner uses - Download and install
Frequent actions to expand the scale of new energy industry Guangzhou plans to invest 1.4 billion in photovoltaic power generation projects
软件项目管理 8.4.软件项目质量计划
[advanced Android] entrusted by kotlin
1-1VMware介绍
Insert sort directly
TRTC zero foundation -- Video subscription on the code
This point (II)
What is the difference between the poll () method and the remove () method?
【二分】leetcode1011. Capacity To Ship Packages Within D Days