Вот код, который я использую:
Код: Выделить всё
import com.toshiba.mwcloud.gs.*;
public class GridDBTest {
public static void main(String[] args) throws GSException {
GridStoreFactory factory = GridStoreFactory.getInstance();
GridStore store = factory.getGridStore("host=127.0.0.1;port=10001;clusterName=myCluster;user=admin;password=admin");
// Define time-series container with timestamp and value columns
ContainerInfo containerInfo = new ContainerInfo();
containerInfo.setType(ContainerType.TIME_SERIES);
containerInfo.setRowKeyAssigned(true);
containerInfo.setColumnInfoList(List.of(
new ColumnInfo("timestamp", GSType.TIMESTAMP),
new ColumnInfo("value", GSType.DOUBLE)
));
TimeSeries timeSeries = store.putTimeSeries("SampleData", containerInfo, true);
// Insert data
for (int i = 0; i < 10; i++) {
Date timestamp = new Date(System.currentTimeMillis() - (i * 1000L));
Row row = timeSeries.createRow();
row.setTimestamp(0, timestamp);
row.setDouble(1, Math.random() * 100);
timeSeries.put(timestamp, row);
}
// Attempt to retrieve data
RowSet rs = timeSeries.query(new Date(System.currentTimeMillis() - 60000), new Date()).fetch();
while (rs.hasNext()) {
Row row = rs.next();
System.out.println("Timestamp: " + row.getTimestamp(0) + ", Value: " + row.getDouble(1));
}
store.close();
}
}
Код: Выделить всё
Exception in thread "main" com.toshiba.mwcloud.gs.GSException: RowSet not initialized
at com.toshiba.mwcloud.gs.RowSetImpl.hasNext(RowSetImpl.java:48)
...
Проверил данные подключения (хост, порт, имя кластера и т. д.) и подтвердил, что они верны.
Убедился, что шаг создания контейнера выполняется без ошибок.
Проверено, требуется ли fetch() сразу после метода query() для инициализации RowSet.
Несмотря на эти шаги, я все равно получаю ту же ошибку. Я что-то упускаю при обработке запросов или это может быть связано с проблемой конфигурации в GridDB? Любые предложения будут полезны!
Подробнее здесь: https://stackoverflow.com/questions/791 ... ot-initial