private static void assertClosedRetainedSizes(OrcRecordReader reader) { assertEquals(reader.getCurrentStripeRetainedSizeInBytes(), 0); // after close() we still account for the StreamReader instance sizes. assertGreaterThan(reader.getStreamReaderRetainedSizeInBytes(), 0L); // after close() we still account for the StreamReader instance sizes. assertGreaterThan(reader.getRetainedSizeInBytes(), 0L); assertEquals(reader.getSystemMemoryUsage(), 0); } }
@Test public void testOrdering() { Iterator<StandardErrorCode> iterator = asList(StandardErrorCode.values()).iterator(); assertTrue(iterator.hasNext()); int previous = code(iterator.next()); while (iterator.hasNext()) { StandardErrorCode code = iterator.next(); int current = code(code); assertGreaterThan(current, previous, "Code is out of order: " + code); if ((code != GENERIC_INTERNAL_ERROR) && (code != GENERIC_INSUFFICIENT_RESOURCES)) { assertEquals(current, previous + 1, "Code is not sequential: " + code); } previous = current; } }
private static void assertInitialRetainedSizes(OrcRecordReader reader, int rows) { assertEquals(reader.getReaderRowCount(), rows); assertEquals(reader.getReaderPosition(), 0); assertEquals(reader.getCurrentStripeRetainedSizeInBytes(), 0); // there will be object overheads assertGreaterThan(reader.getStreamReaderRetainedSizeInBytes(), 0L); // there will be object overheads assertGreaterThan(reader.getRetainedSizeInBytes(), 0L); assertEquals(reader.getSystemMemoryUsage(), 0); }
@Test public void testSplitPage() { int positionCount = 10; int maxPageSizeInBytes = 100; List<Type> types = ImmutableList.of(BIGINT, BIGINT, BIGINT); Page largePage = createSequencePage(types, positionCount, 0, 1, 1); List<Page> pages = splitPage(largePage, maxPageSizeInBytes); assertGreaterThan(pages.size(), 1); assertPageSize(pages, maxPageSizeInBytes); assertPositionCount(pages, positionCount); MaterializedResult actual = toMaterializedResult(TEST_SESSION, types, pages); MaterializedResult expected = toMaterializedResult(TEST_SESSION, types, ImmutableList.of(largePage)); assertEquals(actual, expected); }
assertGreaterThan(outputPageCount, 3); assertBuilderSize(groupByHash, types, Collections.nCopies(pageCount, 0), Collections.nCopies(rowCount, 0), groupedTopNBuilder.getEstimatedSizeInBytes());
@Test public void pageProcessingDelay() { Session session = testSessionBuilder() .setCatalog("blackhole") .setSchema("default") .build(); Duration pageProcessingDelay = new Duration(1, SECONDS); assertThatQueryReturnsValue( format("CREATE TABLE nation WITH ( %s = 8, %s = 1, %s = 1, %s = 1, %s = '%s' ) AS " + "SELECT * FROM tpch.tiny.nation", FIELD_LENGTH_PROPERTY, ROWS_PER_PAGE_PROPERTY, PAGES_PER_SPLIT_PROPERTY, SPLIT_COUNT_PROPERTY, PAGE_PROCESSING_DELAY, pageProcessingDelay), 25L, session); Stopwatch stopwatch = Stopwatch.createStarted(); assertEquals(queryRunner.execute(session, "SELECT * FROM nation").getRowCount(), 1); queryRunner.execute(session, "INSERT INTO nation SELECT CAST(null AS BIGINT), CAST(null AS VARCHAR(25)), CAST(null AS BIGINT), CAST(null AS VARCHAR(152))"); stopwatch.stop(); assertGreaterThan(stopwatch.elapsed(MILLISECONDS), pageProcessingDelay.toMillis()); assertThatQueryReturnsValue("DROP TABLE nation", true); }
@Test public void testAllFormats() throws Exception { HiveClientConfig config = new HiveClientConfig(); File tempDir = Files.createTempDir(); try { ExtendedHiveMetastore metastore = createTestingFileHiveMetastore(new File(tempDir, "metastore")); for (HiveStorageFormat format : HiveStorageFormat.values()) { config.setHiveStorageFormat(format); config.setHiveCompressionCodec(NONE); long uncompressedLength = writeTestFile(config, metastore, makeFileName(tempDir, config)); assertGreaterThan(uncompressedLength, 0L); for (HiveCompressionCodec codec : HiveCompressionCodec.values()) { if (codec == NONE) { continue; } config.setHiveCompressionCodec(codec); long length = writeTestFile(config, metastore, makeFileName(tempDir, config)); assertTrue(uncompressedLength > length, format("%s with %s compressed to %s which is not less than %s", format, codec, length, uncompressedLength)); } } } finally { deleteRecursively(tempDir.toPath(), ALLOW_INSECURE); } }
@Test private void testSplitPageNonDecreasingPageSize() { int positionCount = 100; int maxPageSizeInBytes = 1; List<Type> types = ImmutableList.of(VARCHAR); Slice expectedValue = wrappedBuffer("test".getBytes()); BlockBuilder blockBuilder = VARCHAR.createBlockBuilder(null, 1, expectedValue.length()); blockBuilder.writeBytes(expectedValue, 0, expectedValue.length()).closeEntry(); Block rleBlock = new RunLengthEncodedBlock(blockBuilder.build(), positionCount); Page initialPage = new Page(rleBlock); List<Page> pages = splitPage(initialPage, maxPageSizeInBytes); // the page should only be split in half as the recursion should terminate // after seeing that the size of the Page doesn't decrease assertEquals(pages.size(), 2); Page first = pages.get(0); Page second = pages.get(1); // the size of the pages will remain the same and should be greater than the maxPageSizeInBytes assertGreaterThan((int) first.getSizeInBytes(), maxPageSizeInBytes); assertGreaterThan((int) second.getSizeInBytes(), maxPageSizeInBytes); assertPositionCount(pages, positionCount); MaterializedResult actual = toMaterializedResult(TEST_SESSION, types, pages); MaterializedResult expected = toMaterializedResult(TEST_SESSION, types, ImmutableList.of(initialPage)); assertEquals(actual, expected); } }
int upperBound = binomial.inverseCumulativeProbability(0.999999); assertLessThan(foo, upperBound); assertGreaterThan(foo, lowerBound); upperBound = binomial.inverseCumulativeProbability(0.999999); assertLessThan(foo, upperBound); assertGreaterThan(foo, lowerBound);
assertGreaterThan(reader.getCurrentStripeRetainedSizeInBytes(), stripeReaderRetainedSize); assertGreaterThan(reader.getRetainedSizeInBytes() - readerRetainedSize, 0L); assertGreaterThan(reader.getSystemMemoryUsage() - readerSystemMemoryUsage, 0L);
assertGreaterThan(reader.getCurrentStripeRetainedSizeInBytes(), stripeReaderRetainedSize); assertGreaterThan(reader.getRetainedSizeInBytes() - readerRetainedSize, 0L); assertGreaterThan(reader.getSystemMemoryUsage() - readerSystemMemoryUsage, 0L);
assertEquals(statistics.getRowCount().getAsLong(), CREATE_TABLE_DATA.getRowCount()); assertEquals(statistics.getFileCount().getAsLong(), 1L); assertGreaterThan(statistics.getInMemoryDataSizeInBytes().getAsLong(), 0L); assertGreaterThan(statistics.getOnDiskDataSizeInBytes().getAsLong(), 0L);
assertEquals(partitionStatistics.getRowCount().getAsLong(), 1L); assertEquals(partitionStatistics.getFileCount().getAsLong(), 1L); assertGreaterThan(partitionStatistics.getInMemoryDataSizeInBytes().getAsLong(), 0L); assertGreaterThan(partitionStatistics.getOnDiskDataSizeInBytes().getAsLong(), 0L);
assertGreaterThan(reader.getCurrentStripeRetainedSizeInBytes(), stripeReaderRetainedSize); assertGreaterThan(reader.getRetainedSizeInBytes() - readerRetainedSize, 0L); assertGreaterThan(reader.getSystemMemoryUsage() - readerSystemMemoryUsage, 0L);
assertEquals(statistics.getRowCount().getAsLong(), i + 1L); assertEquals(statistics.getFileCount().getAsLong(), i + 1L); assertGreaterThan(statistics.getInMemoryDataSizeInBytes().getAsLong(), 0L); assertGreaterThan(statistics.getOnDiskDataSizeInBytes().getAsLong(), 0L);
assertEquals(tableStatistics.getRowCount().getAsLong(), CREATE_TABLE_DATA.getRowCount() * (i + 1)); assertEquals(tableStatistics.getFileCount().getAsLong(), i + 1L); assertGreaterThan(tableStatistics.getInMemoryDataSizeInBytes().getAsLong(), 0L); assertGreaterThan(tableStatistics.getOnDiskDataSizeInBytes().getAsLong(), 0L);
int upperBound = binomial.inverseCumulativeProbability(0.999999); assertLessThan(group2Ran, upperBound); assertGreaterThan(group2Ran, lowerBound);
assertGreaterThan(lowerLevelTime, (higherLevelTime * 2) - 10); assertLessThan(higherLevelTime, (lowerLevelTime * 2) + 10);
assertGreaterThan(getHashCapacity.apply(operator), oldCapacity);
@SuppressWarnings({"unchecked", "rawtypes"}) public void passGreaterThan(Comparable actual, Comparable expected) { assertGreaterThan(actual, expected); assertGreaterThan(actual, expected, MESSAGE); }