Java 类org.apache.lucene.util.packed.MonotonicBlockPackedWriter 实例源码

项目:lams    文件:Lucene49DocValuesConsumer.java   
private void addAddresses(FieldInfo field, Iterable<Number> values) throws IOException {
  meta.writeVInt(field.number);
  meta.writeByte(Lucene49DocValuesFormat.NUMERIC);
  meta.writeVInt(MONOTONIC_COMPRESSED);
  meta.writeLong(-1L);
  meta.writeLong(data.getFilePointer());
  meta.writeVLong(maxDoc);
  meta.writeVInt(PackedInts.VERSION_CURRENT);
  meta.writeVInt(BLOCK_SIZE);

  final MonotonicBlockPackedWriter writer = new MonotonicBlockPackedWriter(data, BLOCK_SIZE);
  long addr = 0;
  writer.add(addr);
  for (Number v : values) {
    addr += v.longValue();
    writer.add(addr);
  }
  writer.finish();
  meta.writeLong(data.getFilePointer());
}
项目:lams    文件:Lucene410DocValuesConsumer.java   
private void addAddresses(FieldInfo field, Iterable<Number> values) throws IOException {
  meta.writeVInt(field.number);
  meta.writeByte(Lucene410DocValuesFormat.NUMERIC);
  meta.writeVInt(MONOTONIC_COMPRESSED);
  meta.writeLong(-1L);
  meta.writeLong(data.getFilePointer());
  meta.writeVLong(maxDoc);
  meta.writeVInt(PackedInts.VERSION_CURRENT);
  meta.writeVInt(BLOCK_SIZE);

  final MonotonicBlockPackedWriter writer = new MonotonicBlockPackedWriter(data, BLOCK_SIZE);
  long addr = 0;
  writer.add(addr);
  for (Number v : values) {
    addr += v.longValue();
    writer.add(addr);
  }
  writer.finish();
  meta.writeLong(data.getFilePointer());
}
项目:search    文件:Lucene49DocValuesConsumer.java   
private void addAddresses(FieldInfo field, Iterable<Number> values) throws IOException {
  meta.writeVInt(field.number);
  meta.writeByte(Lucene49DocValuesFormat.NUMERIC);
  meta.writeVInt(MONOTONIC_COMPRESSED);
  meta.writeLong(-1L);
  meta.writeLong(data.getFilePointer());
  meta.writeVLong(maxDoc);
  meta.writeVInt(PackedInts.VERSION_CURRENT);
  meta.writeVInt(BLOCK_SIZE);

  final MonotonicBlockPackedWriter writer = new MonotonicBlockPackedWriter(data, BLOCK_SIZE);
  long addr = 0;
  writer.add(addr);
  for (Number v : values) {
    addr += v.longValue();
    writer.add(addr);
  }
  writer.finish();
  meta.writeLong(data.getFilePointer());
}
项目:search    文件:Lucene410DocValuesConsumer.java   
private void addAddresses(FieldInfo field, Iterable<Number> values) throws IOException {
  meta.writeVInt(field.number);
  meta.writeByte(Lucene410DocValuesFormat.NUMERIC);
  meta.writeVInt(MONOTONIC_COMPRESSED);
  meta.writeLong(-1L);
  meta.writeLong(data.getFilePointer());
  meta.writeVLong(maxDoc);
  meta.writeVInt(PackedInts.VERSION_CURRENT);
  meta.writeVInt(BLOCK_SIZE);

  final MonotonicBlockPackedWriter writer = new MonotonicBlockPackedWriter(data, BLOCK_SIZE);
  long addr = 0;
  writer.add(addr);
  for (Number v : values) {
    addr += v.longValue();
    writer.add(addr);
  }
  writer.finish();
  meta.writeLong(data.getFilePointer());
}
项目:NYBC    文件:DiskDocValuesConsumer.java   
@Override
public void addSortedSetField(FieldInfo field, Iterable<BytesRef> values, Iterable<Number> docToOrdCount, Iterable<Number> ords) throws IOException {
  meta.writeVInt(field.number);
  meta.writeByte(DiskDocValuesFormat.SORTED_SET);
  // write the ord -> byte[] as a binary field
  addBinaryField(field, values);
  // write the stream of ords as a numeric field
  // NOTE: we could return an iterator that delta-encodes these within a doc
  addNumericField(field, ords);

  // write the doc -> ord count as a absolute index to the stream
  meta.writeVInt(field.number);
  meta.writeByte(DiskDocValuesFormat.NUMERIC);
  meta.writeVInt(PackedInts.VERSION_CURRENT);
  meta.writeLong(data.getFilePointer());
  meta.writeVLong(maxDoc);
  meta.writeVInt(BLOCK_SIZE);

  final MonotonicBlockPackedWriter writer = new MonotonicBlockPackedWriter(data, BLOCK_SIZE);
  long addr = 0;
  for (Number v : docToOrdCount) {
    addr += v.longValue();
    writer.add(addr);
  }
  writer.finish();
}
项目:incubator-blur    文件:DiskDocValuesConsumer.java   
@Override
public void addSortedSetField(FieldInfo field, Iterable<BytesRef> values, Iterable<Number> docToOrdCount, Iterable<Number> ords) throws IOException {
  meta.writeVInt(field.number);
  meta.writeByte(DiskDocValuesFormat.SORTED_SET);
  // write the ord -> byte[] as a binary field
  addBinaryField(field, values);
  // write the stream of ords as a numeric field
  // NOTE: we could return an iterator that delta-encodes these within a doc
  addNumericField(field, ords);

  // write the doc -> ord count as a absolute index to the stream
  meta.writeVInt(field.number);
  meta.writeByte(DiskDocValuesFormat.NUMERIC);
  meta.writeVInt(PackedInts.VERSION_CURRENT);
  meta.writeLong(data.getFilePointer());
  meta.writeVLong(maxDoc);
  meta.writeVInt(BLOCK_SIZE);

  final MonotonicBlockPackedWriter writer = new MonotonicBlockPackedWriter(data, BLOCK_SIZE);
  long addr = 0;
  for (Number v : docToOrdCount) {
    addr += v.longValue();
    writer.add(addr);
  }
  writer.finish();
}
项目:read-open-source-code    文件:Lucene49DocValuesConsumer.java   
private void addAddresses(FieldInfo field, Iterable<Number> values) throws IOException {
  meta.writeVInt(field.number);
  meta.writeByte(Lucene49DocValuesFormat.NUMERIC);
  meta.writeVInt(MONOTONIC_COMPRESSED);
  meta.writeLong(-1L);
  meta.writeLong(data.getFilePointer());
  meta.writeVLong(maxDoc);
  meta.writeVInt(PackedInts.VERSION_CURRENT);
  meta.writeVInt(BLOCK_SIZE);

  final MonotonicBlockPackedWriter writer = new MonotonicBlockPackedWriter(data, BLOCK_SIZE);
  long addr = 0;
  writer.add(addr);
  for (Number v : values) {
    addr += v.longValue();
    writer.add(addr);
  }
  writer.finish();
  meta.writeLong(data.getFilePointer());
}
项目:read-open-source-code    文件:Lucene410DocValuesConsumer.java   
private void addAddresses(FieldInfo field, Iterable<Number> values) throws IOException {
  meta.writeVInt(field.number);
  meta.writeByte(Lucene410DocValuesFormat.NUMERIC);
  meta.writeVInt(MONOTONIC_COMPRESSED);
  meta.writeLong(-1L);
  meta.writeLong(data.getFilePointer());
  meta.writeVLong(maxDoc);
  meta.writeVInt(PackedInts.VERSION_CURRENT);
  meta.writeVInt(BLOCK_SIZE);

  final MonotonicBlockPackedWriter writer = new MonotonicBlockPackedWriter(data, BLOCK_SIZE);
  long addr = 0;
  writer.add(addr);
  for (Number v : values) {
    addr += v.longValue();
    writer.add(addr);
  }
  writer.finish();
  meta.writeLong(data.getFilePointer());
}
项目:lams    文件:Lucene45DocValuesConsumer.java   
@Override
public void addSortedSetField(FieldInfo field, Iterable<BytesRef> values, final Iterable<Number> docToOrdCount, final Iterable<Number> ords) throws IOException {
  checkCanWrite(field);
  meta.writeVInt(field.number);
  meta.writeByte(Lucene45DocValuesFormat.SORTED_SET);

  if (isSingleValued(docToOrdCount)) {
    meta.writeVInt(SORTED_SET_SINGLE_VALUED_SORTED);
    // The field is single-valued, we can encode it as SORTED
    addSortedField(field, values, singletonView(docToOrdCount, ords, -1L));
    return;
  }

  meta.writeVInt(SORTED_SET_WITH_ADDRESSES);

  // write the ord -> byte[] as a binary field
  addTermsDict(field, values);

  // write the stream of ords as a numeric field
  // NOTE: we could return an iterator that delta-encodes these within a doc
  addNumericField(field, ords, false);

  // write the doc -> ord count as a absolute index to the stream
  meta.writeVInt(field.number);
  meta.writeByte(Lucene45DocValuesFormat.NUMERIC);
  meta.writeVInt(DELTA_COMPRESSED);
  meta.writeLong(-1L);
  meta.writeVInt(PackedInts.VERSION_CURRENT);
  meta.writeLong(data.getFilePointer());
  meta.writeVLong(maxDoc);
  meta.writeVInt(BLOCK_SIZE);

  final MonotonicBlockPackedWriter writer = new MonotonicBlockPackedWriter(data, BLOCK_SIZE);
  long addr = 0;
  for (Number v : docToOrdCount) {
    addr += v.longValue();
    writer.add(addr);
  }
  writer.finish();
}
项目:lams    文件:Lucene410DocValuesConsumer.java   
private void addReverseTermIndex(FieldInfo field, final Iterable<BytesRef> values, int maxLength) throws IOException {
  long count = 0;
  BytesRefBuilder priorTerm = new BytesRefBuilder();
  priorTerm.grow(maxLength);
  BytesRef indexTerm = new BytesRef();
  long startFP = data.getFilePointer();
  PagedBytes pagedBytes = new PagedBytes(15);
  MonotonicBlockPackedWriter addresses = new MonotonicBlockPackedWriter(data, BLOCK_SIZE);

  for (BytesRef b : values) {
    int termPosition = (int) (count & REVERSE_INTERVAL_MASK);
    if (termPosition == 0) {
      int len = StringHelper.sortKeyLength(priorTerm.get(), b);
      indexTerm.bytes = b.bytes;
      indexTerm.offset = b.offset;
      indexTerm.length = len;
      addresses.add(pagedBytes.copyUsingLengthPrefix(indexTerm));
    } else if (termPosition == REVERSE_INTERVAL_MASK) {
      priorTerm.copyBytes(b);
    }
    count++;
  }
  addresses.finish();
  long numBytes = pagedBytes.getPointer();
  pagedBytes.freeze(true);
  PagedBytesDataInput in = pagedBytes.getDataInput();
  meta.writeLong(startFP);
  data.writeVLong(numBytes);
  data.copyBytes(in, numBytes);
}
项目:search    文件:MemoryDocValuesConsumer.java   
@Override
public void addSortedNumericField(FieldInfo field, Iterable<Number> docToValueCount, Iterable<Number> values) throws IOException {
  meta.writeVInt(field.number);

  if (isSingleValued(docToValueCount)) {
    meta.writeByte(SORTED_NUMERIC_SINGLETON);
    addNumericField(field, singletonView(docToValueCount, values, null), true);
  } else {
    meta.writeByte(SORTED_NUMERIC);

    // write the addresses:
    meta.writeVInt(PackedInts.VERSION_CURRENT);
    meta.writeVInt(BLOCK_SIZE);
    meta.writeLong(data.getFilePointer());
    final MonotonicBlockPackedWriter writer = new MonotonicBlockPackedWriter(data, BLOCK_SIZE);
    long addr = 0;
    writer.add(addr);
    for (Number v : docToValueCount) {
      addr += v.longValue();
      writer.add(addr);
    }
    writer.finish();
    long valueCount = writer.ord();
    meta.writeLong(valueCount);

    // write the values
    addNumericField(field, values, true);
  }
}
项目:search    文件:Lucene45DocValuesConsumer.java   
@Override
public void addSortedSetField(FieldInfo field, Iterable<BytesRef> values, final Iterable<Number> docToOrdCount, final Iterable<Number> ords) throws IOException {
  checkCanWrite(field);
  meta.writeVInt(field.number);
  meta.writeByte(Lucene45DocValuesFormat.SORTED_SET);

  if (isSingleValued(docToOrdCount)) {
    meta.writeVInt(SORTED_SET_SINGLE_VALUED_SORTED);
    // The field is single-valued, we can encode it as SORTED
    addSortedField(field, values, singletonView(docToOrdCount, ords, -1L));
    return;
  }

  meta.writeVInt(SORTED_SET_WITH_ADDRESSES);

  // write the ord -> byte[] as a binary field
  addTermsDict(field, values);

  // write the stream of ords as a numeric field
  // NOTE: we could return an iterator that delta-encodes these within a doc
  addNumericField(field, ords, false);

  // write the doc -> ord count as a absolute index to the stream
  meta.writeVInt(field.number);
  meta.writeByte(Lucene45DocValuesFormat.NUMERIC);
  meta.writeVInt(DELTA_COMPRESSED);
  meta.writeLong(-1L);
  meta.writeVInt(PackedInts.VERSION_CURRENT);
  meta.writeLong(data.getFilePointer());
  meta.writeVLong(maxDoc);
  meta.writeVInt(BLOCK_SIZE);

  final MonotonicBlockPackedWriter writer = new MonotonicBlockPackedWriter(data, BLOCK_SIZE);
  long addr = 0;
  for (Number v : docToOrdCount) {
    addr += v.longValue();
    writer.add(addr);
  }
  writer.finish();
}
项目:search    文件:Lucene410DocValuesConsumer.java   
private void addReverseTermIndex(FieldInfo field, final Iterable<BytesRef> values, int maxLength) throws IOException {
  long count = 0;
  BytesRefBuilder priorTerm = new BytesRefBuilder();
  priorTerm.grow(maxLength);
  BytesRef indexTerm = new BytesRef();
  long startFP = data.getFilePointer();
  PagedBytes pagedBytes = new PagedBytes(15);
  MonotonicBlockPackedWriter addresses = new MonotonicBlockPackedWriter(data, BLOCK_SIZE);

  for (BytesRef b : values) {
    int termPosition = (int) (count & REVERSE_INTERVAL_MASK);
    if (termPosition == 0) {
      int len = StringHelper.sortKeyLength(priorTerm.get(), b);
      indexTerm.bytes = b.bytes;
      indexTerm.offset = b.offset;
      indexTerm.length = len;
      addresses.add(pagedBytes.copyUsingLengthPrefix(indexTerm));
    } else if (termPosition == REVERSE_INTERVAL_MASK) {
      priorTerm.copyBytes(b);
    }
    count++;
  }
  addresses.finish();
  long numBytes = pagedBytes.getPointer();
  pagedBytes.freeze(true);
  PagedBytesDataInput in = pagedBytes.getDataInput();
  meta.writeLong(startFP);
  data.writeVLong(numBytes);
  data.copyBytes(in, numBytes);
}
项目:read-open-source-code    文件:MemoryDocValuesConsumer.java   
@Override
public void addSortedNumericField(FieldInfo field, Iterable<Number> docToValueCount, Iterable<Number> values) throws IOException {
  meta.writeVInt(field.number);

  if (isSingleValued(docToValueCount)) {
    meta.writeByte(SORTED_NUMERIC_SINGLETON);
    addNumericField(field, singletonView(docToValueCount, values, null), true);
  } else {
    meta.writeByte(SORTED_NUMERIC);

    // write the addresses:
    meta.writeVInt(PackedInts.VERSION_CURRENT);
    meta.writeVInt(BLOCK_SIZE);
    meta.writeLong(data.getFilePointer());
    final MonotonicBlockPackedWriter writer = new MonotonicBlockPackedWriter(data, BLOCK_SIZE);
    long addr = 0;
    writer.add(addr);
    for (Number v : docToValueCount) {
      addr += v.longValue();
      writer.add(addr);
    }
    writer.finish();
    long valueCount = writer.ord();
    meta.writeLong(valueCount);

    // write the values
    addNumericField(field, values, true);
  }
}
项目:read-open-source-code    文件:Lucene45DocValuesConsumer.java   
@Override
public void addSortedSetField(FieldInfo field, Iterable<BytesRef> values, final Iterable<Number> docToOrdCount, final Iterable<Number> ords) throws IOException {
  checkCanWrite(field);
  meta.writeVInt(field.number);
  meta.writeByte(Lucene45DocValuesFormat.SORTED_SET);

  if (isSingleValued(docToOrdCount)) {
    meta.writeVInt(SORTED_SET_SINGLE_VALUED_SORTED);
    // The field is single-valued, we can encode it as SORTED
    addSortedField(field, values, singletonView(docToOrdCount, ords, -1L));
    return;
  }

  meta.writeVInt(SORTED_SET_WITH_ADDRESSES);

  // write the ord -> byte[] as a binary field
  addTermsDict(field, values);

  // write the stream of ords as a numeric field
  // NOTE: we could return an iterator that delta-encodes these within a doc
  addNumericField(field, ords, false);

  // write the doc -> ord count as a absolute index to the stream
  meta.writeVInt(field.number);
  meta.writeByte(Lucene45DocValuesFormat.NUMERIC);
  meta.writeVInt(DELTA_COMPRESSED);
  meta.writeLong(-1L);
  meta.writeVInt(PackedInts.VERSION_CURRENT);
  meta.writeLong(data.getFilePointer());
  meta.writeVLong(maxDoc);
  meta.writeVInt(BLOCK_SIZE);

  final MonotonicBlockPackedWriter writer = new MonotonicBlockPackedWriter(data, BLOCK_SIZE);
  long addr = 0;
  for (Number v : docToOrdCount) {
    addr += v.longValue();
    writer.add(addr);
  }
  writer.finish();
}
项目:read-open-source-code    文件:Lucene410DocValuesConsumer.java   
private void addReverseTermIndex(FieldInfo field, final Iterable<BytesRef> values, int maxLength) throws IOException {
  long count = 0;
  BytesRefBuilder priorTerm = new BytesRefBuilder();
  priorTerm.grow(maxLength);
  BytesRef indexTerm = new BytesRef();
  long startFP = data.getFilePointer();
  PagedBytes pagedBytes = new PagedBytes(15);
  MonotonicBlockPackedWriter addresses = new MonotonicBlockPackedWriter(data, BLOCK_SIZE);

  for (BytesRef b : values) {
    int termPosition = (int) (count & REVERSE_INTERVAL_MASK);
    if (termPosition == 0) {
      int len = StringHelper.sortKeyLength(priorTerm.get(), b);
      indexTerm.bytes = b.bytes;
      indexTerm.offset = b.offset;
      indexTerm.length = len;
      addresses.add(pagedBytes.copyUsingLengthPrefix(indexTerm));
    } else if (termPosition == REVERSE_INTERVAL_MASK) {
      priorTerm.copyBytes(b);
    }
    count++;
  }
  addresses.finish();
  long numBytes = pagedBytes.getPointer();
  pagedBytes.freeze(true);
  PagedBytesDataInput in = pagedBytes.getDataInput();
  meta.writeLong(startFP);
  data.writeVLong(numBytes);
  data.copyBytes(in, numBytes);
}