예제 #1
0
    /**
     * Populates an entity from a row.
     *
     * @param entity Entity object to populate from a row.
     * @param row Kiji row to populate the entity from.
     * @return the populated entity.
     * @throws IllegalAccessException
     * @throws IOException
     */
    public T populateEntityFromRow(T entity, KijiRowData row)
        throws IllegalAccessException, IOException {

      // Populate fields from the row columns:
      for (final Field field : mColumnFields) {
        final KijiColumn column = field.getAnnotation(KijiColumn.class);
        Preconditions.checkState(column != null);

        if (column.qualifier().isEmpty()) {
          // Field is populated from a map-type family:
          populateFieldFromMapTypeFamily(entity, field, column, row);

        } else {
          // Field is populated from a fully-qualified column:
          populateFieldFromFullyQualifiedColumn(entity, field, column, row);
        }
      }

      // Populate fields from the row entity ID:
      for (final Field field : mEntityIdFields) {
        final EntityIdField eidField = field.getAnnotation(EntityIdField.class);
        Preconditions.checkState(eidField != null);

        final int index = mRowKeyComponentIndexMap.get(eidField.component());
        field.set(entity, row.getEntityId().getComponentByIndex(index));
      }
      return entity;
    }
 /**
  * Populates the specified key and value with the next key-value pair read from the input split.
  *
  * @param key instance to populate with the next key read.
  * @param value instance to popualte with the next value read.
  * @return <code>true</code> if a new key-value was read, <code>false</code> if we have reached
  *     the end of the input split.
  */
 @Override
 public boolean next(KijiKey key, KijiValue value) {
   if (mIterator.hasNext()) {
     // Read the next row and store it in the provided key/value pair.
     final KijiRowData row = mIterator.next();
     if (null != key) {
       key.set(row.getEntityId());
     }
     if (null != value) {
       value.set(row);
     }
     return true;
   } else {
     return false;
   }
 }
예제 #3
0
 /** {@inheritDoc} */
 @Override
 protected void map(KijiRowData input, Context mapContext) throws IOException {
   mProducerContext.setEntityId(input.getEntityId());
   mProducer.produce(input, mProducerContext);
   mapContext.getCounter(JobHistoryCounters.PRODUCER_ROWS_PROCESSED).increment(1);
 }