英文:
page size in Ignite Sql query
问题
I am trying create a sql query on ignite to fetch records in batches. I found in ignite docs that there is a way to set page size. I would like to know if this parameter is query result payload size or number of records returned at a time.
我试图创建一个在Ignite上获取记录批量的SQL查询。我在Ignite文档中发现有一种设置页面大小的方法。我想知道这个参数是查询结果的负载大小还是一次返回的记录数量。
Also, is page size applicable only when we obtain query cursor? Is it used when we do query.getAll() ?
此外,页面大小仅在我们获取查询游标时适用吗?在执行query.getAll()时是否也会使用页面大小?
private static final String EMP_CACHE = "emp_cache";
public static void main(String[] args) {
try (Ignite ignite = Ignition.start(new IgniteConfiguration())) {
IgniteCache<Long, Employee> empCache = ignite.getOrCreateCache(empCacheConfig());
String[] dept = {"Math", "Science", "CS", "ECE", "Physics", "Chemistry", "English", "Hindi"};
long count = 10;
while (count-- > 0) {
String name = RandomStringUtils.randomAlphanumeric(20);
int deptNo = (int) (Math.random() * 7);
empCache.put(count, new Employee(count, name, dept[deptNo]));
}
FieldsQueryCursor<List>> cursor =
empCache.query(new SqlFieldsQuery("select * from empCache.EMPLOYEE").setPageSize(2));
for (List> objects : cursor) {
System.out.println("Record =" + objects);
// would this mean cursor will fetch two records and go back to ignite to fetch next batch
// OR cursor will fetch records 2KB at a time
}
}
}
public static CacheConfiguration<Long, Employee> empCacheConfig() {
CacheConfiguration<Long, Employee> empCacheConfig = new CacheConfiguration<>(EMP_CACHE);
empCacheConfig.setCacheMode(CacheMode.PARTITIONED);
empCacheConfig.setBackups(1);
empCacheConfig.setIndexedTypes(Long.class, Employee.class);
return empCacheConfig;
}
Thanks.
英文:
I am trying create a sql query on ignite to fetch records in batches. I found in ignite docs that there is a way to set page size. I would like to know if this parameter is query result payload size or number of records returned at a time.
Also, is page size applicable only when we obtain query cursor? Is it used when we do query.getAll() ?
private static final String EMP_CACHE = "emp_cache";
public static void main(String[] args) {
try (Ignite ignite = Ignition.start(new IgniteConfiguration())) {
IgniteCache<Long, Employee> empCache = ignite.getOrCreateCache(empCacheConfig());
String[] dept = {"Math", "Science", "CS", "ECE", "Physics", "Chemistry", "English", "Hindi"};
long count = 10;
while (count-- > 0) {
String name = RandomStringUtils.randomAlphanumeric(20);
int deptNo = (int) (Math.random() * 7);
empCache.put(count, new Employee(count, name, dept[deptNo]));
}
FieldsQueryCursor<List<?>> cursor =
empCache.query(new SqlFieldsQuery("select * from empCache.EMPLOYEE").setPageSize(2));
for (List<?> objects : cursor) {
System.out.println("Record =" + objects);
// would this mean cursor will fetch two records and go back to ignite to fetch next batch
// OR cursor will fetch records 2KB at a time
}
}
}
public static CacheConfiguration<Long, Employee> empCacheConfig() {
CacheConfiguration<Long, Employee> empCacheConfig = new CacheConfiguration<>(EMP_CACHE);
empCacheConfig.setCacheMode(CacheMode.PARTITIONED);
empCacheConfig.setBackups(1);
empCacheConfig.setIndexedTypes(Long.class, Employee.class);
return empCacheConfig;
}
Thanks.
答案1
得分: 1
-
pageSize
设置每个批次的行数(而非字节数)。行以批次方式从远程节点传输。 -
getAll
不受此属性影响。
英文:
-
pageSize
sets the number of rows per batch (not bytes). Rows are transferred in batches from remote nodes. -
getAll
is not affected by this property
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论