/** * Create a new FijiColumnName from a family and qualifier. * * @param family Family of the Fiji column for which to create a name. * @param qualifier Qualifier of the Fiji column for which to create a name. * @return a new FijiColumnName from the given family and qualifier. */ public static FijiColumnName create( final String family, final String qualifier ) { return new FijiColumnName(family, qualifier); }
/** * Given a FijiColumnName, return a sensible Hive column name. For a fully qualified column, * return the qualifier. Otherwise if it's a map type family, return the family name. * * @param fijiColumnName to generate the Hive column name for. * @return default Hive column name corresponding to the Fiji column. */ protected static String getDefaultHiveColumnName(FijiColumnName fijiColumnName) { if (fijiColumnName.isFullyQualified()) { return fijiColumnName.getQualifier(); } return fijiColumnName.getFamily(); }
/** {@inheritDoc} */ @Override public String getOutputColumn() { return mOutputColumn.toString(); }
/** {@inheritDoc} */ @Override public int compareTo(FijiColumnName otherObj) { final int comparison = this.mFamily.compareTo(otherObj.mFamily); if (0 == comparison) { return (this.isFullyQualified() ? mQualifier : "") .compareTo(otherObj.isFullyQualified() ? otherObj.getQualifier() : ""); } else { return comparison; } } }
/** * Constructs a row filter that excludes rows that have no data in <code>columnName</code>. * * @param columnName The column family:qualifier of interest. */ public HasColumnDataRowFilter(String columnName) { if (null == columnName) { throw new IllegalArgumentException("columnName is required"); } FijiColumnName fijiColName = FijiColumnName.create(columnName); if (!fijiColName.isFullyQualified()) { throw new IllegalArgumentException("Cannot use an unqualified column family."); } mFamily = fijiColName.getFamily(); mQualifier = fijiColName.getQualifier(); }
/** {@inheritDoc} */ @Override public boolean equals(Object otherObj) { if (otherObj == this) { return true; } else if (null == otherObj) { return false; } else if (!otherObj.getClass().equals(getClass())) { return false; } final FijiColumnName other = (FijiColumnName) otherObj; return other.getFamily().equals(mFamily) && Objects.equal(other.getQualifier(), mQualifier); }
/** {@inheritDoc}*/ @Override public HBaseColumnName toHBaseColumnName(FijiColumnName fijiColumnName) throws NoSuchColumnException { final String familyName = fijiColumnName.getFamily(); final String qualifierName = fijiColumnName.getQualifier(); // Validate the Fiji family final FamilyLayout family = mLayout.getFamilyMap().get(familyName); if (family == null) { throw new NoSuchColumnException(fijiColumnName.toString()); } // Validate the Fiji qualifier if (family.isGroupType() && !family.getColumnMap().containsKey(qualifierName)) { throw new NoSuchColumnException(fijiColumnName.toString()); } final byte[] localityGroupBytes = Bytes.toBytes(family.getLocalityGroup().getName()); final byte[] familyBytes = Bytes.toBytes(familyName); final byte[] qualifierBytes = Bytes.toBytes(qualifierName); final byte[] hbaseQualifierBytes = ShortColumnNameTranslator.concatWithSeparator(SEPARATOR, familyBytes, qualifierBytes); return new HBaseColumnName(localityGroupBytes, hbaseQualifierBytes); }
FijiColumnName fijiColumnName = new FijiColumnName(qualifierPagingColumn); Preconditions.checkArgument(!fijiColumnName.isFullyQualified(), "Cannot page over qualifiers for a fully qualified column: %s", qualifierPagingColumn); FijiColumnName fijiColumnName = new FijiColumnName(cellPagingColumn); if (fijiColumnName.isFullyQualified()) { Preconditions.checkArgument(!qualifierPagingMap.containsKey(fijiColumnName.getFamily()), "Cannot override family level cell paging with fully qualified cell paging: %s", fijiColumnName.toString());
/** {@inheritDoc} */ @Override public void produce(FijiRowData input, ProducerContext context) throws IOException { if (!mInputColumn.isFullyQualified()) { // Copy the entire family. for (String qualifier : input.getQualifiers(mInputColumn.getFamily())) { FijiColumnName sourceColumn = new FijiColumnName(mInputColumn.getFamily(), qualifier); produceAllVersions(input, context, sourceColumn); } } else { // Copy just a specific column. produceAllVersions(input, context, mInputColumn); } }
/** {@inheritDoc} */ @Override public void produce(FijiRowData input, ProducerContext context) throws IOException { if (!input.containsColumn(getInputColumnName().getFamily(), getInputColumnName().getQualifier())) { LOG.debug("No " + getInputColumnName().getName() + " for entity: " + input.getEntityId()); } String string = input.getMostRecentValue(getInputColumnName().getFamily(), getInputColumnName().getQualifier()).toString(); // Run the regex on the input string. Matcher matcher = mPattern.matcher(string); if (matcher.matches()) { if (matcher.groupCount() == 1) { context.put(matcher.group(1)); } } else { LOG.debug(input.getEntityId().toString() + "'s data '" + string + "' does not match " + mPattern.pattern()); } } }
/** * Sets the family. * * @param family The family. */ @HadoopConf(key=CONF_EXPORT_FAMILY) protected void setFamily(String family) { FijiColumnName name = new FijiColumnName(family); if (name.isFullyQualified()) { throw new RuntimeException("Expected an unqualified map type family. " + "Requested family was: " + name.getName()); } mFamily = family; }
if (column.isFullyQualified()) { return getDecoder(FijiColumnName.create(column.getFamily(), null));
/** * Gets the Fiji column family name. * * @return The Fiji column family name. */ protected String getFamily() { return mFijiColumnName.getFamily(); }
/** * Initialize the family and qualifier instance variables. */ private void initializeInputColumn() { mInputColumn = new FijiColumnName(getInputColumn()); if (!mInputColumn.isFullyQualified()) { throw new RuntimeException("getInputColumn() must contain a colon (':')"); } }
/** * Reports the request the applies for the specified column, or null if no such request exists. * * <p> * If the column belongs to a map-type family and there is a request for the entire family, * the request for the entire family is reported. * </p> * * @param columnName Requested column or family. * @return the request that applies for the specified column or family, * or null if no such request exists. */ public Column getRequestForColumn(final FijiColumnName columnName) { final Column column = getColumn(columnName); if (column != null) { return column; } if (columnName.isFullyQualified()) { return getColumn(columnName.getFamily(), null); } return null; }
/** * Builds the Hive type from the schema for a particular cell within Hive. * * @param fijiColumnName that specifices which column to build the Hive type from. * @param fijiTableLayout where the column resides. * @param schemaTable of the Fiji instance for type mappings * @return String representing the corresponding Hive type for a cell within the table's layout. * @throws IOException if there is an issue retrieving the schema of a particular column. */ protected static String getHiveType(FijiColumnName fijiColumnName, FijiTableLayout fijiTableLayout, FijiSchemaTable schemaTable) throws IOException { CellSchema cellSchema = fijiTableLayout.getCellSchema(fijiColumnName); Schema schema = getSchemaFromCellSchema(cellSchema, schemaTable); String hiveType = ""; if (null != schema) { hiveType = convertSchemaToHiveType(schema); if (!fijiColumnName.isFullyQualified()) { hiveType = "MAP<STRING, " + hiveType + ">"; } } else { // Null schemas are probably indicative of a counter, but they are currently unsupported // within the Fiji Hive Adapter. Log a warning, and let the user fix it. LOG.warn(fijiColumnName.toString() + " has a null schema and is unsupported within Hive."); } return hiveType; }
/** * Sets the column to retrieve values from. * * @param colName the column to use. * @return this builder instance. */ public Builder withColumn(FijiColumnName colName) { if (!colName.isFullyQualified()) { throw new IllegalArgumentException("Must specify a fully-qualified column, not a map."); } mColumn = colName; return this; }
/** {@inheritDoc} */ @Override public NavigableSet<String> getQualifiers(final String family) { final FijiColumnName column = FijiColumnName.create(family, null); validateColumnRequest(column); final NavigableSet<String> qualifiers = Sets.newTreeSet(); for (final FijiCell<?> cell : mResult.narrowView(column)) { qualifiers.add(cell.getColumn().getQualifier()); } return qualifiers; }
/** * Initializes a new FijiCell. * * @param column Name of the column in which this cell exists. * @param timestamp Timestamp of this cell in milliseconds since the epoch. * @param decodedCell Decoded cell content. */ private FijiCell( final FijiColumnName column, final long timestamp, final DecodedCell<T> decodedCell ) { Preconditions.checkArgument(column.isFullyQualified(), "Cannot create a FijiCell without a fully qualified column. Found family: %s", column.getName()); mColumn = column; mTimestamp = timestamp; mDecodedCell = decodedCell; }
if (!mFijiQualifierPagers.containsKey(columnName.getFamily())) { columnNames.add(columnName); FijiColumnName fijiColumnName = entry.getKey(); if (!pageData.containsKey(fijiColumnName) && !mFijiQualifierPagers.containsKey(fijiColumnName.getFamily())) { WritableUtils.writeString(out, entry.getKey().getName()); WritableUtils.writeString(out, entry.getValue().toString());