Ejemplo n.º 1
0
 protected void addFields(Row row, List<IndexedField> fields) throws IOException {
   if (fields == null) return;
   for (IndexedField indexedField : fields) {
     ValueSource value = row.value(indexedField.getPosition());
     Field field = indexedField.getField(value);
     currentDocument.add(field);
   }
 }
Ejemplo n.º 2
0
 public void indexRow(Row row) throws IOException {
   if (row == null) {
     addDocument();
     return;
   }
   RowType rowType = row.rowType();
   Integer ancestorDepth = ancestorRowTypes.get(rowType);
   if (ancestorDepth != null) {
     ancestors[ancestorDepth] = row;
     if (ancestorDepth == ancestors.length - 1) {
       addDocument();
       currentDocument = new Document();
       getKeyBytes(row);
       addFields(row, fieldsByRowType.get(rowType));
       for (int i = 0; i < ancestors.length - 1; i++) {
         Row ancestor = ancestors[i];
         if (ancestor != null) {
           // We may have remembered an ancestor with no
           // children and then this row is an orphan.
           if (ancestor.ancestorOf(row)) {
             addFields(ancestor, fieldsByRowType.get(ancestor.rowType()));
           } else {
             ancestors[i] = null;
           }
         }
       }
     }
   } else if (descendantRowTypes.contains(rowType)) {
     Row ancestor = ancestors[ancestors.length - 1];
     if ((ancestor != null) && ancestor.ancestorOf(row)) {
       addFields(row, fieldsByRowType.get(rowType));
     }
   }
 }
Ejemplo n.º 3
0
 protected void getKeyBytes(Row row) {
   Key key = ((PersistitHKey) row.hKey()).key();
   keyEncodedString = encodeBytes(key.getEncodedBytes(), 0, key.getEncodedSize());
   Field field = new StringField(IndexedField.KEY_FIELD, keyEncodedString, Store.YES);
   currentDocument.add(field);
 }