This is an automated email from the ASF dual-hosted git repository.
amashenkov pushed a commit to branch ignite-14743-compaction
in repository https://gitbox.apache.org/repos/asf/ignite-3.git
The following commit(s) were added to refs/heads/ignite-14743-compaction by
this push:
new bee6095 Minor.
bee6095 is described below
commit bee60957920d287474d6acc23bc0c836b698d3d5
Author: Andrew Mashenkov <[email protected]>
AuthorDate: Mon Jun 28 11:32:16 2021 +0300
Minor.
---
.../internal/schema/row/ExpandableByteBuf.java | 29 +++++++---------------
1 file changed, 9 insertions(+), 20 deletions(-)
diff --git
a/modules/schema/src/main/java/org/apache/ignite/internal/schema/row/ExpandableByteBuf.java
b/modules/schema/src/main/java/org/apache/ignite/internal/schema/row/ExpandableByteBuf.java
index ae5dd89..d1ae471 100644
---
a/modules/schema/src/main/java/org/apache/ignite/internal/schema/row/ExpandableByteBuf.java
+++
b/modules/schema/src/main/java/org/apache/ignite/internal/schema/row/ExpandableByteBuf.java
@@ -23,6 +23,7 @@ import java.nio.CharBuffer;
import java.nio.charset.CharacterCodingException;
import java.nio.charset.CharsetEncoder;
import java.nio.charset.CoderResult;
+import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import org.apache.ignite.internal.util.Constants;
@@ -171,6 +172,9 @@ public class ExpandableByteBuf {
* @throws CharacterCodingException If encoding failed.
*/
public int putString(int off, String val, CharsetEncoder encoder) throws
CharacterCodingException {
+ if (val.isEmpty())
+ return 0;
+
ensureCapacity(off);
encoder.reset();
@@ -180,8 +184,11 @@ public class ExpandableByteBuf {
try {
CharBuffer valBuf = CharBuffer.wrap(val);
- while (true) {
- CoderResult cr = encoder.encode(valBuf, buf, true);
+ for(;;) {
+ CoderResult cr = valBuf.hasRemaining() ?
encoder.encode(valBuf, buf, true) : CoderResult.UNDERFLOW;
+
+ if (cr.isUnderflow())
+ cr = encoder.flush(buf);
len = buf.position();
@@ -199,24 +206,6 @@ public class ExpandableByteBuf {
}
- while (true) {
- CoderResult cr = encoder.flush(buf);
-
- len = buf.position();
-
- if (cr.isOverflow()) {
- expand(len + (int)encoder.maxBytesPerChar());
-
- continue;
- }
-
- if (cr.isUnderflow())
- break;
-
- if (cr.isError())
- cr.throwException();
- }
-
return len - off;
}
finally {