@Test public void testMutatingAPut() throws Exception { Put put = generateOriginalPut(); byte[] newValue = Bytes.toBytes("new-value"); Cell cell = put.get(TABLE_FAMILY_BYTES, QUALIFIER).get(0); assertEquals(Bytes.toString(ORIGINAL_VALUE), Bytes.toString(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength())); MetaDataUtil.mutatePutValue(put, TABLE_FAMILY_BYTES, QUALIFIER, newValue); cell = put.get(TABLE_FAMILY_BYTES, QUALIFIER).get(0); assertEquals(Bytes.toString(newValue), Bytes.toString(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength())); }
public static void mutatePutValue(Put somePut, byte[] family, byte[] qualifier, byte[] newValue) { NavigableMap<byte[], List<Cell>> familyCellMap = somePut.getFamilyCellMap(); List<Cell> cells = familyCellMap.get(family); List<Cell> newCells = Lists.newArrayList(); if (cells != null) { for (Cell cell : cells) { if (Bytes.compareTo(cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength(), qualifier, 0, qualifier.length) == 0) { Cell replacementCell = new KeyValue(cell.getRowArray(), cell.getRowOffset(), cell.getRowLength(), cell.getFamilyArray(), cell.getFamilyOffset(), cell.getFamilyLength(), cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength(), cell.getTimestamp(), KeyValue.Type.codeToType(cell.getType().getCode()), newValue, 0, newValue.length); newCells.add(replacementCell); } else { newCells.add(cell); } } familyCellMap.put(family, newCells); } }
MetaDataUtil { public static void mutatePutValue(Put somePut, byte[] family, byte[] qualifier, byte[] newValue) { NavigableMap<byte[], List<Cell>> familyCellMap = somePut.getFamilyCellMap(); List<Cell> cells = familyCellMap.get(family); List<Cell> newCells = Lists.newArrayList(); if (cells != null) { for (Cell cell : cells) { if (Bytes.compareTo(cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength(), qualifier, 0, qualifier.length) == 0) { Cell replacementCell = new KeyValue(cell.getRowArray(), cell.getRowOffset(), cell.getRowLength(), cell.getFamilyArray(), cell.getFamilyOffset(), cell.getFamilyLength(), cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength(), cell.getTimestamp(), KeyValue.Type.codeToType(cell.getType().getCode()), newValue, 0, newValue.length); newCells.add(replacementCell); } else { newCells.add(cell); } } familyCellMap.put(family, newCells); } } }
MetaDataUtil { public static void mutatePutValue(Put somePut, byte[] family, byte[] qualifier, byte[] newValue) { NavigableMap<byte[], List<Cell>> familyCellMap = somePut.getFamilyCellMap(); List<Cell> cells = familyCellMap.get(family); List<Cell> newCells = Lists.newArrayList(); if (cells != null) { for (Cell cell : cells) { if (Bytes.compareTo(cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength(), qualifier, 0, qualifier.length) == 0) { Cell replacementCell = new KeyValue(cell.getRowArray(), cell.getRowOffset(), cell.getRowLength(), cell.getFamilyArray(), cell.getFamilyOffset(), cell.getFamilyLength(), cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength(), cell.getTimestamp(), KeyValue.Type.codeToType(cell.getType().getCode()), newValue, 0, newValue.length); newCells.add(replacementCell); } else { newCells.add(cell); } } familyCellMap.put(family, newCells); } }  }
MetaDataUtil { public static void mutatePutValue(Put somePut, byte[] family, byte[] qualifier, byte[] newValue) { NavigableMap<byte[], List<Cell>> familyCellMap = somePut.getFamilyCellMap(); List<Cell> cells = familyCellMap.get(family); List<Cell> newCells = Lists.newArrayList(); if (cells != null) { for (Cell cell : cells) { if (Bytes.compareTo(cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength(), qualifier, 0, qualifier.length) == 0) { Cell replacementCell = new KeyValue(cell.getRowArray(), cell.getRowOffset(), cell.getRowLength(), cell.getFamilyArray(), cell.getFamilyOffset(), cell.getFamilyLength(), cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength(), cell.getTimestamp(), KeyValue.Type.codeToType(cell.getType().getCode()), newValue, 0, newValue.length); newCells.add(replacementCell); } else { newCells.add(cell); } } familyCellMap.put(family, newCells); } }  static ClientServerCompatibility areClientAndServerCompatible(long serverHBaseAndPhoenixVersion); static int decodePhoenixVersion(long version); static long encodeHasIndexWALCodec(long version, boolean isValid); static boolean decodeHasIndexWALCodec(long version); static int decodeHBaseVersion(long version); static String decodeHBaseVersionAsString(int version); static boolean decodeTableNamespaceMappingEnabled(long version); static long encodeVersion(String hbaseVersionStr, Configuration config); static byte[] getTenantIdAndSchemaAndTableName(Mutation someRow); static byte[] getTenantIdAndSchemaAndTableName(Result result); static void getTenantIdAndSchemaAndTableName(List<Mutation> tableMetadata, byte[][] rowKeyMetaData); static int getBaseColumnCount(List<Mutation> tableMetadata); static void mutatePutValue(Put somePut, byte[] family, byte[] qualifier, byte[] newValue); static void conditionallyAddTagsToPutCells(Put somePut, byte[] family, byte[] qualifier,
            ExtendedCellBuilder cellBuilder, byte[] valueArray, byte[] tagArray); static Put cloneDeleteToPutAndAddColumn(Delete delete, byte[] family, byte[] qualifier, byte[] value); static void getTenantIdAndFunctionName(List<Mutation> functionMetadata, byte[][] rowKeyMetaData); static byte[] getParentTableName(List<Mutation> tableMetadata); static long getSequenceNumber(Mutation tableMutation); static long getSequenceNumber(List<Mutation> tableMetaData); static PTableType getTableType(List<Mutation> tableMetaData, KeyValueBuilder builder,
      ImmutableBytesWritable value); static boolean isNameSpaceMapped(List<Mutation> tableMetaData, KeyValueBuilder builder,
            ImmutableBytesWritable value); static int getSaltBuckets(List<Mutation> tableMetaData, KeyValueBuilder builder,
      ImmutableBytesWritable value); static long getParentSequenceNumber(List<Mutation> tableMetaData); static Mutation getTableHeaderRow(List<Mutation> tableMetaData); static boolean getMutationValue(Mutation headerRow, byte[] key,
      KeyValueBuilder builder, ImmutableBytesWritable ptr); static KeyValue getMutationValue(Mutation headerRow, byte[] key,
        KeyValueBuilder builder); static boolean setMutationValue(Mutation headerRow, byte[] key,
        KeyValueBuilder builder, KeyValue keyValue); static Put getPutOnlyTableHeaderRow(List<Mutation> tableMetaData); static Put getPutOnlyAutoPartitionColumn(PTable parentTable, List<Mutation> tableMetaData); static Mutation getParentTableHeaderRow(List<Mutation> tableMetaData); static long getClientTimeStamp(List<Mutation> tableMetadata); static long getClientTimeStamp(Mutation m); static byte[] getParentLinkKey(String tenantId, String schemaName, String tableName, String indexName); static byte[] getParentLinkKey(byte[] tenantId, byte[] schemaName, byte[] tableName, byte[] indexName); static byte[] getChildLinkKey(PName parentTenantId, PName parentSchemaName, PName parentTableName, PName viewTenantId, PName viewName); static Cell getCell(List<Cell> cells, byte[] cq); static boolean isMultiTenant(Mutation m, KeyValueBuilder builder, ImmutableBytesWritable ptr); static boolean isTransactional(Mutation m, KeyValueBuilder builder, ImmutableBytesWritable ptr); static boolean isSalted(Mutation m, KeyValueBuilder builder, ImmutableBytesWritable ptr); static byte[] getViewIndexPhysicalName(byte[] physicalTableName); static String getViewIndexPhysicalName(String physicalTableName); static byte[] getLocalIndexPhysicalName(byte[] physicalTableName); static String getLocalIndexTableName(String tableName); static String getLocalIndexSchemaName(String schemaName); static String getLocalIndexUserTableName(String localIndexTableName); static String getViewIndexUserTableName(String viewIndexTableName); static String getOldViewIndexSequenceSchemaName(PName physicalName, boolean isNamespaceMapped); static String getOldViewIndexSequenceName(PName physicalName, PName tenantId, boolean isNamespaceMapped); static SequenceKey getOldViewIndexSequenceKey(String tenantId, PName physicalName, int nSaltBuckets,
                                                      boolean isNamespaceMapped); static String getViewIndexSequenceSchemaName(PName physicalName, boolean isNamespaceMapped); static String getViewIndexSequenceName(PName physicalName, PName tenantId, boolean isNamespaceMapped); static SequenceKey getViewIndexSequenceKey(String tenantId, PName physicalName, int nSaltBuckets,
            boolean isNamespaceMapped); static PDataType getViewIndexIdDataType(); static PDataType getLegacyViewIndexIdDataType(); static String getViewIndexIdColumnName(); static boolean hasViewIndexTable(PhoenixConnection connection, PName physicalName); static boolean hasViewIndexTable(PhoenixConnection connection, byte[] physicalTableName); static boolean hasLocalIndexTable(PhoenixConnection connection, PName physicalName); static boolean hasLocalIndexTable(PhoenixConnection connection, byte[] physicalTableName); static boolean hasLocalIndexColumnFamily(TableDescriptor desc); static List<byte[]> getNonLocalIndexColumnFamilies(TableDescriptor desc); static List<byte[]> getLocalIndexColumnFamilies(PhoenixConnection conn, byte[] physicalTableName); static void deleteViewIndexSequences(PhoenixConnection connection, PName name, boolean isNamespaceMapped); static boolean tableRegionsOnline(Configuration conf, PTable table); static boolean propertyNotAllowedToBeOutOfSync(String colFamProp); static Map<String, Object> getSyncedProps(ColumnFamilyDescriptor defaultCFDesc); static Scan newTableRowsScan(byte[] key, long startTimeStamp, long stopTimeStamp); static Scan newTableRowsScan(byte[] startKey, byte[] stopKey, long startTimeStamp, long stopTimeStamp); static LinkType getLinkType(Mutation tableMutation); static LinkType getLinkType(Collection<Cell> kvs); static boolean isLocalIndex(String physicalName); static boolean isViewIndex(String physicalName); static String getAutoPartitionColumnName(PTable parentTable); static int getAutoPartitionColIndex(PTable parentTable); static String getJdbcUrl(RegionCoprocessorEnvironment env); static boolean isHColumnProperty(String propName); static boolean isHTableProperty(String propName); static boolean isLocalIndexFamily(ImmutableBytesPtr cfPtr); static boolean isLocalIndexFamily(byte[] cf); static final byte[] getPhysicalTableRowForView(PTable view); static List<Mutation> removeChildLinkMutations(List<Mutation> metadataMutations); static IndexType getIndexType(List<Mutation> tableMetaData, KeyValueBuilder builder,
            ImmutableBytesWritable value); static PDataType<?> getIndexDataType(List<Mutation> tableMetaData,
            KeyValueBuilder builder, ImmutableBytesWritable value); static PColumn getColumn(int pkCount, byte[][] rowKeyMetaData, PTable table); static void deleteFromStatsTable(PhoenixConnection connection,
                                            PTable table, List<byte[]> physicalTableNames,
                                            List<MetaDataProtocol.SharedTableState> sharedTableStates); }
