@Override public void perform() throws Exception { final Random random = new Random(); final BloomType[] bloomArray = BloomType.values(); final int bloomArraySize = bloomArray.length; LOG.info("Performing action: Change bloom filter on all columns of table " + tableName); modifyAllTableColumns(tableName, (columnName, columnBuilder) -> { BloomType bloomType = bloomArray[random.nextInt(bloomArraySize)]; LOG.debug("Performing action: About to set bloom filter type to " + bloomType + " on column " + columnName + " of table " + tableName); columnBuilder.setBloomFilterType(bloomType); if (bloomType == BloomType.ROWPREFIX_FIXED_LENGTH) { columnBuilder.setConfiguration(BloomFilterUtil.PREFIX_LENGTH_KEY, "10"); } else if (bloomType == BloomType.ROWPREFIX_DELIMITED) { columnBuilder.setConfiguration(BloomFilterUtil.DELIMITER_KEY, "#"); } }); LOG.debug("Performing action: Just set bloom filter types on table " + tableName); } }
/** * Converts a ColumnFamilySchema to ColumnFamilyDescriptor * @param cfs the ColumnFamilySchema * @return An {@link ColumnFamilyDescriptor} made from the passed in <code>cfs</code> */ public static ColumnFamilyDescriptor toColumnFamilyDescriptor(final ColumnFamilySchema cfs) { // Use the empty constructor so we preserve the initial values set on construction for things // like maxVersion. Otherwise, we pick up wrong values on deserialization which makes for // unrelated-looking test failures that are hard to trace back to here. ColumnFamilyDescriptorBuilder builder = ColumnFamilyDescriptorBuilder.newBuilder(cfs.getName().toByteArray()); cfs.getAttributesList().forEach(a -> builder.setValue(a.getFirst().toByteArray(), a.getSecond().toByteArray())); cfs.getConfigurationList().forEach(a -> builder.setConfiguration(a.getName(), a.getValue())); return builder.build(); }
/** * Test that we add and remove strings from configuration properly. */ @Test public void testAddGetRemoveConfiguration() { ColumnFamilyDescriptorBuilder builder = ColumnFamilyDescriptorBuilder.newBuilder(Bytes.toBytes("foo")); String key = "Some"; String value = "value"; builder.setConfiguration(key, value); assertEquals(value, builder.build().getConfigurationValue(key)); builder.removeConfiguration(key); assertEquals(null, builder.build().getConfigurationValue(key)); }
builder.setConfiguration(conf.getKey(), conf.getValue());
/** * Converts a ColumnFamilySchema to ColumnFamilyDescriptor * @param cfs the ColumnFamilySchema * @return An {@link ColumnFamilyDescriptor} made from the passed in <code>cfs</code> */ public static ColumnFamilyDescriptor toColumnFamilyDescriptor(final ColumnFamilySchema cfs) { // Use the empty constructor so we preserve the initial values set on construction for things // like maxVersion. Otherwise, we pick up wrong values on deserialization which makes for // unrelated-looking test failures that are hard to trace back to here. ColumnFamilyDescriptorBuilder builder = ColumnFamilyDescriptorBuilder.newBuilder(cfs.getName().toByteArray()); cfs.getAttributesList().forEach(a -> builder.setValue(a.getFirst().toByteArray(), a.getSecond().toByteArray())); cfs.getConfigurationList().forEach(a -> builder.setConfiguration(a.getName(), a.getValue())); return builder.build(); }
/** * Test that we add and remove strings from configuration properly. */ @Test public void testAddGetRemoveConfiguration() { ColumnFamilyDescriptorBuilder builder = ColumnFamilyDescriptorBuilder.newBuilder(Bytes.toBytes("foo")); String key = "Some"; String value = "value"; builder.setConfiguration(key, value); assertEquals(value, builder.build().getConfigurationValue(key)); builder.removeConfiguration(key); assertEquals(null, builder.build().getConfigurationValue(key)); }
/** * Converts a ColumnFamilySchema to ColumnFamilyDescriptor * @param cfs the ColumnFamilySchema * @return An {@link ColumnFamilyDescriptor} made from the passed in <code>cfs</code> */ public static ColumnFamilyDescriptor toColumnFamilyDescriptor(final ColumnFamilySchema cfs) { // Use the empty constructor so we preserve the initial values set on construction for things // like maxVersion. Otherwise, we pick up wrong values on deserialization which makes for // unrelated-looking test failures that are hard to trace back to here. ColumnFamilyDescriptorBuilder builder = ColumnFamilyDescriptorBuilder.newBuilder(cfs.getName().toByteArray()); cfs.getAttributesList().forEach(a -> builder.setValue(a.getFirst().toByteArray(), a.getSecond().toByteArray())); cfs.getConfigurationList().forEach(a -> builder.setConfiguration(a.getName(), a.getValue())); return builder.build(); }