forked from opensearch-project/k-NN
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added IndexOutputWithBuffer. Removed print logging.
- Loading branch information
Dooyong Kim
committed
Sep 11, 2024
1 parent
bf9bf61
commit 143e13a
Showing
2 changed files
with
36 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
src/main/java/org/opensearch/knn/index/util/IndexOutputWithBuffer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.knn.index.util; | ||
|
||
import org.apache.lucene.store.IndexOutput; | ||
|
||
import java.io.IOException; | ||
|
||
public class IndexOutputWithBuffer { | ||
public IndexOutputWithBuffer(IndexOutput indexOutput) { | ||
this.indexOutput = indexOutput; | ||
} | ||
|
||
public byte[] getBuffer() { | ||
return buffer; | ||
} | ||
|
||
public void writeBytes(int length) { | ||
try { | ||
indexOutput.writeBytes(buffer, 0, length); | ||
} catch (IOException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "{indexOutput=" + indexOutput + ", len(buffer)=" + buffer.length + "}"; | ||
} | ||
|
||
private IndexOutput indexOutput; | ||
private byte[] buffer = new byte[4 * 1024]; | ||
} |