List of usage examples for org.apache.lucene.util.packed BlockPackedWriter BlockPackedWriter
public BlockPackedWriter(DataOutput out, int blockSize)
From source file:org.apache.blur.lucene.codec.DiskDocValuesConsumer.java
License:Apache License
@Override public void addNumericField(FieldInfo field, Iterable<Number> values) throws IOException { long count = 0; for (@SuppressWarnings("unused") Number nv : values) {/*from w w w .j av a 2 s . c o m*/ ++count; } meta.writeVInt(field.number); meta.writeByte(DiskDocValuesFormat.NUMERIC); meta.writeVInt(PackedInts.VERSION_CURRENT); meta.writeLong(data.getFilePointer()); meta.writeVLong(count); meta.writeVInt(BLOCK_SIZE); final BlockPackedWriter writer = new BlockPackedWriter(data, BLOCK_SIZE); for (Number nv : values) { writer.add(nv.longValue()); } writer.finish(); }
From source file:org.yipeng.test.util.packed.TestPackedInts.java
License:Apache License
@Test public void testBlockReader() throws IOException { String path = "E:/yipeng/my_lucene/index_dir/packedints"; Directory dir = FSDirectory.open(Paths.get(path)); final IndexOutput out = dir.createOutput("out.bin", IOContext.DEFAULT); final BlockPackedWriter writer = new BlockPackedWriter(out, 128); writer.add(2);/*from ww w.j av a2 s .c o m*/ writer.add(4); writer.add(2 << 3); writer.add(2 << 4); writer.add(2 << 5); writer.add(2 << 6); writer.add(2 << 7); writer.add(2 << 8); writer.add(2 << 9); writer.finish(); out.close(); }