当前位置:网站首页>[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 .
边栏推荐
- Goframe framework: quick creation of static file download web service
- 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]
- Fetch request details
- [OWT] OWT client native P2P E2E test vs2017 construction 4: Construction and link of third-party databases p2pmfc exe
- Enterprise official website applet building tutorial
- WordPress modifying fixed links and pseudo statics
- 软件项目管理 8.4.软件项目质量计划
- JS Part 4
- [Zeng shuge's laser slam notes] gmapping filter based slam
- Nature: correlation between oscillatory signals and gene expression supporting human episodic memory coding
猜你喜欢
![Analysis of the number of urban residents covered by basic medical insurance, their treatment and medical treatment in other places in China in 2021 [figure]](/img/81/4d3cb059f700dd9243645e64023be7.jpg)
Analysis of the number of urban residents covered by basic medical insurance, their treatment and medical treatment in other places in China in 2021 [figure]

Google Earth engine (GEE) - long time series monthly VCI data extraction, analysis and area calculation (Mexico as an example)

软件项目管理 8.4.软件项目质量计划

【owt】owt-client-native-p2p-e2e-test vs2017构建 4 : 第三方库的构建及链接p2pmfc.exe
![Analysis on development history, industrial chain, output and enterprise layout of medical polypropylene in China in 2020 [figure]](/img/28/ebfc25ec288627706e15a07e6bdb77.jpg)
Analysis on development history, industrial chain, output and enterprise layout of medical polypropylene in China in 2020 [figure]

innodb_ruby 视角下 MySQL 记录增删改

The first batch of job hunting after 00: don't misread their "different"

嵌入式软件测试工具TPT18更新全解析

One of the touchdesigner uses - Download and install

1-1VMware介绍
随机推荐
The first batch of job hunting after 00: don't misread their "different"
Using jhipster to build microservice architecture
Goframe framework: quick creation of static file download web service
One of the touchdesigner uses - Download and install
【曾书格激光SLAM笔记】Gmapping基于滤波器的SLAM
How to share small programs released by wechat
[metauniverse 7ai rope skipping] how is this app light application realized? What are the application scenarios?
What should be prepared to develop the company's official website?
JS remove first character of string
If there is a smart bus visualization platform, can "beginning" restart indefinitely?
Tencent released the global DDoS threat report in 2021: DDoS threat has become the preferred extortion method for criminal gangs
What is the potential of dmail based on Web3.0? First round financing of $10 million?
Easysearcher cannot find the IP address of easynvr hardware. How to solve it?
TRTC zero foundation -- Video subscription on the code
Goframe framework: log configuration management
Analysis on the development status of China's watch industry in 2021: a large number of electric watches are imported [figure]
JSON. Function of the stringify() optional parameter
Enterprise official website applet building tutorial
[OWT] OWT client native P2P E2E test vs2017 build 2: test unit construction and operation
Salesforce heroku (V) application in salesforce (canvasapp)