当前位置: 首页>>代码示例>>Java>>正文


Java ByteArrayDataOutput.writeInt方法代码示例

本文整理汇总了Java中org.apache.lucene.store.ByteArrayDataOutput.writeInt方法的典型用法代码示例。如果您正苦于以下问题:Java ByteArrayDataOutput.writeInt方法的具体用法?Java ByteArrayDataOutput.writeInt怎么用?Java ByteArrayDataOutput.writeInt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.lucene.store.ByteArrayDataOutput的用法示例。


在下文中一共展示了ByteArrayDataOutput.writeInt方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testCloseIntoReader

import org.apache.lucene.store.ByteArrayDataOutput; //导入方法依赖的package包/类
public void testCloseIntoReader() throws IOException {
    try (TranslogWriter writer = translog.createWriter(0)) {
        final int numOps = randomIntBetween(8, 128);
        final byte[] bytes = new byte[4];
        final ByteArrayDataOutput out = new ByteArrayDataOutput(bytes);
        for (int i = 0; i < numOps; i++) {
            out.reset(bytes);
            out.writeInt(i);
            writer.add(new BytesArray(bytes), randomNonNegativeLong());
        }
        writer.sync();
        final Checkpoint writerCheckpoint = writer.getCheckpoint();
        try (TranslogReader reader = writer.closeIntoReader()) {
            for (int i = 0; i < numOps; i++) {
                final ByteBuffer buffer = ByteBuffer.allocate(4);
                reader.readBytes(buffer, reader.getFirstOperationOffset() + 4 * i);
                buffer.flip();
                final int value = buffer.getInt();
                assertEquals(i, value);
            }
            final Checkpoint readerCheckpoint = reader.getCheckpoint();
            assertThat(readerCheckpoint, equalTo(writerCheckpoint));
        }
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:26,代码来源:TranslogTests.java

示例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);
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:24,代码来源:TestIndexInput.java

示例3: 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);
  }
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:24,代码来源:TestIndexInput.java

示例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());
}
 
开发者ID:europeana,项目名称:search,代码行数:11,代码来源:WFSTCompletionLookup.java

示例5: 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());
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:11,代码来源:WFSTCompletionLookup.java

示例6: serialize

import org.apache.lucene.store.ByteArrayDataOutput; //导入方法依赖的package包/类
@Override
public void serialize(ByteArrayDataOutput output) {
  try {
    output.writeInt(value);
  } catch (IOException e) {
    throw new RuntimeException("unexpected exception writing to a byte[]", e);
  }
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:9,代码来源:CategoryIntAssociation.java

示例7: serialize

import org.apache.lucene.store.ByteArrayDataOutput; //导入方法依赖的package包/类
@Override
public void serialize(ByteArrayDataOutput output) {
  try {
    output.writeInt(Float.floatToIntBits(value));
  } catch (IOException e) {
    throw new RuntimeException("unexpected exception writing to a byte[]", e);
  }
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:9,代码来源:CategoryFloatAssociation.java

示例8: 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());
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:11,代码来源:WFSTCompletionLookup.java


注:本文中的org.apache.lucene.store.ByteArrayDataOutput.writeInt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。