From 59fc033ca1739824a7c979bb26342fea80101c9d Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Mon, 22 Sep 2014 15:32:06 +0000
Subject: [PATCH] OPENDJ-1472 : File based changelog : optimize random seek in each log file CR-3727
---
opendj-sdk/opendj-core/src/main/java/org/forgerock/opendj/ldap/ByteStringBuilder.java | 28 ++++++++++++++++++++++++++++
1 files changed, 28 insertions(+), 0 deletions(-)
diff --git a/opendj-sdk/opendj-core/src/main/java/org/forgerock/opendj/ldap/ByteStringBuilder.java b/opendj-sdk/opendj-core/src/main/java/org/forgerock/opendj/ldap/ByteStringBuilder.java
index 65de162..a8e2dbd 100755
--- a/opendj-sdk/opendj-core/src/main/java/org/forgerock/opendj/ldap/ByteStringBuilder.java
+++ b/opendj-sdk/opendj-core/src/main/java/org/forgerock/opendj/ldap/ByteStringBuilder.java
@@ -26,6 +26,8 @@
*/
package org.forgerock.opendj.ldap;
+import java.io.DataInput;
+import java.io.EOFException;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -466,7 +468,33 @@
// The 1 byte char assumption was correct
this.length += len;
return this;
+ }
+ /**
+ * Appends the provided {@code DataInput} to this byte string
+ * builder.
+ *
+ * @param stream
+ * The data input stream to be appended to this byte string
+ * builder.
+ * @param length
+ * The maximum number of bytes to be appended from {@code
+ * input}.
+ * @throws IndexOutOfBoundsException
+ * If {@code length} is less than zero.
+ * @throws EOFException
+ * If this stream reaches the end before reading all the bytes.
+ * @throws IOException
+ * If an I/O error occurs.
+ */
+ public void append(DataInput stream, int length) throws EOFException, IOException {
+ if (length < 0) {
+ throw new IndexOutOfBoundsException();
+ }
+
+ ensureAdditionalCapacity(length);
+ stream.readFully(buffer, this.length, length);
+ this.length = length;
}
/**
--
Gitblit v1.10.0