flink-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From se...@apache.org
Subject [01/17] flink git commit: [hotfix] [core] Small improvements to DataOutputSerializer
Date Sun, 22 Apr 2018 20:40:37 GMT
Repository: flink
Updated Branches:
  refs/heads/master 7d0bfd51e -> d519eb78e


[hotfix] [core] Small improvements to DataOutputSerializer


Project: http://git-wip-us.apache.org/repos/asf/flink/repo
Commit: http://git-wip-us.apache.org/repos/asf/flink/commit/1c533aa0
Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/1c533aa0
Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/1c533aa0

Branch: refs/heads/master
Commit: 1c533aa02722cc254dfcdff967e7060fc334c219
Parents: 7d0bfd5
Author: Stephan Ewen <sewen@apache.org>
Authored: Tue Apr 17 17:55:54 2018 +0200
Committer: Stephan Ewen <sewen@apache.org>
Committed: Sun Apr 22 16:28:33 2018 +0200

----------------------------------------------------------------------
 .../flink/core/memory/DataOutputSerializer.java | 26 ++++++++++++++++++++
 1 file changed, 26 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flink/blob/1c533aa0/flink-core/src/main/java/org/apache/flink/core/memory/DataOutputSerializer.java
----------------------------------------------------------------------
diff --git a/flink-core/src/main/java/org/apache/flink/core/memory/DataOutputSerializer.java
b/flink-core/src/main/java/org/apache/flink/core/memory/DataOutputSerializer.java
index 7b8acb7..7738a30 100644
--- a/flink-core/src/main/java/org/apache/flink/core/memory/DataOutputSerializer.java
+++ b/flink-core/src/main/java/org/apache/flink/core/memory/DataOutputSerializer.java
@@ -65,10 +65,36 @@ public class DataOutputSerializer implements DataOutputView {
 		return this.wrapper;
 	}
 
+	/**
+	 * @deprecated Replaced by {@link #getSharedBuffer()} for a better, safer name.
+	 */
+	@Deprecated
 	public byte[] getByteArray() {
+		return getSharedBuffer();
+	}
+
+	/**
+	 * Gets a reference to the internal byte buffer. This buffer may be larger than the
+	 * actual serialized data. Only the bytes from zero to {@link #length()} are valid.
+	 * The buffer will also be overwritten with the next write calls.
+	 *
+	 * <p>This method is useful when trying to avid byte copies, but should be used carefully.
+	 *
+	 * @return A reference to the internal shared and reused buffer.
+	 */
+	public byte[] getSharedBuffer() {
 		return buffer;
 	}
 
+	/**
+	 * Gets a copy of the buffer that has the right length for the data serialized so far.
+	 * The returned buffer is an exclusive copy and can be safely used without being overwritten
+	 * by future write calls to this serializer.
+	 *
+	 * <p>This method is equivalent to {@code Arrays.copyOf(getSharedBuffer(), length());}
+	 *
+	 * @return A non-shared copy of the serialization buffer.
+	 */
 	public byte[] getCopyOfBuffer() {
 		return Arrays.copyOf(buffer, position);
 	}


Mime
View raw message