Java 类org.apache.lucene.index.DocValuesUpdate.NumericDocValuesUpdate 实例源码

项目:lams    文件:DocumentsWriterDeleteQueue.java   
@Override
void apply(BufferedUpdates bufferedUpdates, int docIDUpto) {
  for (DocValuesUpdate update : item) {
    switch (update.type) {
      case NUMERIC:
        bufferedUpdates.addNumericUpdate(new NumericDocValuesUpdate(update.term, update.field, (Long) update.value), docIDUpto);
        break;
      case BINARY:
        bufferedUpdates.addBinaryUpdate(new BinaryDocValuesUpdate(update.term, update.field, (BytesRef) update.value), docIDUpto);
        break;
      default:
        throw new IllegalArgumentException(update.type + " DocValues updates not supported yet!");
    }
  }
}
项目:lams    文件:BufferedUpdates.java   
public void addNumericUpdate(NumericDocValuesUpdate update, int docIDUpto) {
  LinkedHashMap<Term,NumericDocValuesUpdate> fieldUpdates = numericUpdates.get(update.field);
  if (fieldUpdates == null) {
    fieldUpdates = new LinkedHashMap<>();
    numericUpdates.put(update.field, fieldUpdates);
    bytesUsed.addAndGet(BYTES_PER_NUMERIC_FIELD_ENTRY);
  }
  final NumericDocValuesUpdate current = fieldUpdates.get(update.term);
  if (current != null && docIDUpto < current.docIDUpto) {
    // Only record the new number if it's greater than or equal to the current
    // one. This is important because if multiple threads are replacing the
    // same doc at nearly the same time, it's possible that one thread that
    // got a higher docID is scheduled before the other threads.
    return;
  }

  update.docIDUpto = docIDUpto;
  // since it's a LinkedHashMap, we must first remove the Term entry so that
  // it's added last (we're interested in insertion-order).
  if (current != null) {
    fieldUpdates.remove(update.term);
  }
  fieldUpdates.put(update.term, update);
  numNumericUpdates.incrementAndGet();
  if (current == null) {
    bytesUsed.addAndGet(BYTES_PER_NUMERIC_UPDATE_ENTRY + update.sizeInBytes());
  }
}
项目:lams    文件:IndexWriter.java   
/**
 * Updates documents' DocValues fields to the given values. Each field update
 * is applied to the set of documents that are associated with the
 * {@link Term} to the same value. All updates are atomically applied and
 * flushed together.
 * 
 * @param updates
 *          the updates to apply
 * @throws CorruptIndexException
 *           if the index is corrupt
 * @throws IOException
 *           if there is a low-level IO error
 */
public void updateDocValues(Term term, Field... updates) throws IOException {
  ensureOpen();
  DocValuesUpdate[] dvUpdates = new DocValuesUpdate[updates.length];
  for (int i = 0; i < updates.length; i++) {
    final Field f = updates[i];
    final DocValuesType dvType = f.fieldType().docValueType();
    if (dvType == null) {
      throw new IllegalArgumentException("can only update NUMERIC or BINARY fields! field=" + f.name());
    }
    if (!globalFieldNumberMap.contains(f.name(), dvType)) {
      throw new IllegalArgumentException("can only update existing docvalues fields! field=" + f.name() + ", type=" + dvType);
    }
    switch (dvType) {
      case NUMERIC:
        dvUpdates[i] = new NumericDocValuesUpdate(term, f.name(), (Long) f.numericValue());
        break;
      case BINARY:
        dvUpdates[i] = new BinaryDocValuesUpdate(term, f.name(), f.binaryValue());
        break;
      default:
        throw new IllegalArgumentException("can only update NUMERIC or BINARY fields: field=" + f.name() + ", type=" + dvType);
    }
  }
  try {
    if (docWriter.updateDocValues(dvUpdates)) {
      processEvents(true, false);
    }
  } catch (OutOfMemoryError oom) {
    tragicEvent(oom, "updateDocValues");
  }
}
项目:search    文件:DocumentsWriterDeleteQueue.java   
@Override
void apply(BufferedUpdates bufferedUpdates, int docIDUpto) {
  for (DocValuesUpdate update : item) {
    switch (update.type) {
      case NUMERIC:
        bufferedUpdates.addNumericUpdate(new NumericDocValuesUpdate(update.term, update.field, (Long) update.value), docIDUpto);
        break;
      case BINARY:
        bufferedUpdates.addBinaryUpdate(new BinaryDocValuesUpdate(update.term, update.field, (BytesRef) update.value), docIDUpto);
        break;
      default:
        throw new IllegalArgumentException(update.type + " DocValues updates not supported yet!");
    }
  }
}
项目:search    文件:BufferedUpdates.java   
public void addNumericUpdate(NumericDocValuesUpdate update, int docIDUpto) {
  LinkedHashMap<Term,NumericDocValuesUpdate> fieldUpdates = numericUpdates.get(update.field);
  if (fieldUpdates == null) {
    fieldUpdates = new LinkedHashMap<>();
    numericUpdates.put(update.field, fieldUpdates);
    bytesUsed.addAndGet(BYTES_PER_NUMERIC_FIELD_ENTRY);
  }
  final NumericDocValuesUpdate current = fieldUpdates.get(update.term);
  if (current != null && docIDUpto < current.docIDUpto) {
    // Only record the new number if it's greater than or equal to the current
    // one. This is important because if multiple threads are replacing the
    // same doc at nearly the same time, it's possible that one thread that
    // got a higher docID is scheduled before the other threads.
    return;
  }

  update.docIDUpto = docIDUpto;
  // since it's a LinkedHashMap, we must first remove the Term entry so that
  // it's added last (we're interested in insertion-order).
  if (current != null) {
    fieldUpdates.remove(update.term);
  }
  fieldUpdates.put(update.term, update);
  numNumericUpdates.incrementAndGet();
  if (current == null) {
    bytesUsed.addAndGet(BYTES_PER_NUMERIC_UPDATE_ENTRY + update.sizeInBytes());
  }
}
项目:search    文件:IndexWriter.java   
/**
 * Updates documents' DocValues fields to the given values. Each field update
 * is applied to the set of documents that are associated with the
 * {@link Term} to the same value. All updates are atomically applied and
 * flushed together.
 * 
 * @param updates
 *          the updates to apply
 * @throws CorruptIndexException
 *           if the index is corrupt
 * @throws IOException
 *           if there is a low-level IO error
 */
