-
Notifications
You must be signed in to change notification settings - Fork 1.5k
GH-3267: Add comprehensive assertions to TestMemPageStore #3268
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,11 +20,15 @@ | |
|
|
||
| import static org.apache.parquet.column.Encoding.BIT_PACKED; | ||
| import static org.apache.parquet.column.Encoding.PLAIN; | ||
| import static org.junit.Assert.assertEquals; | ||
| import static org.junit.Assert.assertNotNull; | ||
| import static org.junit.Assert.assertTrue; | ||
|
|
||
| import java.io.IOException; | ||
| import org.apache.parquet.bytes.BytesInput; | ||
| import org.apache.parquet.column.ColumnDescriptor; | ||
| import org.apache.parquet.column.page.DataPage; | ||
| import org.apache.parquet.column.page.DataPageV1; | ||
| import org.apache.parquet.column.page.PageReader; | ||
| import org.apache.parquet.column.page.PageWriter; | ||
| import org.apache.parquet.column.page.mem.MemPageStore; | ||
|
|
@@ -46,19 +50,42 @@ public void test() throws IOException { | |
| ColumnDescriptor col = new ColumnDescriptor(path, PrimitiveTypeName.INT64, 2, 2); | ||
| LongStatistics stats = new LongStatistics(); | ||
| PageWriter pageWriter = memPageStore.getPageWriter(col); | ||
|
|
||
| pageWriter.writePage(BytesInput.from(new byte[735]), 209, stats, BIT_PACKED, BIT_PACKED, PLAIN); | ||
| pageWriter.writePage(BytesInput.from(new byte[743]), 209, stats, BIT_PACKED, BIT_PACKED, PLAIN); | ||
| pageWriter.writePage(BytesInput.from(new byte[743]), 209, stats, BIT_PACKED, BIT_PACKED, PLAIN); | ||
| pageWriter.writePage(BytesInput.from(new byte[735]), 209, stats, BIT_PACKED, BIT_PACKED, PLAIN); | ||
|
|
||
| PageReader pageReader = memPageStore.getPageReader(col); | ||
| long totalValueCount = pageReader.getTotalValueCount(); | ||
| LOG.info(String.valueOf(totalValueCount)); | ||
| LOG.info("Total value count: " + totalValueCount); | ||
|
|
||
| assertEquals("Expected total value count to be 836 (4 pages * 209 values)", 836, totalValueCount); | ||
|
|
||
| int total = 0; | ||
| int pageCount = 0; | ||
| do { | ||
| DataPage readPage = pageReader.readPage(); | ||
|
|
||
| // Assert page was successfully read | ||
| assertNotNull("Page should not be null", readPage); | ||
| // Assert page has expected value count | ||
| assertEquals("Each page should have 209 values", 209, readPage.getValueCount()); | ||
| // Assert encodings when the implementation is DataPageV1 | ||
| assertTrue("Page should be an instance of DataPageV1", readPage instanceof DataPageV1); | ||
| if (readPage instanceof DataPageV1) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd prefer asserting that this is a DataPageV1
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added the assertion thanks |
||
| DataPageV1 v1 = (DataPageV1) readPage; | ||
| assertEquals("Page repetition level encoding should be BIT_PACKED", BIT_PACKED, v1.getRlEncoding()); | ||
| assertEquals("Page definition level encoding should be BIT_PACKED", BIT_PACKED, v1.getDlEncoding()); | ||
| assertEquals("Page value encoding should be PLAIN", PLAIN, v1.getValueEncoding()); | ||
| } | ||
|
|
||
| total += readPage.getValueCount(); | ||
| LOG.info(readPage.toString()); | ||
| // TODO: assert | ||
| pageCount++; | ||
| } while (total < totalValueCount); | ||
|
|
||
| // Assert we read exactly the expected number of pages and values | ||
| assertEquals("Should have read 4 pages", 4, pageCount); | ||
| assertEquals("Total values read should match totalValueCount", totalValueCount, total); | ||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that TestMemPageStore previously tests nothing but merely to prove that methods of MemPageStore are working.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes seems like previously
MemPageStorewas just supposed to test the MemPageStore upper level functionality. Seems thatTestMemColumndoes the actual data and lower level checks