当前位置:网站首页>[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 .
边栏推荐
- Get method of fetch request and data of formdata type submitted by post
- Svn local computer storage configuration
- Encryption related to returnee of national market supervision public service platform
- Insérer le tri directement
- 【机器学习】 吴恩达机器学习作业 ex2逻辑回归 Matlab实现
- Golang resource embedding scheme
- Google Earth Engine(GEE)——长时间序列逐月VCI数据提取分析和面积计算(墨西哥为例)
- For patch rollback, please check the cbpersistent log
- Goframe framework: quick creation of static file download web service
- LRU cache
猜你喜欢

Insert sort directly

Insérer le tri directement

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

Google Earth Engine(GEE)——长时间序列逐月VCI数据提取分析和面积计算(墨西哥为例)

选择排序法
![Analysis of China's integrated circuit industry chain in 2021: huge downstream market demand [figure]](/img/de/d73805aaf4345ca3d2a7baf85aab8d.jpg)
Analysis of China's integrated circuit industry chain in 2021: huge downstream market demand [figure]
![[Zeng shuge's laser slam notes] gmapping filter based slam](/img/93/b940ad95508d1c0d23642022df37f2.png)
[Zeng shuge's laser slam notes] gmapping filter based slam

Encryption related to returnee of national market supervision public service platform

centos7 安装 MySQL 及配置 innodb_ruby

Static code block, code block, constructor execution order
随机推荐
How to print array contents
Downloading sqlserver versions (2016-2019)
WordPress modifying fixed links and pseudo statics
Tcapulusdb Jun · industry news collection (IV)
直接插入排序
【贪心】leetcode991. Broken Calculator
JS array de duplication, removing the same value
TRTC zero foundation -- Video subscription on the code
Analysis on the development of duty-free industry in Hainan Province in 2021: the implementation of the new policy makes the duty-free market in Hainan more "prosperous" [figure]
If there is a smart bus visualization platform, can "beginning" restart indefinitely?
【二叉树】993. Cousins in Binary Tree
What if the self incrementing IDs of online MySQL are exhausted?
[leetcode] flip linked list II
第一批00后下场求职:不要误读他们的“不一样”
【LeetCode】两数之和II
JS Part 4
Fetch request details
Goframe framework: log configuration management
[leetcode] sum of two numbers II
Google Earth Engine(GEE)——长时间序列逐月VCI数据提取分析和面积计算(墨西哥为例)