/** * Get the content of this cell. * * @return the content of this cell. */ public T getData() { return mDecodedCell.getData(); }
/** {@inheritDoc} */ @Override public byte[] encode(final DecodedCell<?> cell) throws IOException { return encode(cell.getData()); }
/** {@inheritDoc} */ @Override public byte[] encode(DecodedCell<?> cell) throws IOException { return encode(cell.getData()); }
/** {@inheritDoc} */ @Override public int hashCode() { return Objects.hashCode(getWriterSchema(), getData()); }
/** {@inheritDoc} */ @Override public byte[] encode(final DecodedCell<?> cell) throws IOException { return encode(cell.getData()); }
/** {@inheritDoc} */ @Override public T decodeValue(byte[] bytes) throws IOException { return decodeCell(bytes).getData(); }
/** {@inheritDoc} */ @Override public T decodeValue(byte[] bytes) throws IOException { return decodeCell(bytes).getData(); } }
/** {@inheritDoc} */ @Override public byte[] encode(final DecodedCell<?> cell) throws IOException { return encode(cell.getData()); }
/** * Determines whether the data contained in this DecodedCell is equivalent to another. The * data is equivalent if they have the same schema and the same data, regardless of location. * * @param obj The object to compare. * @return Whether this contains the same data as the other DecodedCell. */ @Override public boolean equals(Object obj) { if (!(obj instanceof DecodedCell<?>)) { return false; } final DecodedCell<?> other = (DecodedCell<?>) obj; if (!Objects.equal(this.getWriterSchema(), other.getWriterSchema())) { return false; } if (!Objects.equal(this.getReaderSchema(), other.getReaderSchema())) { return false; } Object data = getData(); Object otherData = other.getData(); // UTF8 strings don't compare well with other CharSequences: if ((data instanceof Utf8) ^ (otherData instanceof Utf8)) { data = data.toString(); otherData = otherData.toString(); } return data.equals(otherData); }
writer.write(original.getData(), encoder); encoder.flush();
/** {@inheritDoc} */ @Override protected JsonNode toJsonNode() { final ObjectNode root = JsonNodeFactory.instance.objectNode(); root.put(FAMILY_NODE, mFamily); root.put(QUALIFIER_NODE, mQualifier); final ObjectNode value = root.with(VALUE_NODE); // Schema's documentation for toString says it is rendered as JSON. value.put(SCHEMA_NODE, mValue.getWriterSchema().toString()); try { value.put(DATA_NODE, ToJson.toAvroJsonString(mValue.getData(), mValue.getWriterSchema())); } catch (IOException ioe) { throw new FijiIOException(ioe); } return root; }
/** {@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); } } }