本文整理汇总了Java中org.apache.lucene.store.ByteArrayDataOutput.writeLong方法的典型用法代码示例。如果您正苦于以下问题:Java ByteArrayDataOutput.writeLong方法的具体用法?Java ByteArrayDataOutput.writeLong怎么用?Java ByteArrayDataOutput.writeLong使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.lucene.store.ByteArrayDataOutput
的用法示例。
在下文中一共展示了ByteArrayDataOutput.writeLong方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: beforeClass
import org.apache.lucene.store.ByteArrayDataOutput; //导入方法依赖的package包/类
@BeforeClass
public static void beforeClass() throws IOException {
Random random = random();
INTS = new int[COUNT];
LONGS = new long[COUNT];
RANDOM_TEST_BYTES = new byte[COUNT * (5 + 4 + 9 + 8)];
final ByteArrayDataOutput bdo = new ByteArrayDataOutput(RANDOM_TEST_BYTES);
for (int i = 0; i < COUNT; i++) {
final int i1 = INTS[i] = random.nextInt();
bdo.writeVInt(i1);
bdo.writeInt(i1);
final long l1;
if (rarely()) {
// a long with lots of zeroes at the end
l1 = LONGS[i] = TestUtil.nextLong(random, 0, Integer.MAX_VALUE) << 32;
} else {
l1 = LONGS[i] = TestUtil.nextLong(random, 0, Long.MAX_VALUE);
}
bdo.writeVLong(l1);
bdo.writeLong(l1);
}
}
示例2: beforeClass
import org.apache.lucene.store.ByteArrayDataOutput; //导入方法依赖的package包/类
@BeforeClass
public static void beforeClass() throws IOException {
Random random = random();
INTS = new int[COUNT];
LONGS = new long[COUNT];
RANDOM_TEST_BYTES = new byte[COUNT * (5 + 4 + 9 + 8)];
final ByteArrayDataOutput bdo = new ByteArrayDataOutput(RANDOM_TEST_BYTES);
for (int i = 0; i < COUNT; i++) {
final int i1 = INTS[i] = random.nextInt();
bdo.writeVInt(i1);
bdo.writeInt(i1);
final long l1;
if (rarely()) {
// a long with lots of zeroes at the end
l1 = LONGS[i] = _TestUtil.nextLong(random, 0, Integer.MAX_VALUE) << 32;
} else {
l1 = LONGS[i] = _TestUtil.nextLong(random, 0, Long.MAX_VALUE);
}
bdo.writeVLong(l1);
bdo.writeLong(l1);
}
}
示例3: 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());
}
示例4: 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());
}