@Override public T apply(final FijiCell<T> cell) { return cell.getData(); } });
/** {@inheritDoc} */ @Override public <T> T getValue(final String family, final String qualifier, final long timestamp) { final FijiCell<T> cell = getCell(family, qualifier, timestamp); return cell == null ? null : cell.getData(); }
/** {@inheritDoc} */ @Override public <T> T getMostRecentValue(final String family, final String qualifier) { final FijiCell<T> cell = getMostRecentCell(family, qualifier); return cell == null ? null : cell.getData(); }
/** {@inheritDoc} */ @Override public <T> NavigableMap<Long, T> getValues(String family, String qualifier) throws IOException { final NavigableMap<Long, T> result = Maps.newTreeMap(TimestampComparator.INSTANCE); for (Map.Entry<Long, FijiCell<T>> entry : this.<T>getCells(family, qualifier).entrySet()) { result.put(entry.getKey(), entry.getValue().getData()); } return result; }
/** {@inheritDoc} */ @Override public String toString() { return Objects.toStringHelper(FijiCell.class) .add("column", mColumn.getName()) .add("timestamp", mTimestamp) .add("encoding", getType()) .add("content", getData()) .toString(); }
/** * Return the value of the first (most recent) {@code FijiCell} in the first column of this * {@code FijiResult}. * * <p> * Note that if all columns in the {@code FijiResult} are paged, then retrieving the first * cell will require fetching a full page. * </p> * * <p> * If the distinction between an empty result and a result with a {@code null} value is * important, use {@link #getFirst} to retrieve the first cell. The cell will be {@code null} * if the result is empty. * </p> * * @param result The {@code FijiResult} containing the value to get. * @param <T> The type of values in the provided {@code FijiResult}'s cells. * @return the value of the first {@code FijiCell} in the result, or {@code null} if the result * is empty, or the value is {@code null}. */ public static <T> T getFirstValue(final FijiResult<T> result) { final FijiCell<T> first = getFirst(result); if (first == null) { return null; } else { return first.getData(); } }
/** * Constructs a FijiCellWritable from an existing FijiCell. * * @param fijiCell from a FijiRowData. */ public FijiCellWritable(FijiCell fijiCell) { mTimestamp = fijiCell.getTimestamp(); mSchema = fijiCell.getWriterSchema(); mData = fijiCell.getData(); }
/** {@inheritDoc} */ @Override public <T> NavigableMap<Long, T> getValues(final String family, final String qualifier) { final FijiColumnName column = FijiColumnName.create(family, qualifier); validateColumnRequest(column); final NavigableMap<Long, T> values = Maps.newTreeMap(TimestampComparator.INSTANCE); for (final FijiCell<T> cell : mResult.<T>narrowView(column)) { values.put(cell.getTimestamp(), cell.getData()); } return values; }
/** * Convenience method to add a new cell (represented by the FijiCell) to the row. * * @param cell is the cell to add. * @param schemaOption is the writer schema (contained as an option: either as a string or uid) */ public void addCell(FijiCell<?> cell, SchemaOption schemaOption) { addCell(cell.getFamily(), cell.getQualifier(), cell.getTimestamp(), cell.getData(), schemaOption); }
/** {@inheritDoc} */ @Override public <T> NavigableMap<String, NavigableMap<Long, T>> getValues(final String family) { final FijiColumnName column = FijiColumnName.create(family, null); validateColumnRequest(column); Preconditions.checkState(mLayout.getFamilyMap().get(family).isMapType(), "getValues(String family) is only enabled on map type column families." + " The column family [%s], is a group type column family." + " Please use the getValues(String family, String qualifier) method.", family); final NavigableMap<String, NavigableMap<Long, T>> qualifiers = Maps.newTreeMap(); for (final FijiCell<T> cell : mResult.<T>narrowView(column)) { NavigableMap<Long, T> columnValues = qualifiers.get(cell.getColumn().getQualifier()); if (columnValues == null) { columnValues = Maps.newTreeMap(TimestampComparator.INSTANCE); qualifiers.put(cell.getColumn().getQualifier(), columnValues); } columnValues.put(cell.getTimestamp(), cell.getData()); } return qualifiers; }
/** * Prints the contents of a single fiji cell to the printstream. * * @param entityId The entity id. * @param cell The FijiCell. * @param printStream The stream to print to. */ private static void printCell(EntityId entityId, FijiCell<?> cell, PrintStream printStream) { printStream.printf("entity-id=%s [%d] %s:%s%n %s%n", formatEntityId(entityId), cell.getTimestamp(), cell.getColumn().getFamily(), cell.getColumn().getQualifier(), cell.getData()); }
final String qualifier = cell.getColumn().getQualifier(); if (!qualifier.equals(previousQualifier)) { qualifiers.put(qualifier, cell.getData()); previousQualifier = qualifier; final FijiCell<T> cell = Helpers.getFirst(mResult.<T>narrowView(requestedColumn)); if (cell != null) { qualifiers.put(cell.getColumn().getQualifier(), cell.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); } } }