@Test public void testGetDataBlockEncoder() throws Exception { for (DataBlockEncoding algo : DataBlockEncoding.values()) { DataBlockEncoder encoder = DataBlockEncoding.getDataBlockEncoderById(algo.getId()); if (algo.getId() != 0) { assertTrue(DataBlockEncoding.isCorrectEncoder(encoder, algo.getId())); } } try { DataBlockEncoding.getDataBlockEncoderById((short) -1); fail("Illegal encoderId, should get IllegalArgumentException."); } catch (IllegalArgumentException ie) { } try { DataBlockEncoding.getDataBlockEncoderById(Byte.MAX_VALUE); // fail because idArray[Byte.MAX_VALUE] = null fail("Illegal encoderId, should get IllegalArgumentException."); } catch (IllegalArgumentException ie) { } }
/** * Updates the current block to be the given {@link HFileBlock}. Seeks to * the the first key/value pair. * * @param newBlock the block to make current */ private void updateCurrentBlock(HFileBlock newBlock) { block = newBlock; // sanity checks if (block.getBlockType() != BlockType.ENCODED_DATA) { throw new IllegalStateException( "EncodedScannerV2 works only on encoded data blocks"); } short dataBlockEncoderId = block.getDataBlockEncodingId(); if (dataBlockEncoder == null || !DataBlockEncoding.isCorrectEncoder(dataBlockEncoder, dataBlockEncoderId)) { DataBlockEncoder encoder = DataBlockEncoding.getDataBlockEncoderById(dataBlockEncoderId); setDataBlockEncoder(encoder); } seeker.setCurrentBuffer(getEncodedBuffer(newBlock)); blockFetches++; }
@Test public void testGetDataBlockEncoder() throws Exception { for (DataBlockEncoding algo : DataBlockEncoding.values()) { DataBlockEncoder encoder = DataBlockEncoding.getDataBlockEncoderById(algo.getId()); if (algo.getId() != 0) { assertTrue(DataBlockEncoding.isCorrectEncoder(encoder, algo.getId())); } } try { DataBlockEncoding.getDataBlockEncoderById((short) -1); fail("Illegal encoderId, should get IllegalArgumentException."); } catch (IllegalArgumentException ie) { } try { DataBlockEncoding.getDataBlockEncoderById(Byte.MAX_VALUE); // fail because idArray[Byte.MAX_VALUE] = null fail("Illegal encoderId, should get IllegalArgumentException."); } catch (IllegalArgumentException ie) { } }