MetaDataUtil { public static void mutatePutValue(Put somePut, byte[] family, byte[] qualifier, byte[] newValue) { NavigableMap<byte[], List<Cell>> familyCellMap = somePut.getFamilyCellMap(); List<Cell> cells = familyCellMap.get(family); List<Cell> newCells = Lists.newArrayList(); if (cells != null) { for (Cell cell : cells) { if (Bytes.compareTo(cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength(), qualifier, 0, qualifier.length) == 0) { Cell replacementCell = new KeyValue(cell.getRowArray(), cell.getRowOffset(), cell.getRowLength(), cell.getFamilyArray(), cell.getFamilyOffset(), cell.getFamilyLength(), cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength(), cell.getTimestamp(), KeyValue.Type.codeToType(cell.getType().getCode()), newValue, 0, newValue.length); newCells.add(replacementCell); } else { newCells.add(cell); } } familyCellMap.put(family, newCells); } }  static ClientServerCompatibility areClientAndServerCompatible(long serverHBaseAndPhoenixVersion); static int decodePhoenixVersion(long version); static long encodeHasIndexWALCodec(long version, boolean isValid); static boolean decodeHasIndexWALCodec(long version); static int decodeHBaseVersion(long version); static String decodeHBaseVersionAsString(int version); static boolean decodeTableNamespaceMappingEnabled(long version); static long encodeVersion(String hbaseVersionStr, Configuration config); static byte[] getTenantIdAndSchemaAndTableName(Mutation someRow); static byte[] getTenantIdAndSchemaAndTableName(Result result); static void getTenantIdAndSchemaAndTableName(List<Mutation> tableMetadata, byte[][] rowKeyMetaData); static int getBaseColumnCount(List<Mutation> tableMetadata); static void mutatePutValue(Put somePut, byte[] family, byte[] qualifier, byte[] newValue); static void conditionallyAddTagsToPutCells(Put somePut, byte[] family, byte[] qualifier,
            ExtendedCellBuilder cellBuilder, byte[] valueArray, byte[] tagArray); static Put cloneDeleteToPutAndAddColumn(Delete delete, byte[] family, byte[] qualifier, byte[] value); static void getTenantIdAndFunctionName(List<Mutation> functionMetadata, byte[][] rowKeyMetaData); static byte[] getParentTableName(List<Mutation> tableMetadata); static long getSequenceNumber(Mutation tableMutation); static long getSequenceNumber(List<Mutation> tableMetaData); static PTableType getTableType(List<Mutation> tableMetaData, KeyValueBuilder builder,
      ImmutableBytesWritable value); static boolean isNameSpaceMapped(List<Mutation> tableMetaData, KeyValueBuilder builder,
            ImmutableBytesWritable value); static int getSaltBuckets(List<Mutation> tableMetaData, KeyValueBuilder builder,
      ImmutableBytesWritable value); static long getParentSequenceNumber(List<Mutation> tableMetaData); static Mutation getTableHeaderRow(List<Mutation> tableMetaData); static boolean getMutationValue(Mutation headerRow, byte[] key,
      KeyValueBuilder builder, ImmutableBytesWritable ptr); static KeyValue getMutationValue(Mutation headerRow, byte[] key,
        KeyValueBuilder builder); static boolean setMutationValue(Mutation headerRow, byte[] key,
        KeyValueBuilder builder, KeyValue keyValue); static Put getPutOnlyTableHeaderRow(List<Mutation> tableMetaData); static Put getPutOnlyAutoPartitionColumn(PTable parentTable, List<Mutation> tableMetaData); static Mutation getParentTableHeaderRow(List<Mutation> tableMetaData); static long getClientTimeStamp(List<Mutation> tableMetadata); static long getClientTimeStamp(Mutation m); static byte[] getParentLinkKey(String tenantId, String schemaName, String tableName, String indexName); static byte[] getParentLinkKey(byte[] tenantId, byte[] schemaName, byte[] tableName, byte[] indexName); static byte[] getChildLinkKey(PName parentTenantId, PName parentSchemaName, PName parentTableName, PName viewTenantId, PName viewName); static Cell getCell(List<Cell> cells, byte[] cq); static boolean isMultiTenant(Mutation m, KeyValueBuilder builder, ImmutableBytesWritable ptr); static boolean isTransactional(Mutation m, KeyValueBuilder builder, ImmutableBytesWritable ptr); static boolean isSalted(Mutation m, KeyValueBuilder builder, ImmutableBytesWritable ptr); static byte[] getViewIndexPhysicalName(byte[] physicalTableName); static String getViewIndexPhysicalName(String physicalTableName); static byte[] getLocalIndexPhysicalName(byte[] physicalTableName); static String getLocalIndexTableName(String tableName); static String getLocalIndexSchemaName(String schemaName); static String getLocalIndexUserTableName(String localIndexTableName); static String getViewIndexUserTableName(String viewIndexTableName); static String getOldViewIndexSequenceSchemaName(PName physicalName, boolean isNamespaceMapped); static String getOldViewIndexSequenceName(PName physicalName, PName tenantId, boolean isNamespaceMapped); static SequenceKey getOldViewIndexSequenceKey(String tenantId, PName physicalName, int nSaltBuckets,
                                                      boolean isNamespaceMapped); static String getViewIndexSequenceSchemaName(PName physicalName, boolean isNamespaceMapped); static String getViewIndexSequenceName(PName physicalName, PName tenantId, boolean isNamespaceMapped); static SequenceKey getViewIndexSequenceKey(String tenantId, PName physicalName, int nSaltBuckets,
            boolean isNamespaceMapped); static PDataType getViewIndexIdDataType(); static PDataType getLegacyViewIndexIdDataType(); static String getViewIndexIdColumnName(); static boolean hasViewIndexTable(PhoenixConnection connection, PName physicalName); static boolean hasViewIndexTable(PhoenixConnection connection, byte[] physicalTableName); static boolean hasLocalIndexTable(PhoenixConnection connection, PName physicalName); static boolean hasLocalIndexTable(PhoenixConnection connection, byte[] physicalTableName); static boolean hasLocalIndexColumnFamily(TableDescriptor desc); static List<byte[]> getNonLocalIndexColumnFamilies(TableDescriptor desc); static List<byte[]> getLocalIndexColumnFamilies(PhoenixConnection conn, byte[] physicalTableName); static void deleteViewIndexSequences(PhoenixConnection connection, PName name, boolean isNamespaceMapped); static boolean tableRegionsOnline(Configuration conf, PTable table); static boolean propertyNotAllowedToBeOutOfSync(String colFamProp); static Map<String, Object> getSyncedProps(ColumnFamilyDescriptor defaultCFDesc); static Scan newTableRowsScan(byte[] key, long startTimeStamp, long stopTimeStamp); static Scan newTableRowsScan(byte[] startKey, byte[] stopKey, long startTimeStamp, long stopTimeStamp); static LinkType getLinkType(Mutation tableMutation); static LinkType getLinkType(Collection<Cell> kvs); static boolean isLocalIndex(String physicalName); static boolean isViewIndex(String physicalName); static String getAutoPartitionColumnName(PTable parentTable); static int getAutoPartitionColIndex(PTable parentTable); static String getJdbcUrl(RegionCoprocessorEnvironment env); static boolean isHColumnProperty(String propName); static boolean isHTableProperty(String propName); static boolean isLocalIndexFamily(ImmutableBytesPtr cfPtr); static boolean isLocalIndexFamily(byte[] cf); static final byte[] getPhysicalTableRowForView(PTable view); static List<Mutation> removeChildLinkMutations(List<Mutation> metadataMutations); static IndexType getIndexType(List<Mutation> tableMetaData, KeyValueBuilder builder,
            ImmutableBytesWritable value); static PDataType<?> getIndexDataType(List<Mutation> tableMetaData,
            KeyValueBuilder builder, ImmutableBytesWritable value); static PColumn getColumn(int pkCount, byte[][] rowKeyMetaData, PTable table); static void deleteFromStatsTable(PhoenixConnection connection,
                                            PTable table, List<byte[]> physicalTableNames,
                                            List<MetaDataProtocol.SharedTableState> sharedTableStates); static final String VIEW_INDEX_TABLE_PREFIX; static final String LOCAL_INDEX_TABLE_PREFIX; static final String VIEW_INDEX_SEQUENCE_PREFIX; static final String VIEW_INDEX_SEQUENCE_NAME_PREFIX; static final byte[] VIEW_INDEX_SEQUENCE_PREFIX_BYTES; static final String VIEW_INDEX_ID_COLUMN_NAME; static final String PARENT_TABLE_KEY; static final String IS_VIEW_INDEX_TABLE_PROP_NAME; static final byte[] IS_VIEW_INDEX_TABLE_PROP_BYTES; static final String IS_LOCAL_INDEX_TABLE_PROP_NAME; static final byte[] IS_LOCAL_INDEX_TABLE_PROP_BYTES; static final String DATA_TABLE_NAME_PROP_NAME; static final byte[] DATA_TABLE_NAME_PROP_BYTES; static final List<String> SYNCED_DATA_TABLE_AND_INDEX_COL_FAM_PROPERTIES; }