All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.ecwid.clickhouse.mapped.ClickHouseMappedClient.kt Maven / Gradle / Ivy

There is a newer version: 0.16.0
Show newest version
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