- java.lang.Object
-
- com.gpudb.GPUdbSqlIterator<T>
-
- All Implemented Interfaces:
AutoCloseable,Iterable<T>
public class GPUdbSqlIterator<T extends Record> extends Object implements Iterable<T>, AutoCloseable
Kinetica API class for iterating over records returned by executing an SQL query. This class accepts aGPUdbinstance and an SQL statement to facilitate iteration over the records returned by the query. SQL options can be passed as aMap. The 'batchSize' for the number of records returned is set to a default of '10000', which can be modified using the parameter 'batchSize' to the constructor. Example usage, passing a database connection and a SQL statement to theGPUdbSqlIterator:try (GPUdbSqlIterator<Record> iterator = new GPUdbSqlIterator<>(gpudb, sql);) { for (Record record : iterator) System.out.println(record); } catch (Exception e) { System.err.println("Error in iteration: " + e.getMessage()); }Copyright (c) 2023 Kinetica DB Inc.
-
-
Constructor Summary
Constructors Constructor Description GPUdbSqlIterator(GPUdb db, String sql)Constructor forGPUdbSqlIteratorGPUdbSqlIterator(GPUdb db, String sql, int batchSize)Constructor forGPUdbSqlIteratorGPUdbSqlIterator(GPUdb db, String sql, int batchSize, Map<String,String> sqlOptions)Constructor forGPUdbSqlIteratorGPUdbSqlIterator(GPUdb db, String sql, Map<String,String> sqlOptions)Constructor forGPUdbSqlIterator
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Iterator<T>iterator()voidsetSqlOptions(Map<String,String> sqlOptions)longsize()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Constructor Detail
-
GPUdbSqlIterator
public GPUdbSqlIterator(GPUdb db, String sql) throws GPUdbException
Constructor forGPUdbSqlIterator- Parameters:
db- - aGPUdbinstancesql- - the SQL statement to execute- Throws:
GPUdbException
-
GPUdbSqlIterator
public GPUdbSqlIterator(GPUdb db, String sql, int batchSize) throws GPUdbException
Constructor forGPUdbSqlIterator- Parameters:
db- - aGPUdbinstancesql- - the SQL statement to executebatchSize- - the number of records to fetch- Throws:
GPUdbException
-
GPUdbSqlIterator
public GPUdbSqlIterator(GPUdb db, String sql, Map<String,String> sqlOptions) throws GPUdbException
Constructor forGPUdbSqlIterator- Parameters:
db- - aGPUdbinstancesql- - the SQL statement to executesqlOptions- - the SQL options to be passed in- Throws:
GPUdbException- See Also:
GPUdb.executeSql(String, long, long, String, List, Map)
-
GPUdbSqlIterator
public GPUdbSqlIterator(GPUdb db, String sql, int batchSize, Map<String,String> sqlOptions) throws GPUdbException
Constructor forGPUdbSqlIterator- Parameters:
db- - aGPUdbinstancesql- - the SQL statement to executebatchSize- - the number of records to fetchsqlOptions- - the SQL options to be passed in- Throws:
GPUdbException- See Also:
GPUdb.executeSql(String, long, long, String, List, Map)
-
-
Method Detail
-
size
public long size()
-
close
public void close() throws Exception- Specified by:
closein interfaceAutoCloseable- Throws:
Exception
-
-