Java Code Examples for org.apache.hadoop.hbase.io.encoding.DataBlockEncoding#FAST_DIFF
The following examples show how to use
org.apache.hadoop.hbase.io.encoding.DataBlockEncoding#FAST_DIFF .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestHStoreFile.java From hbase with Apache License 2.0 | 6 votes |
/** * Check if data block encoding information is saved correctly in HFile's file info. */ @Test public void testDataBlockEncodingMetaData() throws IOException { // Make up a directory hierarchy that has a regiondir ("7e0102") and familyname. Path dir = new Path(new Path(testDir, "7e0102"), "familyname"); Path path = new Path(dir, "1234567890"); DataBlockEncoding dataBlockEncoderAlgo = DataBlockEncoding.FAST_DIFF; cacheConf = new CacheConfig(conf); HFileContext meta = new HFileContextBuilder().withBlockSize(BLOCKSIZE_SMALL).withChecksumType(CKTYPE) .withBytesPerCheckSum(CKBYTES).withDataBlockEncoding(dataBlockEncoderAlgo).build(); // Make a store file and write data to it. StoreFileWriter writer = new StoreFileWriter.Builder(conf, cacheConf, this.fs) .withFilePath(path).withMaxKeyCount(2000).withFileContext(meta).build(); writer.close(); HStoreFile storeFile = new HStoreFile(fs, writer.getPath(), conf, cacheConf, BloomType.NONE, true); storeFile.initReader(); StoreFileReader reader = storeFile.getReader(); Map<byte[], byte[]> fileInfo = reader.loadFileInfo(); byte[] value = fileInfo.get(HFileDataBlockEncoder.DATA_BLOCK_ENCODING); assertArrayEquals(dataBlockEncoderAlgo.getNameInBytes(), value); }
Example 2
Source File: ThriftUtilities.java From hbase with Apache License 2.0 | 5 votes |
public static DataBlockEncoding dataBlockEncodingFromThrift(TDataBlockEncoding in) { switch (in.getValue()) { case 0: return DataBlockEncoding.NONE; case 2: return DataBlockEncoding.PREFIX; case 3: return DataBlockEncoding.DIFF; case 4: return DataBlockEncoding.FAST_DIFF; case 7: return DataBlockEncoding.ROW_INDEX_V1; default: return DataBlockEncoding.NONE; } }
Example 3
Source File: IntegrationTestDDLMasterFailover.java From hbase with Apache License 2.0 | 4 votes |
@Override void perform() throws IOException { TableDescriptor selected = selectTable(disabledTables); if (selected == null) { return; } ColumnFamilyDescriptor columnDesc = selectFamily(selected); if (columnDesc == null){ return; } Admin admin = connection.getAdmin(); try { TableName tableName = selected.getTableName(); // possible DataBlockEncoding ids DataBlockEncoding[] possibleIds = {DataBlockEncoding.NONE, DataBlockEncoding.PREFIX, DataBlockEncoding.DIFF, DataBlockEncoding.FAST_DIFF, DataBlockEncoding.ROW_INDEX_V1}; short id = possibleIds[RandomUtils.nextInt(0, possibleIds.length)].getId(); LOG.info("Altering encoding of column family: " + columnDesc + " to: " + id + " in table: " + tableName); ColumnFamilyDescriptor cfd = ColumnFamilyDescriptorBuilder.newBuilder(columnDesc) .setDataBlockEncoding(DataBlockEncoding.getEncodingById(id)) .build(); TableDescriptor td = TableDescriptorBuilder.newBuilder(selected) .modifyColumnFamily(cfd) .build(); admin.modifyTable(td); // assertion TableDescriptor freshTableDesc = admin.getDescriptor(tableName); ColumnFamilyDescriptor freshColumnDesc = freshTableDesc.getColumnFamily(columnDesc.getName()); Assert.assertEquals("Encoding of column family: " + columnDesc + " was not altered", freshColumnDesc.getDataBlockEncoding().getId(), id); Assert.assertTrue( "After alter encoding of column family, Table: " + tableName + " is not disabled", admin.isTableDisabled(tableName)); disabledTables.put(tableName, freshTableDesc); LOG.info("Altered encoding of column family: " + freshColumnDesc + " to: " + id + " in table: " + tableName); } catch (Exception e) { LOG.warn("Caught exception in action: " + this.getClass()); throw e; } finally { admin.close(); } }