public void updateDocValues(Term term, Field... updates) throws IOException {
  ensureOpen();
  DocValuesUpdate[] dvUpdates = new DocValuesUpdate[updates.length];
  for (int i = 0; i < updates.length; i++) {
    final Field f = updates[i];
    final DocValuesType dvType = f.fieldType().docValueType();
    if (dvType == null) {
      throw new IllegalArgumentException("can only update NUMERIC or BINARY fields! field=" + f.name());
    }
    if (!globalFieldNumberMap.contains(f.name(), dvType)) {
      throw new IllegalArgumentException("can only update existing docvalues fields! field=" + f.name() + ", type=" + dvType);
    }
    switch (dvType) {
      case NUMERIC:
        dvUpdates[i] = new NumericDocValuesUpdate(term, f.name(), (Long) f.numericValue());
        break;
      case BINARY:
        dvUpdates[i] = new BinaryDocValuesUpdate(term, f.name(), f.binaryValue());
        break;
      default:
        throw new IllegalArgumentException("can only update NUMERIC or BINARY fields: field=" + f.name() + ", type=" + dvType);
    }
  }
  try {
    if (docWriter.updateDocValues(dvUpdates)) {
      processEvents(true, false);
    }
  } catch (OutOfMemoryError oom) {
    tragicEvent(oom, "updateDocValues");
  }
}
项目:read-open-source-code    文件:DocumentsWriterDeleteQueue.java   
@Override
void apply(BufferedUpdates bufferedUpdates, int docIDUpto) {
  for (DocValuesUpdate update : item) {
    switch (update.type) {
      case NUMERIC:
        bufferedUpdates.addNumericUpdate(new NumericDocValuesUpdate(update.term, update.field, (Long) update.value), docIDUpto);
        break;
      case BINARY:
        bufferedUpdates.addBinaryUpdate(new BinaryDocValuesUpdate(update.term, update.field, (BytesRef) update.value), docIDUpto);
        break;
      default:
        throw new IllegalArgumentException(update.type + " DocValues updates not supported yet!");
    }
  }
}
项目:read-open-source-code    文件:BufferedUpdates.java   
public void addNumericUpdate(NumericDocValuesUpdate update, int docIDUpto) {
  LinkedHashMap<Term,NumericDocValuesUpdate> fieldUpdates = numericUpdates.get(update.field);
  if (fieldUpdates == null) {
    fieldUpdates = new LinkedHashMap<>();
    numericUpdates.put(update.field, fieldUpdates);
    bytesUsed.addAndGet(BYTES_PER_NUMERIC_FIELD_ENTRY);
  }
  final NumericDocValuesUpdate current = fieldUpdates.get(update.term);
  if (current != null && docIDUpto < current.docIDUpto) {
    // Only record the new number if it's greater than or equal to the current
    // one. This is important because if multiple threads are replacing the
    // same doc at nearly the same time, it's possible that one thread that
    // got a higher docID is scheduled before the other threads.
    return;
  }

  update.docIDUpto = docIDUpto;
  // since it's a LinkedHashMap, we must first remove the Term entry so that
  // it's added last (we're interested in insertion-order).
  if (current != null) {
    fieldUpdates.remove(update.term);
  }
  fieldUpdates.put(update.term, update);
  numNumericUpdates.incrementAndGet();
  if (current == null) {
    bytesUsed.addAndGet(BYTES_PER_NUMERIC_UPDATE_ENTRY + update.sizeInBytes());
  }
}
项目:read-open-source-code    文件:IndexWriter.java   
/**
 * Updates documents' DocValues fields to the given values. Each field update
 * is applied to the set of documents that are associated with the
 * {@link Term} to the same value. All updates are atomically applied and
 * flushed together.
 * 
 * @param updates
 *          the updates to apply
 * @throws CorruptIndexException
 *           if the index is corrupt
 * @throws IOException
 *           if there is a low-level IO error
 */
