mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-03-31 04:18:39 +00:00
this allows for better buffer usage, specifically when forwarding requests to other nodes
92 lines
2.2 KiB
Java
92 lines
2.2 KiB
Java
/*
|
|
* Licensed to Elastic Search and Shay Banon under one
|
|
* or more contributor license agreements. See the NOTICE file
|
|
* distributed with this work for additional information
|
|
* regarding copyright ownership. Elastic Search licenses this
|
|
* file to you under the Apache License, Version 2.0 (the
|
|
* "License"); you may not use this file except in compliance
|
|
* with the License. You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing,
|
|
* software distributed under the License is distributed on an
|
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
* KIND, either express or implied. See the License for the
|
|
* specific language governing permissions and limitations
|
|
* under the License.
|
|
*/
|
|
|
|
package org.elasticsearch.common.bytes;
|
|
|
|
import org.elasticsearch.common.io.stream.StreamInput;
|
|
|
|
import java.io.IOException;
|
|
import java.io.OutputStream;
|
|
|
|
/**
|
|
* A reference to bytes.
|
|
*/
|
|
public interface BytesReference {
|
|
|
|
/**
|
|
* Returns the byte at the specified index. Need to be between 0 and length.
|
|
*/
|
|
byte get(int index);
|
|
|
|
/**
|
|
* The length.
|
|
*/
|
|
int length();
|
|
|
|
/**
|
|
* Slice the bytes from the <tt>from</tt> index up to <tt>length</tt>.
|
|
*/
|
|
BytesReference slice(int from, int length);
|
|
|
|
/**
|
|
* A stream input of the bytes.
|
|
*/
|
|
StreamInput streamInput();
|
|
|
|
/**
|
|
* Writes the bytes directly to the output stream.
|
|
*/
|
|
void writeTo(OutputStream os) throws IOException;
|
|
|
|
/**
|
|
* Returns the bytes as a single byte array.
|
|
*/
|
|
byte[] toBytes();
|
|
|
|
/**
|
|
* Returns the bytes as a byte array, possibly sharing the underlying byte buffer.
|
|
*/
|
|
BytesArray toBytesArray();
|
|
|
|
/**
|
|
* Returns the bytes copied over as a byte array.
|
|
*/
|
|
BytesArray copyBytesArray();
|
|
|
|
/**
|
|
* Is there an underlying byte array for this bytes reference.
|
|
*/
|
|
boolean hasArray();
|
|
|
|
/**
|
|
* The underlying byte array (if exists).
|
|
*/
|
|
byte[] array();
|
|
|
|
/**
|
|
* The offset into the underlying byte array.
|
|
*/
|
|
int arrayOffset();
|
|
|
|
/**
|
|
* Converts to a string based on utf8.
|
|
*/
|
|
String toUtf8();
|
|
}
|