当前位置:网站首页>[in depth understanding of tcallusdb technology] asynchronous scanning data example code - [generic table]
[in depth understanding of tcallusdb technology] asynchronous scanning data example code - [generic table]
2022-04-22 15:14:00 【Database master】
Preparation of this paper
See Chapter : preparation .
Sample code
Sample code
import com.tencent.tcaplus.client.Client;
import com.tencent.tcaplus.client.ClientFactory;
import com.tencent.tcaplus.client.GenericTableTraverser;
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. The structure is based on part Key A request to read data from a field value
// 3.1. Get request object . In order to improve SDK performance ,Request Objects are reusable
Request request = client.acquireRequest();
// 3.2. establish 1 Scanners
GenericTableTraverser traverser = client.getGenericTableTraverser(tableName);
// 3.3. Add the data to be read Value Field
traverser.addFieldName("typeid");
traverser.addFieldName("Data");
traverser.addFieldName("uname");
// 3.4. Set the maximum number of data pieces returned in a batch , Because the amount of data returned by scanning is usually large , Batch return required
traverser.setLoadOptions(100);
// 3.5. Set the maximum number of data returned in total
traverser.setTotalLimit(10000);
CountDownLatch latch = new CountDownLatch(1);
// 4. Start the scanner asynchronously , And specify the processor that returns the result
traverser.startAsync(new Future() {
@Override
public void onResponse(Response response) {
// 5. Processing results
if (response.getResult() == 0) {
for (Record result : response.getRecordList()) {
// TODO You can add processing data codes here
}
}
if (traverser.isCompleted()) {
latch.countDown();
}
}
});
latch.await();
} 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 .
版权声明
本文为[Database master]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204221501394806.html
边栏推荐
- 【网络】传输层-UDP协议
- Installation et utilisation de la plate - forme de programmation des tâches distribuées XXL - job
- Terraform 最佳实践:典型文件布局
- Sequential list -- basic implementation of one-way headless linked list
- wxWidgets学习笔记(一):解读Code::Blocks模板工程源代码
- Ansible 实用技巧 - 批量巡检站点 URL 状态
- 小心间谍出没!维护国家安全,你我共同守护
- C语言中的动态内存
- 人脸识别 (5) 基于MCTNN人脸检测(Pytorch)
- share memory的bank conflict分析
猜你喜欢

Computer Vision L7 -- Self-supervised Learning

Operation of simulated examination platform for examination questions of safety production management personnel of hazardous chemical production units in 2022

Introduction to JVM garbage collection serial, serial old, parallel scavenge, parallel old and STW (stop the world)

wxWidgets学习笔记(一):解读Code::Blocks模板工程源代码

【Yolact数据集制作-labelme使用与转coco详解】
![[in depth understanding of tcallusdb technology] description of data interface of designated location in replacement list - [list table]](/img/7b/8c4f1549054ee8c0184495d9e8e378.png)
[in depth understanding of tcallusdb technology] description of data interface of designated location in replacement list - [list table]

Raspberry Pi B的UART极简例程

Overview of microservice Technology

mysql初始化报错

Saving notes 20: transforming notebook computer (ASUS a555l)
随机推荐
ArcGIS调用WorldWayBack历史影像并导出动画
数据库操作
如何通过云效Projex项目协同提高团队更高效的协作能力
JVM garbage collection parnew and CMS introduction
Analysis on the characteristics of the official game economic model launched by platoffarm
云呐|最新酒店行业固定资产管理办法,酒店实物资产管理系统
PlatoFarm推出正式版游戏经济模型的特点分析
Tcallusdb Jun · industry news compilation (V)
【KMP】
「译文」如何在YAML中输入多行字符串?
「译文」使用 Prometheus 和 Grafana 实现 SLO
Android UI - zoomcontrols zoom in and out pictures, Android interview resume template
这两种人是做不好自媒体的,一辈子都赚不到大钱
ROS communication mechanism III - parameter server
分布式任务调度平台XXL-JOB安装及使用
【深入理解TcaplusDB技术】读取列表指定位置数据接口说明——[List表]
多款无源探头1:1衰减比有什么区别
顺序表——单向无头链表基础实现
Bootsrap 模态框文字超出处理
【深入理解TcaplusDB技术】扫描数据示例代码——[Generic表]