public void updateDocValues(Term term, Field... updates) throws IOException {
  ensureOpen();
  DocValuesUpdate[] dvUpdates = new DocValuesUpdate[updates.length];
  for (int i = 0; i < updates.length; i++) {
    final Field f = updates[i];
    final DocValuesType dvType = f.fieldType().docValueType();
    if (dvType == null) {
      throw new IllegalArgumentException("can only update NUMERIC or BINARY fields! field=" + f.name());
    }
    if (!globalFieldNumberMap.contains(f.name(), dvType)) {
      throw new IllegalArgumentException("can only update existing docvalues fields! field=" + f.name() + ", type=" + dvType);
    }
    switch (dvType) {
      case NUMERIC:
        dvUpdates[i] = new NumericDocValuesUpdate(term, f.name(), (Long) f.numericValue());
        break;
      case BINARY:
        dvUpdates[i] = new BinaryDocValuesUpdate(term, f.name(), f.binaryValue());
        break;
      default:
        throw new IllegalArgumentException("can only update NUMERIC or BINARY fields: field=" + f.name() + ", type=" + dvType);
    }
  }
  try {
    if (docWriter.updateDocValues(dvUpdates)) {
      processEvents(true, false);
    }
  } catch (OutOfMemoryError oom) {
    tragicEvent(oom, "updateDocValues");
  }
}
项目:lams    文件:IndexWriter.java   
/**
 * Updates a document's {@link NumericDocValues} for <code>field</code> to the
 * given <code>value</code>. You can only update fields that already exist in
 * the index, not add new fields through this method.
 * 
 * @param term
 *          the term to identify the document(s) to be updated
 * @param field
 *          field name of the {@link NumericDocValues} field
 * @param value
 *          new value for the field
 * @throws CorruptIndexException
 *           if the index is corrupt
 * @throws IOException
 *           if there is a low-level IO error
 */
public void updateNumericDocValue(Term term, String field, long value) throws IOException {
  ensureOpen();
  if (!globalFieldNumberMap.contains(field, DocValuesType.NUMERIC)) {
    throw new IllegalArgumentException("can only update existing numeric-docvalues fields!");
  }
  try {
    if (docWriter.updateDocValues(new NumericDocValuesUpdate(term, field, value))) {
      processEvents(true, false);
    }
  } catch (OutOfMemoryError oom) {
    tragicEvent(oom, "updateNumericDocValue");
  }
}
项目:search    文件:IndexWriter.java   
/**
 * Updates a document's {@link NumericDocValues} for <code>field</code> to the
 * given <code>value</code>. You can only update fields that already exist in
 * the index, not add new fields through this method.
 * 
 * @param term
 *          the term to identify the document(s) to be updated
 * @param field
 *          field name of the {@link NumericDocValues} field
 * @param value
 *          new value for the field
 * @throws CorruptIndexException
 *           if the index is corrupt
 * @throws IOException
 *           if there is a low-level IO error
 */
public void updateNumericDocValue(Term term, String field, long value) throws IOException {
  ensureOpen();
  if (!globalFieldNumberMap.contains(field, DocValuesType.NUMERIC)) {
    throw new IllegalArgumentException("can only update existing numeric-docvalues fields!");
  }
  try {
    if (docWriter.updateDocValues(new NumericDocValuesUpdate(term, field, value))) {
      processEvents(true, false);
    }
  } catch (OutOfMemoryError oom) {
    tragicEvent(oom, "updateNumericDocValue");
  }
}
项目:read-open-source-code    文件:IndexWriter.java   
/**
 * Updates a document's {@link NumericDocValues} for <code>field</code> to the
 * given <code>value</code>. You can only update fields that already exist in
 * the index, not add new fields through this method.
 * 
 * @param term
 *          the term to identify the document(s) to be updated
 * @param field
 *          field name of the {@link NumericDocValues} field
 * @param value
 *          new value for the field
 * @throws CorruptIndexException
 *           if the index is corrupt
 * @throws IOException
 *           if there is a low-level IO error
 */
public void updateNumericDocValue(Term term, String field, long value) throws IOException {
  ensureOpen();
  if (!globalFieldNumberMap.contains(field, DocValuesType.NUMERIC)) {
    throw new IllegalArgumentException("can only update existing numeric-docvalues fields!");
  }
  try {
    if (docWriter.updateDocValues(new NumericDocValuesUpdate(term, field, value))) {
      processEvents(true, false);
    }
  } catch (OutOfMemoryError oom) {
    tragicEvent(oom, "updateNumericDocValue");
  }
}