
com.ecwid.clickhouse.mapped.ClickHouseMappedClient.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of clickhouse-client Show documentation
Show all versions of clickhouse-client Show documentation
Java client for ClickHouse HTTP API (https://clickhouse.com)
package com.ecwid.clickhouse.mapped
import com.ecwid.clickhouse.ClickHouseResponse
import com.ecwid.clickhouse.raw.ClickHouseRawClient
import com.ecwid.clickhouse.transport.HttpTransport
import com.ecwid.clickhouse.typed.ClickHouseTypedClient
import com.ecwid.clickhouse.typed.TypedRow
import com.ecwid.clickhouse.typed.TypedValues
class ClickHouseMappedClient(httpTransport: HttpTransport) {
private val typedClient = ClickHouseTypedClient(httpTransport)
fun select(host: String, sqlQuery: String, mapper: (TypedRow) -> T): ClickHouseResponse {
val typedResponse = typedClient.select(host, sqlQuery)
return MappedResponse(typedResponse, mapper)
}
fun insert(host: String, table: String, values: List, mapper: (T) -> TypedValues) {
typedClient.insert(host, table, values.map(mapper))
}
fun getRawClient(): ClickHouseRawClient = typedClient.getRawClient()
fun getTypedClient(): ClickHouseTypedClient = typedClient
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy