本文整理汇总了Java中org.apache.lucene.store.ByteArrayDataOutput.writeBytes方法的典型用法代码示例。如果您正苦于以下问题:Java ByteArrayDataOutput.writeBytes方法的具体用法?Java ByteArrayDataOutput.writeBytes怎么用?Java ByteArrayDataOutput.writeBytes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.lucene.store.ByteArrayDataOutput
的用法示例。
在下文中一共展示了ByteArrayDataOutput.writeBytes方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: binaryValue
import org.apache.lucene.store.ByteArrayDataOutput; //导入方法依赖的package包/类
@Override
public BytesRef binaryValue() {
try {
CollectionUtils.sortAndDedup(bytesList);
int size = bytesList.size();
final byte[] bytes = new byte[totalSize + (size + 1) * 5];
ByteArrayDataOutput out = new ByteArrayDataOutput(bytes);
out.writeVInt(size); // write total number of values
for (int i = 0; i < size; i ++) {
final byte[] value = bytesList.get(i);
int valueLength = value.length;
out.writeVInt(valueLength);
out.writeBytes(value, 0, valueLength);
}
return new BytesRef(bytes, 0, out.getPosition());
} catch (IOException e) {
throw new ElasticsearchException("Failed to get binary value", e);
}
}
示例2: binaryValue
import org.apache.lucene.store.ByteArrayDataOutput; //导入方法依赖的package包/类
@Override
public BytesRef binaryValue() {
try {
CollectionUtils.sortAndDedup(bytesList);
final int size = bytesList.size();
final byte[] bytes = new byte[totalSize + (size + 1) * 5];
final ByteArrayDataOutput out = new ByteArrayDataOutput(bytes);
out.writeVInt(size); // write total number of values
for (int i = 0; i < size; i++) {
final byte[] value = bytesList.get(i);
final int valueLength = value.length;
out.writeVInt(valueLength);
out.writeBytes(value, 0, valueLength);
}
return new BytesRef(bytes, 0, out.getPosition());
} catch (final IOException e) {
throw new ElasticsearchException("Failed to get binary value",
e);
}
}
示例3: binaryValue
import org.apache.lucene.store.ByteArrayDataOutput; //导入方法依赖的package包/类
@Override
public BytesRef binaryValue() {
try {
CollectionUtils.sortAndDedup(bytesList);
final int size = bytesList.size();
final byte[] bytes = new byte[totalSize + (size + 1) * 5];
final ByteArrayDataOutput out = new ByteArrayDataOutput(bytes);
out.writeVInt(size); // write total number of values
for (int i = 0; i < size; i++) {
final byte[] value = bytesList.get(i);
final int valueLength = value.length;
out.writeVInt(valueLength);
out.writeBytes(value, 0, valueLength);
}
return new BytesRef(bytes, 0, out.getPosition());
} catch (final IOException e) {
throw new ElasticsearchException("Failed to get MinHash value",
e);
}
}
示例4: encode
import org.apache.lucene.store.ByteArrayDataOutput; //导入方法依赖的package包/类
@Override
protected void encode(ByteSequencesWriter writer, ByteArrayDataOutput output, byte[] buffer, BytesRef spare, BytesRef payload, Set<BytesRef> contexts, long weight) throws IOException {
if (spare.length + 4 >= buffer.length) {
buffer = ArrayUtil.grow(buffer, spare.length + 4);
}
output.reset(buffer);
output.writeBytes(spare.bytes, spare.offset, spare.length);
output.writeInt(encodeWeight(weight));
writer.write(buffer, 0, output.getPosition());
}
示例5: encode
import org.apache.lucene.store.ByteArrayDataOutput; //导入方法依赖的package包/类
/** encodes an entry (bytes+weight) to the provided writer */
protected void encode(ByteSequencesWriter writer, ByteArrayDataOutput output, byte[] buffer, BytesRef spare, long weight) throws IOException {
if (spare.length + 8 >= buffer.length) {
buffer = ArrayUtil.grow(buffer, spare.length + 8);
}
output.reset(buffer);
output.writeBytes(spare.bytes, spare.offset, spare.length);
output.writeLong(weight);
writer.write(buffer, 0, output.getPosition());
}
示例6: encode
import org.apache.lucene.store.ByteArrayDataOutput; //导入方法依赖的package包/类
@Override
protected void encode(ByteSequencesWriter writer, ByteArrayDataOutput output, byte[] buffer, BytesRef spare, long weight) throws IOException {
if (spare.length + 4 >= buffer.length) {
buffer = ArrayUtil.grow(buffer, spare.length + 4);
}
output.reset(buffer);
output.writeBytes(spare.bytes, spare.offset, spare.length);
output.writeInt(encodeWeight(weight));
writer.write(buffer, 0, output.getPosition());
}
示例7: encode
import org.apache.lucene.store.ByteArrayDataOutput; //导入方法依赖的package包/类
@Override
protected void encode(ByteSequencesWriter writer, ByteArrayDataOutput output, byte[] buffer, BytesRef spare, BytesRef payload, long weight) throws IOException {
if (spare.length + 4 >= buffer.length) {
buffer = ArrayUtil.grow(buffer, spare.length + 4);
}
output.reset(buffer);
output.writeBytes(spare.bytes, spare.offset, spare.length);
output.writeInt(encodeWeight(weight));
writer.write(buffer, 0, output.getPosition());
}
示例8: encode
import org.apache.lucene.store.ByteArrayDataOutput; //导入方法依赖的package包/类
/** encodes an entry (bytes+(payload)+weight) to the provided writer */
protected void encode(ByteSequencesWriter writer, ByteArrayDataOutput output, byte[] buffer, BytesRef spare, BytesRef payload, long weight) throws IOException {
int requiredLength = spare.length + 8 + ((hasPayloads) ? 2 + payload.length : 0);
if (requiredLength >= buffer.length) {
buffer = ArrayUtil.grow(buffer, requiredLength);
}
output.reset(buffer);
output.writeBytes(spare.bytes, spare.offset, spare.length);
if (hasPayloads) {
output.writeBytes(payload.bytes, payload.offset, payload.length);
output.writeShort((short) payload.length);
}
output.writeLong(weight);
writer.write(buffer, 0, output.getPosition());
}