alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Lucene example source code file (InstantiatedTermDocumentInformation.java)

This example Lucene source code file (InstantiatedTermDocumentInformation.java) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Lucene tags/keywords

comparator, comparator, instantiateddocument, instantiateddocument, instantiatedterm, instantiatedtermdocumentinformation, instantiatedtermdocumentinformation, integer, integer, io, object, serializable, termvectoroffsetinfo, util

The Lucene InstantiatedTermDocumentInformation.java source code

package org.apache.lucene.store.instantiated;

import org.apache.lucene.index.TermVectorOffsetInfo;

import java.io.Serializable;
import java.util.Comparator;

/**
 * Copyright 2006 The Apache Software Foundation
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/**
 * There is one instance of this class per indexed term in a document
 * and it contains the meta data about each occurrence of a term in a document.
 *
 * It is the inner glue of the inverted index.
 *
 * <pre>
 * [Term]-- {0..*} | {0..*} --(field)[Document]
 *            <<ordered>>
 *                 |
 *    [TermDocumentInformation]
 *       +payloads
 *       +termPositions
 *       +termOffsets
 * </pre>
 * 
 */
public class InstantiatedTermDocumentInformation
    implements Serializable {

  private static final long serialVersionUID = 1l;

  public static final Comparator<InstantiatedTermDocumentInformation> termComparator = new Comparator() {
    public int compare(InstantiatedTermDocumentInformation instantiatedTermDocumentInformation, InstantiatedTermDocumentInformation instantiatedTermDocumentInformation1) {
      return instantiatedTermDocumentInformation.getTerm().getTerm().compareTo(instantiatedTermDocumentInformation1.getTerm().getTerm());
    }
  };

  public static final Comparator<InstantiatedTermDocumentInformation> documentNumberComparator = new Comparator() {
    public int compare(InstantiatedTermDocumentInformation instantiatedTermDocumentInformation, InstantiatedTermDocumentInformation instantiatedTermDocumentInformation1) {
      return instantiatedTermDocumentInformation.getDocument().getDocumentNumber().compareTo(instantiatedTermDocumentInformation1.getDocument().getDocumentNumber());
    }
  };

  public static final Comparator doumentNumberIntegerComparator = new Comparator() {
    public int compare(Object o1, Object o2) {
      InstantiatedTermDocumentInformation di = (InstantiatedTermDocumentInformation) o1;
      Integer i = (Integer) o2;
      return di.getDocument().getDocumentNumber().compareTo(i);
    }
  };


  private byte[][] payloads;
  private int[] termPositions;
  private InstantiatedTerm term;
  private InstantiatedDocument document;
  private TermVectorOffsetInfo[] termOffsets;



  public InstantiatedTermDocumentInformation(InstantiatedTerm term, InstantiatedDocument document, int[] termPositions, byte[][] payloads) {
    this.term = term;
    this.document = document;
    this.termPositions = termPositions;
    this.payloads = payloads;
  }


// not quite sure why I wanted this.
//  /**
//   * [Term]--- {0..* ordered} ->[Info]
//   */
//  private int indexFromTerm;


//  public int getIndexFromTerm() {
//    return indexFromTerm;
//  }
//
//  void setIndexFromTerm(int indexFromTerm) {
//    this.indexFromTerm = indexFromTerm;
//  }


  public int[] getTermPositions() {
    return termPositions;
  }


  public byte[][] getPayloads() {
    return payloads;
  }

  public InstantiatedDocument getDocument() {
    return document;
  }



  public InstantiatedTerm getTerm() {
    return term;
  }


  void setTermPositions(int[] termPositions) {
    this.termPositions = termPositions;
  }


  void setTerm(InstantiatedTerm term) {
    this.term = term;
  }

  void setDocument(InstantiatedDocument document) {
    this.document = document;
  }

  public TermVectorOffsetInfo[] getTermOffsets() {
    return termOffsets;
  }

  void setTermOffsets(TermVectorOffsetInfo[] termOffsets) {
    this.termOffsets = termOffsets;
  }
}

Other Lucene examples (source code examples)

Here is a short list of links related to this Lucene InstantiatedTermDocumentInformation.java source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.