com.vesoft.nebula.driver.graph.scan.ScanResult Maven / Gradle / Ivy
The newest version!
package com.vesoft.nebula.driver.graph.scan;
import com.vesoft.nebula.driver.graph.data.ResultSet;
import java.util.ArrayList;
import java.util.List;
public abstract class ScanResult {
protected final List results;
protected List tableRows = new ArrayList<>();
protected boolean isEmpty;
public ScanResult(List results) {
this.results = results;
isEmpty = isResultsEmpty();
}
/**
* check if scan node result is empty
*
* @return boolean
*/
public boolean isEmpty() {
return isEmpty;
}
/**
* get node table rows
*
* @return list of {@link TableRow}
*/
public List getTableRows() {
if (!isEmpty && tableRows.isEmpty()) {
convertResultToRow();
}
return tableRows;
}
/**
* convert the record of results to row
*/
protected abstract void convertResultToRow();
/**
* if the scanNodeResult is empty
*
* @return boolean
*/
private boolean isResultsEmpty() {
for (ResultSet resultSet : results) {
if (!resultSet.isEmpty()) {
return false;
}
}
return true;
}
}