Last active
July 19, 2022 06:15
-
-
Save shivam-880/f120f32f553b09ac92dd369440c45dc3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
private val vectorSchemaRoot = VectorSchemaRoot.create(schema, allocator) | |
val id = vectorSchemaRoot.getVector("id").asInstanceOf[IntVector] | |
val username = vectorSchemaRoot.getVector("username").asInstanceOf[VarCharVector] | |
val pro = vectorSchemaRoot.getVector("pro").asInstanceOf[BitVector] | |
val ls = List(1000, "iamsmkr", true) | |
val vectors = List(id, username, pro) | |
ls.zip(vectors).map { (value, vector) => | |
vector.allocateNew() | |
vector.setSafe(0, value) | |
vector.setValueCount(1) | |
vector.get(0) | |
} | |
// Returned is the list of values as a validation of value vectors being set correctly | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment