-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
GH-3040: DictionaryFilter.canDrop may return false positive result when dict size exceeds 8k #3041
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.apache.parquet.bytes; | ||
|
||
import java.io.ByteArrayInputStream; | ||
|
||
public class AvailableAgnosticInputStream extends ByteArrayInputStream { | ||
|
||
public AvailableAgnosticInputStream(byte[] buf) { | ||
super(buf); | ||
} | ||
|
||
// In practice, there are some implementations always return 0 even if they has more data | ||
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. in my case, the underlying 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. Out of curiosity. Why are you using 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. My test code is
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. Thanks, this is very helpful! |
||
@Override | ||
public synchronized int available() { | ||
return 0; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -140,6 +140,20 @@ public void testFromInputStream() throws IOException { | |
validate(data, factory); | ||
} | ||
|
||
@Test | ||
public void testFromLargeAvailableAgnosticInputStream() throws IOException { | ||
// allocate a bytes that large than | ||
// java.nio.channel.Channels.ReadableByteChannelImpl.TRANSFER_SIZE = 8192 | ||
byte[] data = new byte[9 * 1024]; | ||
RANDOM.nextBytes(data); | ||
byte[] input = new byte[data.length + 10]; | ||
RANDOM.nextBytes(input); | ||
System.arraycopy(data, 0, input, 0, data.length); | ||
Supplier<BytesInput> factory = () -> BytesInput.from(new AvailableAgnosticInputStream(input), 9 * 1024); | ||
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. What about using an anonymous class here instead of adding a new file? 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 tend to use a new file as it is a quite common case that needs to be tested, it might be used in other places in the future. |
||
|
||
validate(data, factory); | ||
} | ||
|
||
@Test | ||
public void testFromByteArrayOutputStream() throws IOException { | ||
byte[] data = new byte[1000]; | ||
|
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.
Is there any other place that is used like this?
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.
I went through the original PR and found nothing else, it would be great if others have a double check.