/** * Returns the Avro descriptor for this table layout. * @return the Avro descriptor for this table layout. */ public TableLayoutDesc getDesc() { return TableLayoutDesc.newBuilder(mDesc).build(); }
/** @return A copy of the Avro descriptor for this column. */ public ColumnDesc getDesc() { return ColumnDesc.newBuilder(mDesc).build(); }
/** @return the Avro descriptor for this locality group. */ public LocalityGroupDesc getDesc() { return LocalityGroupDesc.newBuilder(mDesc).build(); }
/** * Converts a SchemaEntry into an Avro SchemaTableEntry. * * @param entry a SchemaEntry. * @return an equivalent Avro SchemaTableEntry. */ public static SchemaTableEntry toAvroEntry(final SchemaEntry entry) { return SchemaTableEntry.newBuilder().setId(entry.getId()) .setHash(new MD5Hash(entry.getHash().getBytes())) .setAvroSchema(entry.getSchema().toString()).build(); }
/** * Normalizes the table layout descriptor to use schema UIDs only. * * @param descBuilder Builder for the table layout descriptor to normalize. * @param options Options describing the normalization to apply. * @throws IOException on I/O error. */ private void normalizeTableLayoutDesc(TableLayoutDesc.Builder descBuilder, LayoutOptions options) throws IOException { for (LocalityGroupDesc lgdesc : descBuilder.getLocalityGroups()) { for (FamilyDesc fdesc : lgdesc.getFamilies()) { if (fdesc.getMapSchema() != null) { normalizeCellSchema(fdesc.getMapSchema(), options); } else { for (ColumnDesc cdesc : fdesc.getColumns()) { normalizeCellSchema(cdesc.getColumnSchema(), options); } } } } }
/** * Find the encoding of the row key given the format. * * @param rowKeyFormat Format of row keys of type RowKeyFormat or RowKeyFormat2. * @return The specific row key encoding, e.g. RAW, HASH, etc. */ public static RowKeyEncoding getEncoding(Object rowKeyFormat) { if (rowKeyFormat instanceof RowKeyFormat) { return ((RowKeyFormat) rowKeyFormat).getEncoding(); } else if (rowKeyFormat instanceof RowKeyFormat2) { return ((RowKeyFormat2) rowKeyFormat).getEncoding(); } else { throw new RuntimeException("Unsupported Row Key Format"); } }
/** {@inheritDoc} */ @Override public List<Object> getComponents() { Preconditions.checkState(!mRowKeyFormat.getSalt().getSuppressKeyMaterialization(), "Cannot retrieve components as materialization is suppressed"); return Collections.unmodifiableList(mComponentValues); }
/** @return the Avro descriptor for this family. */ public FamilyDesc getDesc() { return FamilyDesc.newBuilder(mDesc).build(); }
/** * Returns the table name. * @return the table name. */ public String getName() { return mDesc.getName(); }
/** @return the primary name for the column. */ public String getName() { return mDesc.getName(); }
/** @return the primary name for the family. */ public String getName() { return mDesc.getName(); }
/** @return whether this is a group-type family. */ public boolean isGroupType() { return mDesc.getMapSchema() == null; }
/** * Returns the underlying CellSchema Avro record, creating it if necessary. * @return the underlying CellSchema Avro record, creating it if necessary. */ private CellSchema getOrCreateCellSchema() { if (null == mCellSchema) { mCellSchema = new CellSchema(); } return mCellSchema; }
/** * Get the layout id. * * @return layout id */ public String getLayoutId() { return mDescBuilder.getLayoutId(); }
/** * Set the layout id. * * @param layoutId to set * @return this. */ public TableLayoutBuilder withLayoutId(String layoutId) { mDescBuilder.setLayoutId(layoutId); return this; }
/** @return the locality group primary name. */ public String getName() { return mDesc.getName(); }
/** * Build a new table layout descriptor. * * @return a built table layout descriptor. */ public TableLayoutDesc build() { return mDescBuilder.build(); }
/** * Converts a SchemaEntry into an Avro SchemaTableEntry. * * @param entry a SchemaEntry. * @return an equivalent Avro SchemaTableEntry. */ public static SchemaTableEntry toAvroEntry(final SchemaEntry entry) { return SchemaTableEntry .newBuilder() .setId(entry.getId()) .setHash(new MD5Hash(entry.getHash().getBytes())) .setAvroSchema(entry.getSchema().toString()) .build(); }
/** {@inheritDoc} */ @Override @SuppressWarnings("unchecked") public <T> T getComponentByIndex(int idx) { Preconditions.checkState(!mRowKeyFormat.getSalt().getSuppressKeyMaterialization(), "Cannot retrieve components as materialization is suppressed"); Preconditions.checkArgument(idx >= 0 && idx < mComponentValues.size()); return (T) mComponentValues.get(idx); }
/** * Normalizes a table layout descriptor to use schema UIDs only. * * @param desc Table layout descriptor to normalize. * @param options Options describing the normalization to apply. * @return the normalized table layout descriptor. * @throws IOException on I/O error. */ public TableLayoutDesc normalizeTableLayoutDesc(TableLayoutDesc desc, LayoutOptions options) throws IOException { final TableLayoutDesc.Builder descBuilder = TableLayoutDesc.newBuilder(desc); normalizeTableLayoutDesc(descBuilder, options); return descBuilder.build(); }