当前位置:网站首页>[tcapulusdb knowledge base] [list table] example code for replacing the data at the specified location in the list
[tcapulusdb knowledge base] [list table] example code for replacing the data at the specified location in the list
2022-06-23 03:45:00 【Tcapulus Jun】
【TcaplusDB The knowledge base 】[List surface ] Sample code for replacing location data specified in the 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. Request to construct replacement 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
request.setCmd(TcaplusProtocolCsConstants.TCAPLUS_CMD_LIST_REPLACE_REQ);
request.setTableName(tableName);
// 3.3. because List In the table , Can be more Key Same data , So when you call some interfaces ,
// You need to specify the number of data in the replacement data list , In this case 0, Take the first place 1 individual , And so on
Record record = request.addRecord(0);
// 3.4. Setting list Key Value of field . explain :Key Field values are not allowed to be updated
record.setKeyInt("gameid", 1);
record.setKeyInt("itemid", 1);
record.setKeyString("name", "test");
// 3.5. Set each Value New value for field
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) {
// Replace data successfully
// TODO You can add the subsequent processing code of successful data replacement here
} else {
// Failed to replace data
// TODO You can add the subsequent processing code of data replacement 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 .
边栏推荐
- China's economy has entered the stage of "the third mock examination coexisting", and JD and Shopify have jointly arranged global DTC
- What is the potential of dmail based on Web3.0? First round financing of $10 million?
- Talk about memory model and memory order
- [binary tree] 993 Cousins in Binary Tree
- [metauniverse 7ai rope skipping] how is this app light application realized? What are the application scenarios?
- Nezha panel modifies logo, small icon and other information
- 嵌入式软件测试工具TPT18更新全解析
- Software project management 8.4 Software project quality plan
- Svn local computer storage configuration
- 【LeetCode】179. Maximum number
猜你喜欢
![[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 :测试单元构建及运行

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

直接插入排序

MySQL data recovery (.Ibdata1, bin log)

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

1-1 introduction to VMWare

第一批00后下场求职:不要误读他们的“不一样”

Centos7 installing MySQL and configuring InnoDB_ ruby
![[Zeng shuge's laser slam notes] gmapping filter based slam](/img/93/b940ad95508d1c0d23642022df37f2.png)
[Zeng shuge's laser slam notes] gmapping filter based slam
随机推荐
Static code block, code block, constructor execution order
第一批00后下场求职:不要误读他们的“不一样”
Hierarchical attention graph convolution network for interpretable recommendation based on knowledge graph
Half search method
Even if you don't learn gradle, these common development operations are worth mastering
【LeetCode】23. 合并K个升序链表
MySQL common instructions
[advanced Android] kotlin delegate attribute
Simply use the pagoda to build WordPress
Engineer culture: should the company buy genuine software
[tcapulusdb knowledge base] [list table] delete all data sample codes in the list
【机器学习】 吴恩达机器学习作业 ex2逻辑回归 Matlab实现
【LeetCode】179. Maximum number
This point (II)
Gakataka student end to bundle Version (made by likewendy)
Analysis on the development of China's satellite navigation industry chain in 2021: satellite navigation is fully integrated into production and life, and the satellite navigation industry is also boo
Brief introduction to arm architecture
How to implement collection sorting?
[OWT] OWT client native P2P E2E test vs2017 construction 4: Construction and link of third-party databases p2pmfc exe
Frequent actions to expand the scale of new energy industry Guangzhou plans to invest 1.4 billion in photovoltaic power generation projects