Class Utils
java.lang.Object
io.openems.backend.timedata.timescaledb.internal.Utils
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static class
Used forTimescaledbImpl#getChannelIdsFromSchemaCache(Schema, String, Set)
. -
Method Summary
Modifier and TypeMethodDescriptionstatic com.zaxxer.hikari.HikariDataSource
getDataSource
(String host, int port, String database, String user, String password, int poolSize) Creates aHikariDataSource
connection pool.static TreeMap<ZonedDateTime,
SortedMap<ChannelAddress, com.google.gson.JsonElement>> prepareDataMap
(ZonedDateTime fromDate, ZonedDateTime toDate, Set<ChannelAddress> channels, Resolution resolution) Prefills a Result-Map with JsonNull values for every timestamp/ChannelAddress.static SortedMap<ChannelAddress,
com.google.gson.JsonElement> prepareEnergyMap
(ZonedDateTime fromDate, ZonedDateTime toDate, Set<ChannelAddress> channels) Prefills a Result-Map with JsonNull values for every timestamp/ChannelAddress.querySchemaCache
(Schema schema, String edgeId, Set<String> channelAddresses) Gets the database Channel-IDs for the given Channel-Addresses from the Schema Cache.static String
toSqlInterval
(Resolution resolution) Converts a Resolution to an SQL interval.
-
Method Details
-
getDataSource
public static com.zaxxer.hikari.HikariDataSource getDataSource(String host, int port, String database, String user, String password, int poolSize) throws SQLException Creates aHikariDataSource
connection pool.- Parameters:
host
- the database hostnameport
- the database portdatabase
- the database nameuser
- the database userpassword
- the database passwordpoolSize
- the pool size- Returns:
- the HikariDataSource
- Throws:
SQLException
- on error
-
querySchemaCache
public static Map<Type,Map<Priority, querySchemaCacheMap<Integer, String>>> (Schema schema, String edgeId, Set<String> channelAddresses) Gets the database Channel-IDs for the given Channel-Addresses from the Schema Cache. -
prepareDataMap
public static TreeMap<ZonedDateTime,SortedMap<ChannelAddress, prepareDataMapcom.google.gson.JsonElement>> (ZonedDateTime fromDate, ZonedDateTime toDate, Set<ChannelAddress> channels, Resolution resolution) Prefills a Result-Map with JsonNull values for every timestamp/ChannelAddress.- Parameters:
fromDate
- the From-DatetoDate
- the To-Datechannels
- the Channelsresolution
- theResolution
- Returns:
- a prefilled result-map
-
prepareEnergyMap
public static SortedMap<ChannelAddress,com.google.gson.JsonElement> prepareEnergyMap(ZonedDateTime fromDate, ZonedDateTime toDate, Set<ChannelAddress> channels) Prefills a Result-Map with JsonNull values for every timestamp/ChannelAddress.- Parameters:
fromDate
- the From-DatetoDate
- the To-Datechannels
- the Channels- Returns:
- a prefilled result-map
-
toSqlInterval
Converts a Resolution to an SQL interval.- Parameters:
resolution
- theResolution
- Returns:
- a SQL interval string
-