Java 类org.apache.lucene.util.PagedBytes 实例源码

项目:lams    文件:Lucene410DocValuesProducer.java   
/** returns a reverse lookup instance for prefix-compressed binary values. */
private synchronized ReverseTermsIndex getReverseIndexInstance(FieldInfo field, BinaryEntry bytes) throws IOException {
  ReverseTermsIndex index = reverseIndexInstances.get(field.number);
  if (index == null) {
    index = new ReverseTermsIndex();
    data.seek(bytes.reverseIndexOffset);
    long size = (bytes.count + REVERSE_INTERVAL_MASK) >>> REVERSE_INTERVAL_SHIFT;
    index.termAddresses = MonotonicBlockPackedReader.of(data, bytes.packedIntsVersion, bytes.blockSize, size, false);
    long dataSize = data.readVLong();
    PagedBytes pagedBytes = new PagedBytes(15);
    pagedBytes.copy(data, dataSize);
    index.terms = pagedBytes.freeze(true);
    reverseIndexInstances.put(field.number, index);
    ramBytesUsed.addAndGet(index.termAddresses.ramBytesUsed() + index.terms.ramBytesUsed());
  }
  return index;
}
项目:search    文件:Lucene410DocValuesProducer.java   
/** returns a reverse lookup instance for prefix-compressed binary values. */
private synchronized ReverseTermsIndex getReverseIndexInstance(FieldInfo field, BinaryEntry bytes) throws IOException {
  ReverseTermsIndex index = reverseIndexInstances.get(field.number);
  if (index == null) {
    index = new ReverseTermsIndex();
    data.seek(bytes.reverseIndexOffset);
    long size = (bytes.count + REVERSE_INTERVAL_MASK) >>> REVERSE_INTERVAL_SHIFT;
    index.termAddresses = MonotonicBlockPackedReader.of(data, bytes.packedIntsVersion, bytes.blockSize, size, false);
    long dataSize = data.readVLong();
    PagedBytes pagedBytes = new PagedBytes(15);
    pagedBytes.copy(data, dataSize);
    index.terms = pagedBytes.freeze(true);
    reverseIndexInstances.put(field.number, index);
    ramBytesUsed.addAndGet(index.termAddresses.ramBytesUsed() + index.terms.ramBytesUsed());
  }
  return index;
}
项目:read-open-source-code    文件:Lucene410DocValuesProducer.java   
/** returns a reverse lookup instance for prefix-compressed binary values. */
private synchronized ReverseTermsIndex getReverseIndexInstance(FieldInfo field, BinaryEntry bytes) throws IOException {
  ReverseTermsIndex index = reverseIndexInstances.get(field.number);
  if (index == null) {
    index = new ReverseTermsIndex();
    data.seek(bytes.reverseIndexOffset);
    long size = (bytes.count + REVERSE_INTERVAL_MASK) >>> REVERSE_INTERVAL_SHIFT;
    index.termAddresses = MonotonicBlockPackedReader.of(data, bytes.packedIntsVersion, bytes.blockSize, size, false);
    long dataSize = data.readVLong();
    PagedBytes pagedBytes = new PagedBytes(15);
    pagedBytes.copy(data, dataSize);
    index.terms = pagedBytes.freeze(true);
    reverseIndexInstances.put(field.number, index);
    ramBytesUsed.addAndGet(index.termAddresses.ramBytesUsed() + index.terms.ramBytesUsed());
  }
  return index;
}
项目:lams    文件:Lucene40DocValuesReader.java   
private BinaryDocValues loadBytesFixedStraight(FieldInfo field) throws IOException {
  String fileName = IndexFileNames.segmentFileName(state.segmentInfo.name + "_" + Integer.toString(field.number), segmentSuffix, "dat");
  IndexInput input = dir.openInput(fileName, state.context);
  boolean success = false;
  try {
    CodecUtil.checkHeader(input, Lucene40DocValuesFormat.BYTES_FIXED_STRAIGHT_CODEC_NAME,
                                 Lucene40DocValuesFormat.BYTES_FIXED_STRAIGHT_VERSION_START,
                                 Lucene40DocValuesFormat.BYTES_FIXED_STRAIGHT_VERSION_CURRENT);
    final int fixedLength = input.readInt();
    PagedBytes bytes = new PagedBytes(16);
    bytes.copy(input, fixedLength * (long)state.segmentInfo.getDocCount());
    final PagedBytes.Reader bytesReader = bytes.freeze(true);
    CodecUtil.checkEOF(input);
    success = true;
    ramBytesUsed.addAndGet(bytesReader.ramBytesUsed());
    return new BinaryDocValues() {

      @Override
      public BytesRef get(int docID) {
        final BytesRef term = new BytesRef();
        bytesReader.fillSlice(term, fixedLength * (long)docID, fixedLength);
        return term;
      }
    };
  } finally {
    if (success) {
      IOUtils.close(input);
    } else {
      IOUtils.closeWhileHandlingException(input);
    }
  }
}
项目:lams    文件:Lucene40DocValuesReader.java   
private SortedDocValues loadBytesFixedSorted(FieldInfo field, IndexInput data, IndexInput index) throws IOException {
  CodecUtil.checkHeader(data, Lucene40DocValuesFormat.BYTES_FIXED_SORTED_CODEC_NAME_DAT,
                              Lucene40DocValuesFormat.BYTES_FIXED_SORTED_VERSION_START,
                              Lucene40DocValuesFormat.BYTES_FIXED_SORTED_VERSION_CURRENT);
  CodecUtil.checkHeader(index, Lucene40DocValuesFormat.BYTES_FIXED_SORTED_CODEC_NAME_IDX,
                               Lucene40DocValuesFormat.BYTES_FIXED_SORTED_VERSION_START,
                               Lucene40DocValuesFormat.BYTES_FIXED_SORTED_VERSION_CURRENT);

  final int fixedLength = data.readInt();
  final int valueCount = index.readInt();

  PagedBytes bytes = new PagedBytes(16);
  bytes.copy(data, fixedLength * (long) valueCount);
  final PagedBytes.Reader bytesReader = bytes.freeze(true);
  final PackedInts.Reader reader = PackedInts.getReader(index);
  ramBytesUsed.addAndGet(bytesReader.ramBytesUsed() + reader.ramBytesUsed());

  return correctBuggyOrds(new SortedDocValues() {
    @Override
    public int getOrd(int docID) {
      return (int) reader.get(docID);
    }

    @Override
    public BytesRef lookupOrd(int ord) {
      final BytesRef term = new BytesRef();
      bytesReader.fillSlice(term, fixedLength * (long) ord, fixedLength);
      return term;
    }

    @Override
    public int getValueCount() {
      return valueCount;
    }
  });
}
项目:lams    文件:Lucene40DocValuesReader.java   
private SortedDocValues loadBytesVarSorted(FieldInfo field, IndexInput data, IndexInput index) throws IOException {
  CodecUtil.checkHeader(data, Lucene40DocValuesFormat.BYTES_VAR_SORTED_CODEC_NAME_DAT,
                              Lucene40DocValuesFormat.BYTES_VAR_SORTED_VERSION_START,
                              Lucene40DocValuesFormat.BYTES_VAR_SORTED_VERSION_CURRENT);
  CodecUtil.checkHeader(index, Lucene40DocValuesFormat.BYTES_VAR_SORTED_CODEC_NAME_IDX,
                               Lucene40DocValuesFormat.BYTES_VAR_SORTED_VERSION_START,
                               Lucene40DocValuesFormat.BYTES_VAR_SORTED_VERSION_CURRENT);

  long maxAddress = index.readLong();
  PagedBytes bytes = new PagedBytes(16);
  bytes.copy(data, maxAddress);
  final PagedBytes.Reader bytesReader = bytes.freeze(true);
  final PackedInts.Reader addressReader = PackedInts.getReader(index);
  final PackedInts.Reader ordsReader = PackedInts.getReader(index);

  final int valueCount = addressReader.size() - 1;
  ramBytesUsed.addAndGet(bytesReader.ramBytesUsed() + addressReader.ramBytesUsed() + ordsReader.ramBytesUsed());

  return correctBuggyOrds(new SortedDocValues() {
    @Override
    public int getOrd(int docID) {
      return (int)ordsReader.get(docID);
    }

    @Override
    public BytesRef lookupOrd(int ord) {
      final BytesRef term = new BytesRef();
      long startAddress = addressReader.get(ord);
      long endAddress = addressReader.get(ord+1);
      bytesReader.fillSlice(term, startAddress, (int)(endAddress - startAddress));
      return term;
    }

    @Override
    public int getValueCount() {
      return valueCount;
    }
  });
}
项目: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);
}
项目:lams    文件:BinaryDocValuesWriter.java   
public BinaryDocValuesWriter(FieldInfo fieldInfo, Counter iwBytesUsed) {
  this.fieldInfo = fieldInfo;
  this.bytes = new PagedBytes(BLOCK_BITS);
  this.bytesOut = bytes.getDataOutput();
  this.lengths = PackedLongValues.deltaPackedBuilder(PackedInts.COMPACT);
  this.iwBytesUsed = iwBytesUsed;
  this.docsWithField = new FixedBitSet(64);
  this.bytesUsed = docsWithFieldBytesUsed();
  iwBytesUsed.addAndGet(bytesUsed);
}
项目:search    文件:MemoryDocValuesProducer.java   
private BytesAndAddresses loadBinary(FieldInfo field) throws IOException {
  BytesAndAddresses bytesAndAddresses = new BytesAndAddresses();
  BinaryEntry entry = binaries.get(field.number);
  data.seek(entry.offset);
  PagedBytes bytes = new PagedBytes(16);
  bytes.copy(data, entry.numBytes);
  bytesAndAddresses.reader = bytes.freeze(true);
  ramBytesUsed.addAndGet(bytesAndAddresses.reader.ramBytesUsed());
  if (entry.minLength != entry.maxLength) {
    data.seek(data.getFilePointer() + entry.missingBytes);
    bytesAndAddresses.addresses = MonotonicBlockPackedReader.of(data, entry.packedIntsVersion, entry.blockSize, maxDoc, false);
    ramBytesUsed.addAndGet(bytesAndAddresses.addresses.ramBytesUsed());
  }
  return bytesAndAddresses;
}
项目:search    文件:FixedGapTermsIndexReader.java   
public FieldIndexData(FieldInfo fieldInfo, PagedBytes termBytes, int numIndexTerms, long indexStart, long termsStart, long packedIndexStart,
                      long packedOffsetsStart) throws IOException {

  this.termsStart = termsStart;
  this.indexStart = indexStart;
  this.packedIndexStart = packedIndexStart;
  this.packedOffsetsStart = packedOffsetsStart;
  this.numIndexTerms = numIndexTerms;

  if (indexDivisor > 0) {
    loadTermsIndex(termBytes);
  }
}
项目:search    文件:Lucene40DocValuesReader.java   
private BinaryDocValues loadBytesFixedStraight(FieldInfo field) throws IOException {
  String fileName = IndexFileNames.segmentFileName(state.segmentInfo.name + "_" + Integer.toString(field.number), segmentSuffix, "dat");
  IndexInput input = dir.openInput(fileName, state.context);
  boolean success = false;
  try {
    CodecUtil.checkHeader(input, Lucene40DocValuesFormat.BYTES_FIXED_STRAIGHT_CODEC_NAME,
                                 Lucene40DocValuesFormat.BYTES_FIXED_STRAIGHT_VERSION_START,
                                 Lucene40DocValuesFormat.BYTES_FIXED_STRAIGHT_VERSION_CURRENT);
    final int fixedLength = input.readInt();
    PagedBytes bytes = new PagedBytes(16);
    bytes.copy(input, fixedLength * (long)state.segmentInfo.getDocCount());
    final PagedBytes.Reader bytesReader = bytes.freeze(true);
    CodecUtil.checkEOF(input);
    success = true;
    ramBytesUsed.addAndGet(bytesReader.ramBytesUsed());
    return new BinaryDocValues() {

      @Override
      public BytesRef get(int docID) {
        final BytesRef term = new BytesRef();
        bytesReader.fillSlice(term, fixedLength * (long)docID, fixedLength);
        return term;
      }
    };
  } finally {
    if (success) {
      IOUtils.close(input);
    } else {
      IOUtils.closeWhileHandlingException(input);
    }
  }
}
项目:search    文件:Lucene40DocValuesReader.java   
private SortedDocValues loadBytesFixedSorted(FieldInfo field, IndexInput data, IndexInput index) throws IOException {
  CodecUtil.checkHeader(data, Lucene40DocValuesFormat.BYTES_FIXED_SORTED_CODEC_NAME_DAT,
                              Lucene40DocValuesFormat.BYTES_FIXED_SORTED_VERSION_START,
                              Lucene40DocValuesFormat.BYTES_FIXED_SORTED_VERSION_CURRENT);
  CodecUtil.checkHeader(index, Lucene40DocValuesFormat.BYTES_FIXED_SORTED_CODEC_NAME_IDX,
                               Lucene40DocValuesFormat.BYTES_FIXED_SORTED_VERSION_START,
                               Lucene40DocValuesFormat.BYTES_FIXED_SORTED_VERSION_CURRENT);

  final int fixedLength = data.readInt();
  final int valueCount = index.readInt();

  PagedBytes bytes = new PagedBytes(16);
  bytes.copy(data, fixedLength * (long) valueCount);
  final PagedBytes.Reader bytesReader = bytes.freeze(true);
  final PackedInts.Reader reader = PackedInts.getReader(index);
  ramBytesUsed.addAndGet(bytesReader.ramBytesUsed() + reader.ramBytesUsed());

  return correctBuggyOrds(new SortedDocValues() {
    @Override
    public int getOrd(int docID) {
      return (int) reader.get(docID);
    }

    @Override
    public BytesRef lookupOrd(int ord) {
      final BytesRef term = new BytesRef();
      bytesReader.fillSlice(term, fixedLength * (long) ord, fixedLength);
      return term;
    }

    @Override
    public int getValueCount() {
      return valueCount;
    }
  });
}
项目:search    文件:Lucene40DocValuesReader.java   
private SortedDocValues loadBytesVarSorted(FieldInfo field, IndexInput data, IndexInput index) throws IOException {
  CodecUtil.checkHeader(data, Lucene40DocValuesFormat.BYTES_VAR_SORTED_CODEC_NAME_DAT,
                              Lucene40DocValuesFormat.BYTES_VAR_SORTED_VERSION_START,
                              Lucene40DocValuesFormat.BYTES_VAR_SORTED_VERSION_CURRENT);
  CodecUtil.checkHeader(index, Lucene40DocValuesFormat.BYTES_VAR_SORTED_CODEC_NAME_IDX,
                               Lucene40DocValuesFormat.BYTES_VAR_SORTED_VERSION_START,
                               Lucene40DocValuesFormat.BYTES_VAR_SORTED_VERSION_CURRENT);

  long maxAddress = index.readLong();
  PagedBytes bytes = new PagedBytes(16);
  bytes.copy(data, maxAddress);
  final PagedBytes.Reader bytesReader = bytes.freeze(true);
  final PackedInts.Reader addressReader = PackedInts.getReader(index);
  final PackedInts.Reader ordsReader = PackedInts.getReader(index);

  final int valueCount = addressReader.size() - 1;
  ramBytesUsed.addAndGet(bytesReader.ramBytesUsed() + addressReader.ramBytesUsed() + ordsReader.ramBytesUsed());

  return correctBuggyOrds(new SortedDocValues() {
    @Override
    public int getOrd(int docID) {
      return (int)ordsReader.get(docID);
    }

    @Override
    public BytesRef lookupOrd(int ord) {
      final BytesRef term = new BytesRef();
      long startAddress = addressReader.get(ord);
      long endAddress = addressReader.get(ord+1);
      bytesReader.fillSlice(term, startAddress, (int)(endAddress - startAddress));
      return term;
    }

    @Override
    public int getValueCount() {
      return valueCount;
    }
  });
}
项目: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);
}
项目:search    文件:BinaryDocValuesWriter.java   
public BinaryDocValuesWriter(FieldInfo fieldInfo, Counter iwBytesUsed) {
  this.fieldInfo = fieldInfo;
  this.bytes = new PagedBytes(BLOCK_BITS);
  this.bytesOut = bytes.getDataOutput();
  this.lengths = PackedLongValues.deltaPackedBuilder(PackedInts.COMPACT);
  this.iwBytesUsed = iwBytesUsed;
  this.docsWithField = new FixedBitSet(64);
  this.bytesUsed = docsWithFieldBytesUsed();
  iwBytesUsed.addAndGet(bytesUsed);
}
项目:NYBC    文件:Lucene40DocValuesReader.java   
private BinaryDocValues loadBytesFixedStraight(FieldInfo field) throws IOException {
  String fileName = IndexFileNames.segmentFileName(state.segmentInfo.name + "_" + Integer.toString(field.number), segmentSuffix, "dat");
  IndexInput input = dir.openInput(fileName, state.context);
  boolean success = false;
  try {
    CodecUtil.checkHeader(input, Lucene40DocValuesFormat.BYTES_FIXED_STRAIGHT_CODEC_NAME, 
                                 Lucene40DocValuesFormat.BYTES_FIXED_STRAIGHT_VERSION_START, 
                                 Lucene40DocValuesFormat.BYTES_FIXED_STRAIGHT_VERSION_CURRENT);
    final int fixedLength = input.readInt();
    PagedBytes bytes = new PagedBytes(16);
    bytes.copy(input, fixedLength * (long)state.segmentInfo.getDocCount());
    final PagedBytes.Reader bytesReader = bytes.freeze(true);
    if (input.getFilePointer() != input.length()) {
      throw new CorruptIndexException("did not read all bytes from file \"" + fileName + "\": read " + input.getFilePointer() + " vs size " + input.length() + " (resource: " + input + ")");
    }
    success = true;
    return new BinaryDocValues() {
      @Override
      public void get(int docID, BytesRef result) {
        bytesReader.fillSlice(result, fixedLength * (long)docID, fixedLength);
      }
    };
  } finally {
    if (success) {
      IOUtils.close(input);
    } else {
      IOUtils.closeWhileHandlingException(input);
    }
  }
}
项目:NYBC    文件:Lucene40DocValuesReader.java   
private SortedDocValues loadBytesFixedSorted(FieldInfo field, IndexInput data, IndexInput index) throws IOException {
  CodecUtil.checkHeader(data, Lucene40DocValuesFormat.BYTES_FIXED_SORTED_CODEC_NAME_DAT, 
                              Lucene40DocValuesFormat.BYTES_FIXED_SORTED_VERSION_START, 
                              Lucene40DocValuesFormat.BYTES_FIXED_SORTED_VERSION_CURRENT);
  CodecUtil.checkHeader(index, Lucene40DocValuesFormat.BYTES_FIXED_SORTED_CODEC_NAME_IDX, 
                               Lucene40DocValuesFormat.BYTES_FIXED_SORTED_VERSION_START, 
                               Lucene40DocValuesFormat.BYTES_FIXED_SORTED_VERSION_CURRENT);

  final int fixedLength = data.readInt();
  final int valueCount = index.readInt();

  PagedBytes bytes = new PagedBytes(16);
  bytes.copy(data, fixedLength * (long) valueCount);
  final PagedBytes.Reader bytesReader = bytes.freeze(true);
  final PackedInts.Reader reader = PackedInts.getReader(index);

  return correctBuggyOrds(new SortedDocValues() {
    @Override
    public int getOrd(int docID) {
      return (int) reader.get(docID);
    }

    @Override
    public void lookupOrd(int ord, BytesRef result) {
      bytesReader.fillSlice(result, fixedLength * (long) ord, fixedLength);
    }

    @Override
    public int getValueCount() {
      return valueCount;
    }
  });
}
项目:NYBC    文件:Lucene40DocValuesReader.java   
private SortedDocValues loadBytesVarSorted(FieldInfo field, IndexInput data, IndexInput index) throws IOException {
  CodecUtil.checkHeader(data, Lucene40DocValuesFormat.BYTES_VAR_SORTED_CODEC_NAME_DAT, 
                              Lucene40DocValuesFormat.BYTES_VAR_SORTED_VERSION_START, 
                              Lucene40DocValuesFormat.BYTES_VAR_SORTED_VERSION_CURRENT);
  CodecUtil.checkHeader(index, Lucene40DocValuesFormat.BYTES_VAR_SORTED_CODEC_NAME_IDX, 
                               Lucene40DocValuesFormat.BYTES_VAR_SORTED_VERSION_START, 
                               Lucene40DocValuesFormat.BYTES_VAR_SORTED_VERSION_CURRENT);

  long maxAddress = index.readLong();
  PagedBytes bytes = new PagedBytes(16);
  bytes.copy(data, maxAddress);
  final PagedBytes.Reader bytesReader = bytes.freeze(true);
  final PackedInts.Reader addressReader = PackedInts.getReader(index);
  final PackedInts.Reader ordsReader = PackedInts.getReader(index);

  final int valueCount = addressReader.size() - 1;

  return correctBuggyOrds(new SortedDocValues() {
    @Override
    public int getOrd(int docID) {
      return (int)ordsReader.get(docID);
    }

    @Override
    public void lookupOrd(int ord, BytesRef result) {
      long startAddress = addressReader.get(ord);
      long endAddress = addressReader.get(ord+1);
      bytesReader.fillSlice(result, startAddress, (int)(endAddress - startAddress));
    }

    @Override
    public int getValueCount() {
      return valueCount;
    }
  });
}
项目:read-open-source-code    文件:Lucene40DocValuesReader.java   
private BinaryDocValues loadBytesFixedStraight(FieldInfo field) throws IOException {
  String fileName = IndexFileNames.segmentFileName(state.segmentInfo.name + "_" + Integer.toString(field.number), segmentSuffix, "dat");
  IndexInput input = dir.openInput(fileName, state.context);
  boolean success = false;
  try {
    CodecUtil.checkHeader(input, Lucene40DocValuesFormat.BYTES_FIXED_STRAIGHT_CODEC_NAME,
                                 Lucene40DocValuesFormat.BYTES_FIXED_STRAIGHT_VERSION_START,
                                 Lucene40DocValuesFormat.BYTES_FIXED_STRAIGHT_VERSION_CURRENT);
    final int fixedLength = input.readInt();
    PagedBytes bytes = new PagedBytes(16);
    bytes.copy(input, fixedLength * (long)state.segmentInfo.getDocCount());
    final PagedBytes.Reader bytesReader = bytes.freeze(true);
    if (input.getFilePointer() != input.length()) {
      throw new CorruptIndexException("did not read all bytes from file \"" + fileName + "\": read " + input.getFilePointer() + " vs size " + input.length() + " (resource: " + input + ")");
    }
    success = true;
    ramBytesUsed.addAndGet(bytes.ramBytesUsed());
    return new BinaryDocValues() {
      @Override
      public void get(int docID, BytesRef result) {
        bytesReader.fillSlice(result, fixedLength * (long)docID, fixedLength);
      }
    };
  } finally {
    if (success) {
      IOUtils.close(input);
    } else {
      IOUtils.closeWhileHandlingException(input);
    }
  }
}
项目:read-open-source-code    文件:Lucene40DocValuesReader.java   
private SortedDocValues loadBytesFixedSorted(FieldInfo field, IndexInput data, IndexInput index) throws IOException {
  CodecUtil.checkHeader(data, Lucene40DocValuesFormat.BYTES_FIXED_SORTED_CODEC_NAME_DAT,
                              Lucene40DocValuesFormat.BYTES_FIXED_SORTED_VERSION_START,
                              Lucene40DocValuesFormat.BYTES_FIXED_SORTED_VERSION_CURRENT);
  CodecUtil.checkHeader(index, Lucene40DocValuesFormat.BYTES_FIXED_SORTED_CODEC_NAME_IDX,
                               Lucene40DocValuesFormat.BYTES_FIXED_SORTED_VERSION_START,
                               Lucene40DocValuesFormat.BYTES_FIXED_SORTED_VERSION_CURRENT);

  final int fixedLength = data.readInt();
  final int valueCount = index.readInt();

  PagedBytes bytes = new PagedBytes(16);
  bytes.copy(data, fixedLength * (long) valueCount);
  final PagedBytes.Reader bytesReader = bytes.freeze(true);
  final PackedInts.Reader reader = PackedInts.getReader(index);
  ramBytesUsed.addAndGet(bytes.ramBytesUsed() + reader.ramBytesUsed());

  return correctBuggyOrds(new SortedDocValues() {
    @Override
    public int getOrd(int docID) {
      return (int) reader.get(docID);
    }

    @Override
    public void lookupOrd(int ord, BytesRef result) {
      bytesReader.fillSlice(result, fixedLength * (long) ord, fixedLength);
    }

    @Override
    public int getValueCount() {
      return valueCount;
    }
  });
}
项目:read-open-source-code    文件:Lucene40DocValuesReader.java   
private SortedDocValues loadBytesVarSorted(FieldInfo field, IndexInput data, IndexInput index) throws IOException {
  CodecUtil.checkHeader(data, Lucene40DocValuesFormat.BYTES_VAR_SORTED_CODEC_NAME_DAT,
                              Lucene40DocValuesFormat.BYTES_VAR_SORTED_VERSION_START,
                              Lucene40DocValuesFormat.BYTES_VAR_SORTED_VERSION_CURRENT);
  CodecUtil.checkHeader(index, Lucene40DocValuesFormat.BYTES_VAR_SORTED_CODEC_NAME_IDX,
                               Lucene40DocValuesFormat.BYTES_VAR_SORTED_VERSION_START,
                               Lucene40DocValuesFormat.BYTES_VAR_SORTED_VERSION_CURRENT);

  long maxAddress = index.readLong();
  PagedBytes bytes = new PagedBytes(16);
  bytes.copy(data, maxAddress);
  final PagedBytes.Reader bytesReader = bytes.freeze(true);
  final PackedInts.Reader addressReader = PackedInts.getReader(index);
  final PackedInts.Reader ordsReader = PackedInts.getReader(index);

  final int valueCount = addressReader.size() - 1;
  ramBytesUsed.addAndGet(bytes.ramBytesUsed() + addressReader.ramBytesUsed() + ordsReader.ramBytesUsed());

  return correctBuggyOrds(new SortedDocValues() {
    @Override
    public int getOrd(int docID) {
      return (int)ordsReader.get(docID);
    }

    @Override
    public void lookupOrd(int ord, BytesRef result) {
      long startAddress = addressReader.get(ord);
      long endAddress = addressReader.get(ord+1);
      bytesReader.fillSlice(result, startAddress, (int)(endAddress - startAddress));
    }

    @Override
    public int getValueCount() {
      return valueCount;
    }
  });
}
项目:read-open-source-code    文件:BinaryDocValuesWriter.java   
public BinaryDocValuesWriter(FieldInfo fieldInfo, Counter iwBytesUsed) {
  this.fieldInfo = fieldInfo;
  this.bytes = new PagedBytes(BLOCK_BITS);
  this.bytesOut = bytes.getDataOutput();
  this.lengths = new AppendingDeltaPackedLongBuffer(PackedInts.COMPACT);
  this.iwBytesUsed = iwBytesUsed;
  this.docsWithField = new FixedBitSet(64);
  this.bytesUsed = docsWithFieldBytesUsed();
  iwBytesUsed.addAndGet(bytesUsed);
}
项目:read-open-source-code    文件:Lucene40DocValuesReader.java   
private BinaryDocValues loadBytesFixedStraight(FieldInfo field) throws IOException {
  String fileName = IndexFileNames.segmentFileName(state.segmentInfo.name + "_" + Integer.toString(field.number), segmentSuffix, "dat");
  IndexInput input = dir.openInput(fileName, state.context);
  boolean success = false;
  try {
    CodecUtil.checkHeader(input, Lucene40DocValuesFormat.BYTES_FIXED_STRAIGHT_CODEC_NAME,
                                 Lucene40DocValuesFormat.BYTES_FIXED_STRAIGHT_VERSION_START,
                                 Lucene40DocValuesFormat.BYTES_FIXED_STRAIGHT_VERSION_CURRENT);
    final int fixedLength = input.readInt();
    PagedBytes bytes = new PagedBytes(16);
    bytes.copy(input, fixedLength * (long)state.segmentInfo.getDocCount());
    final PagedBytes.Reader bytesReader = bytes.freeze(true);
    if (input.getFilePointer() != input.length()) {
      throw new CorruptIndexException("did not read all bytes from file \"" + fileName + "\": read " + input.getFilePointer() + " vs size " + input.length() + " (resource: " + input + ")");
    }
    success = true;
    ramBytesUsed.addAndGet(bytes.ramBytesUsed());
    return new BinaryDocValues() {
      @Override
      public void get(int docID, BytesRef result) {
        bytesReader.fillSlice(result, fixedLength * (long)docID, fixedLength);
      }
    };
  } finally {
    if (success) {
      IOUtils.close(input);
    } else {
      IOUtils.closeWhileHandlingException(input);
    }
  }
}
项目:read-open-source-code    文件:Lucene40DocValuesReader.java   
private SortedDocValues loadBytesFixedSorted(FieldInfo field, IndexInput data, IndexInput index) throws IOException {
  CodecUtil.checkHeader(data, Lucene40DocValuesFormat.BYTES_FIXED_SORTED_CODEC_NAME_DAT,
                              Lucene40DocValuesFormat.BYTES_FIXED_SORTED_VERSION_START,
                              Lucene40DocValuesFormat.BYTES_FIXED_SORTED_VERSION_CURRENT);
  CodecUtil.checkHeader(index, Lucene40DocValuesFormat.BYTES_FIXED_SORTED_CODEC_NAME_IDX,
                               Lucene40DocValuesFormat.BYTES_FIXED_SORTED_VERSION_START,
                               Lucene40DocValuesFormat.BYTES_FIXED_SORTED_VERSION_CURRENT);

  final int fixedLength = data.readInt();
  final int valueCount = index.readInt();

  PagedBytes bytes = new PagedBytes(16);
  bytes.copy(data, fixedLength * (long) valueCount);
  final PagedBytes.Reader bytesReader = bytes.freeze(true);
  final PackedInts.Reader reader = PackedInts.getReader(index);
  ramBytesUsed.addAndGet(bytes.ramBytesUsed() + reader.ramBytesUsed());

  return correctBuggyOrds(new SortedDocValues() {
    @Override
    public int getOrd(int docID) {
      return (int) reader.get(docID);
    }

    @Override
    public void lookupOrd(int ord, BytesRef result) {
      bytesReader.fillSlice(result, fixedLength * (long) ord, fixedLength);
    }

    @Override
    public int getValueCount() {
      return valueCount;
    }
  });
}
项目:read-open-source-code    文件:Lucene40DocValuesReader.java   
private SortedDocValues loadBytesVarSorted(FieldInfo field, IndexInput data, IndexInput index) throws IOException {
  CodecUtil.checkHeader(data, Lucene40DocValuesFormat.BYTES_VAR_SORTED_CODEC_NAME_DAT,
                              Lucene40DocValuesFormat.BYTES_VAR_SORTED_VERSION_START,
                              Lucene40DocValuesFormat.BYTES_VAR_SORTED_VERSION_CURRENT);
  CodecUtil.checkHeader(index, Lucene40DocValuesFormat.BYTES_VAR_SORTED_CODEC_NAME_IDX,
                               Lucene40DocValuesFormat.BYTES_VAR_SORTED_VERSION_START,
                               Lucene40DocValuesFormat.BYTES_VAR_SORTED_VERSION_CURRENT);

  long maxAddress = index.readLong();
  PagedBytes bytes = new PagedBytes(16);
  bytes.copy(data, maxAddress);
  final PagedBytes.Reader bytesReader = bytes.freeze(true);
  final PackedInts.Reader addressReader = PackedInts.getReader(index);
  final PackedInts.Reader ordsReader = PackedInts.getReader(index);

  final int valueCount = addressReader.size() - 1;
  ramBytesUsed.addAndGet(bytes.ramBytesUsed() + addressReader.ramBytesUsed() + ordsReader.ramBytesUsed());

  return correctBuggyOrds(new SortedDocValues() {
    @Override
    public int getOrd(int docID) {
      return (int)ordsReader.get(docID);
    }

    @Override
    public void lookupOrd(int ord, BytesRef result) {
      long startAddress = addressReader.get(ord);
      long endAddress = addressReader.get(ord+1);
      bytesReader.fillSlice(result, startAddress, (int)(endAddress - startAddress));
    }

    @Override
    public int getValueCount() {
      return valueCount;
    }
  });
}
项目:read-open-source-code    文件:BinaryDocValuesWriter.java   
public BinaryDocValuesWriter(FieldInfo fieldInfo, Counter iwBytesUsed) {
  this.fieldInfo = fieldInfo;
  this.bytes = new PagedBytes(BLOCK_BITS);
  this.bytesOut = bytes.getDataOutput();
  this.lengths = new AppendingDeltaPackedLongBuffer(PackedInts.COMPACT);
  this.iwBytesUsed = iwBytesUsed;
  this.docsWithField = new FixedBitSet(64);
  this.bytesUsed = docsWithFieldBytesUsed();
  iwBytesUsed.addAndGet(bytesUsed);
}
项目:read-open-source-code    文件:Lucene40DocValuesReader.java   
private BinaryDocValues loadBytesFixedStraight(FieldInfo field) throws IOException {
  String fileName = IndexFileNames.segmentFileName(state.segmentInfo.name + "_" + Integer.toString(field.number), segmentSuffix, "dat");
  IndexInput input = dir.openInput(fileName, state.context);
  boolean success = false;
  try {
    CodecUtil.checkHeader(input, Lucene40DocValuesFormat.BYTES_FIXED_STRAIGHT_CODEC_NAME,
                                 Lucene40DocValuesFormat.BYTES_FIXED_STRAIGHT_VERSION_START,
                                 Lucene40DocValuesFormat.BYTES_FIXED_STRAIGHT_VERSION_CURRENT);
    final int fixedLength = input.readInt();
    PagedBytes bytes = new PagedBytes(16);
    bytes.copy(input, fixedLength * (long)state.segmentInfo.getDocCount());
    final PagedBytes.Reader bytesReader = bytes.freeze(true);
    CodecUtil.checkEOF(input);
    success = true;
    ramBytesUsed.addAndGet(bytesReader.ramBytesUsed());
    return new BinaryDocValues() {

      @Override
      public BytesRef get(int docID) {
        final BytesRef term = new BytesRef();
        bytesReader.fillSlice(term, fixedLength * (long)docID, fixedLength);
        return term;
      }
    };
  } finally {
    if (success) {
      IOUtils.close(input);
    } else {
      IOUtils.closeWhileHandlingException(input);
    }
  }
}
项目:read-open-source-code    文件:Lucene40DocValuesReader.java   
private SortedDocValues loadBytesFixedSorted(FieldInfo field, IndexInput data, IndexInput index) throws IOException {
  CodecUtil.checkHeader(data, Lucene40DocValuesFormat.BYTES_FIXED_SORTED_CODEC_NAME_DAT,
                              Lucene40DocValuesFormat.BYTES_FIXED_SORTED_VERSION_START,
                              Lucene40DocValuesFormat.BYTES_FIXED_SORTED_VERSION_CURRENT);
  CodecUtil.checkHeader(index, Lucene40DocValuesFormat.BYTES_FIXED_SORTED_CODEC_NAME_IDX,
                               Lucene40DocValuesFormat.BYTES_FIXED_SORTED_VERSION_START,
                               Lucene40DocValuesFormat.BYTES_FIXED_SORTED_VERSION_CURRENT);

  final int fixedLength = data.readInt();
  final int valueCount = index.readInt();

  PagedBytes bytes = new PagedBytes(16);
  bytes.copy(data, fixedLength * (long) valueCount);
  final PagedBytes.Reader bytesReader = bytes.freeze(true);
  final PackedInts.Reader reader = PackedInts.getReader(index);
  ramBytesUsed.addAndGet(bytesReader.ramBytesUsed() + reader.ramBytesUsed());

  return correctBuggyOrds(new SortedDocValues() {
    @Override
    public int getOrd(int docID) {
      return (int) reader.get(docID);
    }

    @Override
    public BytesRef lookupOrd(int ord) {
      final BytesRef term = new BytesRef();
      bytesReader.fillSlice(term, fixedLength * (long) ord, fixedLength);
      return term;
    }

    @Override
    public int getValueCount() {
      return valueCount;
    }
  });
}
项目:read-open-source-code    文件:Lucene40DocValuesReader.java   
private SortedDocValues loadBytesVarSorted(FieldInfo field, IndexInput data, IndexInput index) throws IOException {
  CodecUtil.checkHeader(data, Lucene40DocValuesFormat.BYTES_VAR_SORTED_CODEC_NAME_DAT,
                              Lucene40DocValuesFormat.BYTES_VAR_SORTED_VERSION_START,
                              Lucene40DocValuesFormat.BYTES_VAR_SORTED_VERSION_CURRENT);
  CodecUtil.checkHeader(index, Lucene40DocValuesFormat.BYTES_VAR_SORTED_CODEC_NAME_IDX,
                               Lucene40DocValuesFormat.BYTES_VAR_SORTED_VERSION_START,
                               Lucene40DocValuesFormat.BYTES_VAR_SORTED_VERSION_CURRENT);

  long maxAddress = index.readLong();
  PagedBytes bytes = new PagedBytes(16);
  bytes.copy(data, maxAddress);
  final PagedBytes.Reader bytesReader = bytes.freeze(true);
  final PackedInts.Reader addressReader = PackedInts.getReader(index);
  final PackedInts.Reader ordsReader = PackedInts.getReader(index);

  final int valueCount = addressReader.size() - 1;
  ramBytesUsed.addAndGet(bytesReader.ramBytesUsed() + addressReader.ramBytesUsed() + ordsReader.ramBytesUsed());

  return correctBuggyOrds(new SortedDocValues() {
    @Override
    public int getOrd(int docID) {
      return (int)ordsReader.get(docID);
    }

    @Override
    public BytesRef lookupOrd(int ord) {
      final BytesRef term = new BytesRef();
      long startAddress = addressReader.get(ord);
      long endAddress = addressReader.get(ord+1);
      bytesReader.fillSlice(term, startAddress, (int)(endAddress - startAddress));
      return term;
    }

    @Override
    public int getValueCount() {
      return valueCount;
    }
  });
}
项目:read-open-source-code    文件:MemoryDocValuesProducer.java   
private BytesAndAddresses loadBinary(FieldInfo field) throws IOException {
  BytesAndAddresses bytesAndAddresses = new BytesAndAddresses();
  BinaryEntry entry = binaries.get(field.number);
  data.seek(entry.offset);
  PagedBytes bytes = new PagedBytes(16);
  bytes.copy(data, entry.numBytes);
  bytesAndAddresses.reader = bytes.freeze(true);
  ramBytesUsed.addAndGet(bytesAndAddresses.reader.ramBytesUsed());
  if (entry.minLength != entry.maxLength) {
    data.seek(data.getFilePointer() + entry.missingBytes);
    bytesAndAddresses.addresses = MonotonicBlockPackedReader.of(data, entry.packedIntsVersion, entry.blockSize, maxDoc, false);
    ramBytesUsed.addAndGet(bytesAndAddresses.addresses.ramBytesUsed());
  }
  return bytesAndAddresses;
}
项目:read-open-source-code    文件:FixedGapTermsIndexReader.java   
public FieldIndexData(FieldInfo fieldInfo, PagedBytes termBytes, int numIndexTerms, long indexStart, long termsStart, long packedIndexStart,
                      long packedOffsetsStart) throws IOException {

  this.termsStart = termsStart;
  this.indexStart = indexStart;
  this.packedIndexStart = packedIndexStart;
  this.packedOffsetsStart = packedOffsetsStart;
  this.numIndexTerms = numIndexTerms;

  if (indexDivisor > 0) {
    loadTermsIndex(termBytes);
  }
}
项目: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);
}
项目:read-open-source-code    文件:BinaryDocValuesWriter.java   
public BinaryDocValuesWriter(FieldInfo fieldInfo, Counter iwBytesUsed) {
  this.fieldInfo = fieldInfo;
  this.bytes = new PagedBytes(BLOCK_BITS);
  this.bytesOut = bytes.getDataOutput();
  this.lengths = PackedLongValues.deltaPackedBuilder(PackedInts.COMPACT);
  this.iwBytesUsed = iwBytesUsed;
  this.docsWithField = new FixedBitSet(64);
  this.bytesUsed = docsWithFieldBytesUsed();
  iwBytesUsed.addAndGet(bytesUsed);
}
项目:Maskana-Gestor-de-Conocimiento    文件:Lucene40DocValuesReader.java   
private BinaryDocValues loadBytesFixedStraight(FieldInfo field) throws IOException {
  String fileName = IndexFileNames.segmentFileName(state.segmentInfo.name + "_" + Integer.toString(field.number), segmentSuffix, "dat");
  IndexInput input = dir.openInput(fileName, state.context);
  boolean success = false;
  try {
    CodecUtil.checkHeader(input, Lucene40DocValuesFormat.BYTES_FIXED_STRAIGHT_CODEC_NAME, 
                                 Lucene40DocValuesFormat.BYTES_FIXED_STRAIGHT_VERSION_START, 
                                 Lucene40DocValuesFormat.BYTES_FIXED_STRAIGHT_VERSION_CURRENT);
    final int fixedLength = input.readInt();
    PagedBytes bytes = new PagedBytes(16);
    bytes.copy(input, fixedLength * (long)state.segmentInfo.getDocCount());
    final PagedBytes.Reader bytesReader = bytes.freeze(true);
    if (input.getFilePointer() != input.length()) {
      throw new CorruptIndexException("did not read all bytes from file \"" + fileName + "\": read " + input.getFilePointer() + " vs size " + input.length() + " (resource: " + input + ")");
    }
    success = true;
    return new BinaryDocValues() {
      @Override
      public void get(int docID, BytesRef result) {
        bytesReader.fillSlice(result, fixedLength * (long)docID, fixedLength);
      }
    };
  } finally {
    if (success) {
      IOUtils.close(input);
    } else {
      IOUtils.closeWhileHandlingException(input);
    }
  }
}
项目:Maskana-Gestor-de-Conocimiento    文件:Lucene40DocValuesReader.java   
private SortedDocValues loadBytesFixedSorted(FieldInfo field, IndexInput data, IndexInput index) throws IOException {
  CodecUtil.checkHeader(data, Lucene40DocValuesFormat.BYTES_FIXED_SORTED_CODEC_NAME_DAT, 
                              Lucene40DocValuesFormat.BYTES_FIXED_SORTED_VERSION_START, 
                              Lucene40DocValuesFormat.BYTES_FIXED_SORTED_VERSION_CURRENT);
  CodecUtil.checkHeader(index, Lucene40DocValuesFormat.BYTES_FIXED_SORTED_CODEC_NAME_IDX, 
                               Lucene40DocValuesFormat.BYTES_FIXED_SORTED_VERSION_START, 
                               Lucene40DocValuesFormat.BYTES_FIXED_SORTED_VERSION_CURRENT);

  final int fixedLength = data.readInt();
  final int valueCount = index.readInt();

  PagedBytes bytes = new PagedBytes(16);
  bytes.copy(data, fixedLength * (long) valueCount);
  final PagedBytes.Reader bytesReader = bytes.freeze(true);
  final PackedInts.Reader reader = PackedInts.getReader(index);

  return correctBuggyOrds(new SortedDocValues() {
    @Override
    public int getOrd(int docID) {
      return (int) reader.get(docID);
    }

    @Override
    public void lookupOrd(int ord, BytesRef result) {
      bytesReader.fillSlice(result, fixedLength * (long) ord, fixedLength);
    }

    @Override
    public int getValueCount() {
      return valueCount;
    }
  });
}
项目:Maskana-Gestor-de-Conocimiento    文件:Lucene40DocValuesReader.java   
private SortedDocValues loadBytesVarSorted(FieldInfo field, IndexInput data, IndexInput index) throws IOException {
  CodecUtil.checkHeader(data, Lucene40DocValuesFormat.BYTES_VAR_SORTED_CODEC_NAME_DAT, 
                              Lucene40DocValuesFormat.BYTES_VAR_SORTED_VERSION_START, 
                              Lucene40DocValuesFormat.BYTES_VAR_SORTED_VERSION_CURRENT);
  CodecUtil.checkHeader(index, Lucene40DocValuesFormat.BYTES_VAR_SORTED_CODEC_NAME_IDX, 
                               Lucene40DocValuesFormat.BYTES_VAR_SORTED_VERSION_START, 
                               Lucene40DocValuesFormat.BYTES_VAR_SORTED_VERSION_CURRENT);

  long maxAddress = index.readLong();
  PagedBytes bytes = new PagedBytes(16);
  bytes.copy(data, maxAddress);
  final PagedBytes.Reader bytesReader = bytes.freeze(true);
  final PackedInts.Reader addressReader = PackedInts.getReader(index);
  final PackedInts.Reader ordsReader = PackedInts.getReader(index);

  final int valueCount = addressReader.size() - 1;

  return correctBuggyOrds(new SortedDocValues() {
    @Override
    public int getOrd(int docID) {
      return (int)ordsReader.get(docID);
    }

    @Override
    public void lookupOrd(int ord, BytesRef result) {
      long startAddress = addressReader.get(ord);
      long endAddress = addressReader.get(ord+1);
      bytesReader.fillSlice(result, startAddress, (int)(endAddress - startAddress));
    }

    @Override
    public int getValueCount() {
      return valueCount;
    }
  });
}
项目:Maskana-Gestor-de-Conocimiento    文件:BinaryDocValuesWriter.java   
public BinaryDocValuesWriter(FieldInfo fieldInfo, Counter iwBytesUsed) {
  this.fieldInfo = fieldInfo;
  this.bytes = new PagedBytes(BLOCK_BITS);
  this.bytesOut = bytes.getDataOutput();
  this.lengths = new AppendingDeltaPackedLongBuffer(PackedInts.COMPACT);
  this.iwBytesUsed = iwBytesUsed;
  this.docsWithField = new OpenBitSet();
  this.bytesUsed = docsWithFieldBytesUsed();
  iwBytesUsed.addAndGet(bytesUsed);
}
项目:elasticsearch_my    文件:PagedBytesAtomicFieldData.java   
public PagedBytesAtomicFieldData(PagedBytes.Reader bytes, PackedLongValues termOrdToBytesOffset, Ordinals ordinals) {
    super(DEFAULT_SCRIPT_FUNCTION);
    this.bytes = bytes;
    this.termOrdToBytesOffset = termOrdToBytesOffset;
    this.ordinals = ordinals;
}
项目:elasticsearch_my    文件:PagedBytesAtomicFieldData.java   
ValuesHolder(PagedBytes.Reader bytes, PackedLongValues termOrdToBytesOffset) {
    this.bytes = bytes;
    this.termOrdToBytesOffset = termOrdToBytesOffset;
}
项目:lams    文件:Lucene40DocValuesReader.java   
private BinaryDocValues loadBytesVarStraight(FieldInfo field) throws IOException {
  String dataName = IndexFileNames.segmentFileName(state.segmentInfo.name + "_" + Integer.toString(field.number), segmentSuffix, "dat");
  String indexName = IndexFileNames.segmentFileName(state.segmentInfo.name + "_" + Integer.toString(field.number), segmentSuffix, "idx");
  IndexInput data = null;
  IndexInput index = null;
  boolean success = false;
  try {
    data = dir.openInput(dataName, state.context);
    CodecUtil.checkHeader(data, Lucene40DocValuesFormat.BYTES_VAR_STRAIGHT_CODEC_NAME_DAT,
                                Lucene40DocValuesFormat.BYTES_VAR_STRAIGHT_VERSION_START,
                                Lucene40DocValuesFormat.BYTES_VAR_STRAIGHT_VERSION_CURRENT);
    index = dir.openInput(indexName, state.context);
    CodecUtil.checkHeader(index, Lucene40DocValuesFormat.BYTES_VAR_STRAIGHT_CODEC_NAME_IDX,
                                 Lucene40DocValuesFormat.BYTES_VAR_STRAIGHT_VERSION_START,
                                 Lucene40DocValuesFormat.BYTES_VAR_STRAIGHT_VERSION_CURRENT);
    long totalBytes = index.readVLong();
    PagedBytes bytes = new PagedBytes(16);
    bytes.copy(data, totalBytes);
    final PagedBytes.Reader bytesReader = bytes.freeze(true);
    final PackedInts.Reader reader = PackedInts.getReader(index);
    CodecUtil.checkEOF(data);
    CodecUtil.checkEOF(index);
    success = true;
    ramBytesUsed.addAndGet(bytesReader.ramBytesUsed() + reader.ramBytesUsed());
    return new BinaryDocValues() {
      @Override
      public BytesRef get(int docID) {
        final BytesRef term = new BytesRef();
        long startAddress = reader.get(docID);
        long endAddress = reader.get(docID+1);
        bytesReader.fillSlice(term, startAddress, (int)(endAddress - startAddress));
        return term;
      }
    };
  } finally {
    if (success) {
      IOUtils.close(data, index);
    } else {
      IOUtils.closeWhileHandlingException(data, index);
    }
  }
}