Skip to content

Instantly share code, notes, and snippets.

View shivam-880's full-sized avatar
🔬

Shivam shivam-880

🔬
View GitHub Profile
private val allocator: BufferAllocator = new RootAllocator()
private val schema: Schema =
new Schema(List(
new Field("id", new FieldType(false, new ArrowType.Int(32, true), null), null),
new Field("username", new FieldType(false, new ArrowType.Utf8(), null), null),
new Field("pro", new FieldType(false, new ArrowType.Bool(), null), null)
).asJava)
import org.apache.arrow.vector._
import shapeless.{::, Generic, HList, HNil}
trait AllocateNew[T] {
def allocateNew(vector: T): Unit
}
object AllocateNew {
def apply[T](implicit derivative: AllocateNew[T]): AllocateNew[T] =
val ls = List(1000, "iamsmkr", true)
val vectors = List(id, username, pro)
id.allocateNew()
username.allocateNew()
pro.allocateNew()
id.setSafe(0, ls(0))
username.setSafe(0, ls(1))
private val allocator: BufferAllocator = new RootAllocator()
private val schema: Schema =
new Schema(List(
new Field("id", new FieldType(false, new ArrowType.Int(32, true), null), null),
new Field("username", new FieldType(false, new ArrowType.Utf8(), null), null),
new Field("pro", new FieldType(false, new ArrowType.Bool(), null), null)
).asJava)
trait ValueVector {
def allocateNew()
}
abstract class BaseFixedWidthVector extends ValueVector {
def allocateNew() {
// impl
}
}
Runtime.getRuntime.addShutdownHook(new Thread() {
override def run(): Unit = {
serviceDiscovery.close()
client.close()
}
})
127.0.0.1,8877,0
127.0.0.1,8855,0
127.0.0.1,8866,1
import scala.jdk.CollectionConverters._
val services = serviceDiscovery.queryForInstances("flightServer").asScala
services.foreach(i => {
println(s"${i.getAddress},${i.getPort},${i.getPayload.partitionId}")
})
val ServiceDiscoveryAtomicPath = "/flightServers"
val serviceDiscovery =
ServiceDiscoveryBuilder
.builder(classOf[ServiceDetail])
.client(zkClient)
.basePath(ServiceDiscoveryAtomicPath)
.build()
serviceDiscovery.start()
% /opt/zookeeper/current/bin/zkCli.sh
[zk: localhost:2181(CONNECTED) 3] ls /flightServers/flightServer
[978ead9a-64d3-4080-9163-235cf99fe1b9, a89b2126-27cb-43c2-a687-2d8d57d74077, d87c5515-4d26-46fa-bc02-06edcc04f86a]
[zk: localhost:2181(CONNECTED) 4] get /flightServers/flightServer/978ead9a-64d3-4080-9163-235cf99fe1b9
{
"name": "flightServer",
"id": "978ead9a-64d3-4080-9163-235cf99fe1b9",
"address": "127.0.0.1",
"port": 8877,