Java Code Examples for org.apache.flink.api.common.io.statistics.BaseStatistics#getAverageRecordWidth()
The following examples show how to use
org.apache.flink.api.common.io.statistics.BaseStatistics#getAverageRecordWidth() .
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: DelimitedInputFormatSamplingTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void testSamplingDirectory() { try { final String tempFile = TestFileUtils.createTempFileDir(testTempFolder, TEST_DATA1, TEST_DATA2); final Configuration conf = new Configuration(); final TestDelimitedInputFormat format = new TestDelimitedInputFormat(CONFIG); format.setFilePath(tempFile); format.configure(conf); BaseStatistics stats = format.getStatistics(null); final int maxNumLines = (int) Math.ceil(TOTAL_SIZE / ((double) Math.min(TEST_DATA_1_LINEWIDTH, TEST_DATA_2_LINEWIDTH))); final int minNumLines = (int) (TOTAL_SIZE / ((double) Math.max(TEST_DATA_1_LINEWIDTH, TEST_DATA_2_LINEWIDTH))); final float maxAvgWidth = ((float) (TOTAL_SIZE)) / minNumLines; final float minAvgWidth = ((float) (TOTAL_SIZE)) / maxNumLines; if (!(stats.getNumberOfRecords() <= maxNumLines & stats.getNumberOfRecords() >= minNumLines)) { System.err.println("Records: " + stats.getNumberOfRecords() + " out of (" + minNumLines + ", " + maxNumLines + ")."); Assert.fail("Wrong record count."); } if (!(stats.getAverageRecordWidth() <= maxAvgWidth & stats.getAverageRecordWidth() >= minAvgWidth)) { Assert.fail("Wrong avg record size."); } } catch (Exception e) { e.printStackTrace(); Assert.fail(e.getMessage()); } }
Example 2
Source File: DelimitedInputFormatSamplingTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testSamplingDirectory() { try { final String tempFile = TestFileUtils.createTempFileDir(testTempFolder, TEST_DATA1, TEST_DATA2); final Configuration conf = new Configuration(); final TestDelimitedInputFormat format = new TestDelimitedInputFormat(CONFIG); format.setFilePath(tempFile); format.configure(conf); BaseStatistics stats = format.getStatistics(null); final int maxNumLines = (int) Math.ceil(TOTAL_SIZE / ((double) Math.min(TEST_DATA_1_LINEWIDTH, TEST_DATA_2_LINEWIDTH))); final int minNumLines = (int) (TOTAL_SIZE / ((double) Math.max(TEST_DATA_1_LINEWIDTH, TEST_DATA_2_LINEWIDTH))); final float maxAvgWidth = ((float) (TOTAL_SIZE)) / minNumLines; final float minAvgWidth = ((float) (TOTAL_SIZE)) / maxNumLines; if (!(stats.getNumberOfRecords() <= maxNumLines & stats.getNumberOfRecords() >= minNumLines)) { System.err.println("Records: " + stats.getNumberOfRecords() + " out of (" + minNumLines + ", " + maxNumLines + ")."); Assert.fail("Wrong record count."); } if (!(stats.getAverageRecordWidth() <= maxAvgWidth & stats.getAverageRecordWidth() >= minAvgWidth)) { Assert.fail("Wrong avg record size."); } } catch (Exception e) { e.printStackTrace(); Assert.fail(e.getMessage()); } }
Example 3
Source File: DelimitedInputFormatSamplingTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testSamplingDirectory() { try { final String tempFile = TestFileUtils.createTempFileDir(testTempFolder, TEST_DATA1, TEST_DATA2); final Configuration conf = new Configuration(); final TestDelimitedInputFormat format = new TestDelimitedInputFormat(CONFIG); format.setFilePath(tempFile); format.configure(conf); BaseStatistics stats = format.getStatistics(null); final int maxNumLines = (int) Math.ceil(TOTAL_SIZE / ((double) Math.min(TEST_DATA_1_LINEWIDTH, TEST_DATA_2_LINEWIDTH))); final int minNumLines = (int) (TOTAL_SIZE / ((double) Math.max(TEST_DATA_1_LINEWIDTH, TEST_DATA_2_LINEWIDTH))); final float maxAvgWidth = ((float) (TOTAL_SIZE)) / minNumLines; final float minAvgWidth = ((float) (TOTAL_SIZE)) / maxNumLines; if (!(stats.getNumberOfRecords() <= maxNumLines & stats.getNumberOfRecords() >= minNumLines)) { System.err.println("Records: " + stats.getNumberOfRecords() + " out of (" + minNumLines + ", " + maxNumLines + ")."); Assert.fail("Wrong record count."); } if (!(stats.getAverageRecordWidth() <= maxAvgWidth & stats.getAverageRecordWidth() >= minAvgWidth)) { Assert.fail("Wrong avg record size."); } } catch (Exception e) { e.printStackTrace(); Assert.fail(e.getMessage()); } }