Abolfazl karimian
08/02/2023, 10:33 AMConfiguration conf = new Configuration();
TableClient myTableClient = DefaultTableClient.create(conf);
Table myTable = Table.forPath("Table/Path");
Snapshot mySnapshot = myTable.getLatestSnapshot(myTableClient);
Scan myScan = mySnapshot.getScanBuilder(myTableClient).build();
Row state = myScan.getScanState(myTableClient);
CloseableIterator<ColumnarBatch> FilesBatchIter = myScan.getScanFiles(myTableClient);
Optional<Expression> exp = Optional.empty();
this is the configuration that seems right.(I dont know about Optional<Expression>)
Not i want to use them to fetch data from table
while (FilesBatchIter.hasNext()) {
CloseableIterator<Row> files = FilesBatchIter.next().getRows();
CloseableIterator<DataReadResult> dataResult = Scan.readData(myTableClient, state, files, exp);
// prints the file names
while (files.hasNext()) {
Row file = files.next();
String column1Value = file.getString(0);
System.out.println(column1Value);
}
// Checking if any result is fetched by Scan.readData
while (dataResult.hasNext()) {
System.out.println("Data Found!");
}
}
It will prints file names but it seems there would be nothing in dataResult.
Any Ideas? or any sample code? (edited)Tom van Bussel
08/02/2023, 2:25 PMfiles
? Scan.readData
uses the argument iterator directly, instead of creating a copy of it. With your current code the iterator is completely emptied by the time that dataResult.hasNext()
is called.Abolfazl karimian
08/05/2023, 8:44 AM