You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2020/03/02 11:34:13 UTC

[GitHub] [flink] JingsongLi commented on a change in pull request #11275: [FLINK-16359][table-runtime] Introduce WritableVectors for abstract writing

JingsongLi commented on a change in pull request #11275: [FLINK-16359][table-runtime] Introduce WritableVectors for abstract writing
URL: https://github.com/apache/flink/pull/11275#discussion_r386341375
 
 

 ##########
 File path: flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/dataformat/vector/heap/HeapIntVector.java
 ##########
 @@ -47,4 +49,45 @@ public int getInt(int i) {
 			return dictionary.decodeToInt(dictionaryIds.vector[i]);
 		}
 	}
+
+	@Override
+	public void setInt(int i, int value) {
+		if (i >= vector.length) {
+			throw new RuntimeException();
+		}
+		vector[i] = value;
+	}
+
+	@Override
+	public void setIntsFromBinary(int rowId, int count, byte[] src, int srcIndex) {
+		if (LITTLE_ENDIAN) {
+			UNSAFE.copyMemory(src, BYTE_ARRAY_OFFSET + srcIndex, vector,
+					INT_ARRAY_OFFSET + rowId * 4L, count * 4L);
+		} else {
+			long srcOffset = srcIndex + BYTE_ARRAY_OFFSET;
+			for (int i = 0; i < count; ++i, srcOffset += 4) {
+				vector[i + rowId] = Integer.reverseBytes(UNSAFE.getInt(src, srcOffset));
+			}
+		}
+	}
+
+	@Override
+	public void setInts(int rowId, int count, int value) {
+		if (rowId + count - 1 >= vector.length) {
+			throw new RuntimeException();
 
 Review comment:
   Nice catch!

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services