KurtYoung commented on a change in pull request #8492: 
[FLINK-12563][table-runtime-blink] Introduce vector data format in blink
URL: https://github.com/apache/flink/pull/8492#discussion_r285874482
 
 

 ##########
 File path: 
flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/dataformat/ColumnarRow.java
 ##########
 @@ -0,0 +1,209 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.dataformat;
+
+import org.apache.flink.core.memory.MemorySegment;
+import org.apache.flink.core.memory.MemorySegmentFactory;
+import org.apache.flink.table.dataformat.vector.BytesColumnVector.Bytes;
+import org.apache.flink.table.dataformat.vector.VectorizedColumnBatch;
+
+/**
+ * Source directly return columnRow in order to reduce Row convert times.
+ */
+public final class ColumnarRow implements BaseRow {
+       private byte header;
+       private VectorizedColumnBatch vectorizedColumnBatch;
+       private int rowId;
+
+       public ColumnarRow() {}
+
+       public ColumnarRow(VectorizedColumnBatch vectorizedColumnBatch) {
+               this(vectorizedColumnBatch, 0);
+       }
+
+       public ColumnarRow(VectorizedColumnBatch vectorizedColumnBatch, int 
rowId) {
+               this.vectorizedColumnBatch = vectorizedColumnBatch;
+               this.rowId = rowId;
+       }
+
+       public void setVectorizedColumnBatch(
+                       VectorizedColumnBatch vectorizedColumnBatch) {
+               this.vectorizedColumnBatch = vectorizedColumnBatch;
+       }
+
+       public void setRowId(int rowId) {
+               this.rowId = rowId;
+       }
+
+       @Override
+       public byte getHeader() {
+               return header;
+       }
+
+       @Override
+       public void setHeader(byte header) {
+               this.header = header;
+       }
+
+       @Override
+       public int getArity() {
+               return vectorizedColumnBatch.getArity();
+       }
+
+       @Override
+       public boolean isNullAt(int ordinal) {
+               return vectorizedColumnBatch.isNullAt(rowId, ordinal);
+       }
+
+       @Override
+       public boolean getBoolean(int ordinal) {
+               return vectorizedColumnBatch.getBoolean(rowId, ordinal);
+       }
+
+       @Override
+       public byte getByte(int ordinal) {
+               return vectorizedColumnBatch.getByte(rowId, ordinal);
+       }
+
+       @Override
+       public short getShort(int ordinal) {
+               return vectorizedColumnBatch.getShort(rowId, ordinal);
+       }
+
+       @Override
+       public int getInt(int ordinal) {
+               return vectorizedColumnBatch.getInt(rowId, ordinal);
+       }
+
+       @Override
+       public long getLong(int ordinal) {
+               return vectorizedColumnBatch.getLong(rowId, ordinal);
+       }
+
+       @Override
+       public float getFloat(int ordinal) {
+               return vectorizedColumnBatch.getFloat(rowId, ordinal);
+       }
+
+       @Override
+       public double getDouble(int ordinal) {
+               return vectorizedColumnBatch.getDouble(rowId, ordinal);
+       }
+
+       @Override
+       public BinaryString getString(int ordinal) {
+               Bytes byteArray = vectorizedColumnBatch.getByteArray(rowId, 
ordinal);
+               MemorySegment memorySegment = 
MemorySegmentFactory.wrap(byteArray.data);
+               return BinaryString.fromAddress(new 
MemorySegment[]{memorySegment}, byteArray.offset, byteArray.len);
 
 Review comment:
   call `BinaryString.fromBytes(byte[] bytes, int offset, int numBytes)` 
instead? 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to