/** {@inheritDoc} */ @Override public <T> void put(long timestamp, T value) throws IOException { Preconditions.checkNotNull(mEntityId); Preconditions.checkNotNull(mQualifier, "Producer output configured for a map-type family, use put(qualifier, timestamp, value)"); mTableContext.put(mEntityId, mFamily, mQualifier, timestamp, value); }
/** {@inheritDoc} */ @Override public <T> void put(String qualifier, long timestamp, T value) throws IOException { Preconditions.checkNotNull(mEntityId); Preconditions.checkState(null == mQualifier, "Qualifier already specified by producer configuration."); mTableContext.put(mEntityId, mFamily, qualifier, timestamp, value); }
/** * Reads a single news article, and writes its contents to a new fiji row, * indexed by the article's name (A string consisting of the parent folder, and * this article's hash), and the a priori categorization of this article. * * @param key The fully qualified path to the current file we're reading. * @param value The raw data to insert into this column. * @param context The context to write to. * @throws IOException if there is an error. */ @Override public void produce(Text key, Text value, FijiTableContext context) throws IOException { Path qualifiedPath = new Path(key.toString()); // Category is specified on the containing folder. String category = qualifiedPath.getParent().getName(); // Name is the concatenation of category and file name. String name = category + "." + qualifiedPath.getName(); // write name, category, and raw article. EntityId entity = context.getEntityId(name); context.put(entity, FAMILY, ARTICLE_NAME_QUALIFIER, name); context.put(entity, FAMILY, CATEGORY_QUALIFIER, category); context.put(entity, FAMILY, RAW_ARTICLE_QUALIFIER, value.toString()); } }
context.put(user, Fields.INFO_FAMILY, Fields.FIRST_NAME, firstName); context.put(user, Fields.INFO_FAMILY, Fields.LAST_NAME, lastName); context.put(user, Fields.INFO_FAMILY, Fields.EMAIL, email); context.put(user, Fields.INFO_FAMILY, Fields.TELEPHONE, telephone); context.put(user, Fields.INFO_FAMILY, Fields.ADDRESS, streetAddr);
String family = fijiColumnName.getFamily(); String qualifier = fijiColumnName.getQualifier(); context.put(eid, family, qualifier, timestamp, convert(fijiColumnName, fieldValue)); } else { incomplete(xmlText, context, "Detected missing field: " + source);
/** {@inheritDoc} */ @Override public void produce(Text value, FijiTableContext context) throws IOException { Map<Field, String> fieldMap; try { fieldMap = CommonLogParser.get().parseCommonLog(value.toString()); } catch (ParseException pe) { reject(value, context, "Unable to parse row: " + value.toString()); return; } Field entityIdSource = Field.valueOf(getEntityIdSource()); EntityId eid = context.getEntityId(fieldMap.get(entityIdSource)); for (FijiColumnName fijiColumnName : getDestinationColumns()) { Field source = Field.valueOf(getSource(fijiColumnName)); String fieldValue = fieldMap.get(source); if (fieldValue != null) { // TODO(FIJIMRLIB-12) Add some ability to use timestamps derived from the log file. context.put(eid, fijiColumnName.getFamily(), fijiColumnName.getQualifier(), fieldValue); } else { reject(value, context, "Log file missing field: " + source); } } } }
/** {@inheritDoc} */ @Override public void produce(ImmutableBytesWritable hbaseRowKey, Result hbaseRow, FijiTableContext context) throws IOException { EntityId entity = context.getEntityId(Bytes.toString(hbaseRowKey.get())); for (ColumnDescriptor columnDescriptor : mColumnDescriptors) { KeyValue keyValue = hbaseRow.getColumnLatest(columnDescriptor.getHBaseFamilyBytes(), columnDescriptor.getHBaseQualifierBytes()); if (null == keyValue) { // No data in this HTable column, skip it. continue; } // Convert the HBase cell to a Fiji cell. DecodedCell<?> fijiCell = decodeHBaseCell(columnDescriptor, keyValue.getValue()); // Write it at the same timestamp as the HBase cell. final String family = columnDescriptor.getFijiColumnName().getFamily(); final String qualifier = columnDescriptor.getFijiColumnName().getQualifier(); context.put(entity, family, qualifier, keyValue.getTimestamp(), fijiCell.getData()); } }
/** {@inheritDoc} */ @Override public void produce(final FijiRowData row, final FijiTableContext context) throws IOException { final Iterable<FijiCell<Object>> cells; if (mColumn.isFullyQualified()) { cells = row.asIterable(mColumn.getFamily(), mColumn.getQualifier()); } else { cells = row.asIterable(mColumn.getFamily()); } for (FijiCell<Object> cell : cells) { context.incrementCounter(Counters.CELLS_PROCESSED); final DecodedCell<Object> original = new DecodedCell<Object>(cell.getWriterSchema(), cell.getData()); final DecodedCell<Object> rewritten = rewriteCell(original); if (rewritten != original) { context.put( row.getEntityId(), mColumn.getFamily(), mColumn.getQualifier(), cell.getTimestamp(), rewritten.getData()); context.incrementCounter(Counters.CELLS_REWRITTEN); } } }