Skip to content

Yank out Bigtable hbase dependency for one ApiFutureUtils class #184

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,6 @@ lazy val cloud_gcp = project
libraryDependencies += "org.json4s" %% "json4s-native" % "3.7.0-M11",
libraryDependencies += "org.json4s" %% "json4s-core" % "3.7.0-M11",
libraryDependencies += "org.yaml" % "snakeyaml" % "2.3",
libraryDependencies += "com.google.cloud.bigtable" % "bigtable-hbase-2.x" % "2.14.2",
libraryDependencies ++= avro,
libraryDependencies ++= spark_all_provided,
dependencyOverrides ++= jackson,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package ai.chronon.integrations.cloud_gcp

import com.google.api.core.ApiFuture
import com.google.api.core.ApiFutureCallback
import com.google.api.core.ApiFutures
import com.google.common.util.concurrent.MoreExecutors

import java.util.concurrent.CompletableFuture

// Fork of the bigtable-hbase ApiFutureUtils class to avoid taking a dependency on bigtable-hbase for one class
// BigTable hbase brings in a ton of dependencies that we don't need for this one class
object ApiFutureUtils {
def toCompletableFuture[T](apiFuture: ApiFuture[T]): CompletableFuture[T] = {
val completableFuture: CompletableFuture[T] = new CompletableFuture[T]() {
override def cancel(mayInterruptIfRunning: Boolean): Boolean = {
val result: Boolean = apiFuture.cancel(mayInterruptIfRunning)
super.cancel(mayInterruptIfRunning)
result
}
}
val callback: ApiFutureCallback[T] = new ApiFutureCallback[T]() {
override def onFailure(throwable: Throwable): Unit = {
completableFuture.completeExceptionally(throwable)
}

override def onSuccess(t: T): Unit = {
completableFuture.complete(t)
}
}
ApiFutures.addCallback(apiFuture, callback, MoreExecutors.directExecutor)
completableFuture
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import com.google.cloud.bigtable.data.v2.models.Query
import com.google.cloud.bigtable.data.v2.models.Range.ByteStringRange
import com.google.cloud.bigtable.data.v2.models.RowMutation
import com.google.cloud.bigtable.data.v2.models.{TableId => BTTableId}
import com.google.cloud.bigtable.hbase2_x.ApiFutureUtils
import com.google.protobuf.ByteString
import org.slf4j.Logger
import org.slf4j.LoggerFactory
Expand Down
Loading