-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't use CapacityByteArrayOutputStream for writing page chunks
- Loading branch information
1 parent
6a20e8b
commit 8b54667
Showing
12 changed files
with
81 additions
and
23 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
48 changes: 48 additions & 0 deletions
48
parquet-encoding/src/main/java/parquet/bytes/ConcatenatingByteArrayCollector.java
This file contains 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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package parquet.bytes; | ||
|
||
import java.io.IOException; | ||
import java.io.OutputStream; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import static java.lang.String.format; | ||
|
||
public class ConcatenatingByteArrayCollector extends BytesInput { | ||
private final List<byte[]> slabs = new ArrayList<byte[]>(); | ||
private long size = 0; | ||
|
||
public void collect(BytesInput bytes) throws IOException { | ||
collect(bytes.toByteArray()); | ||
} | ||
|
||
public void collect(byte[] bytes) { | ||
slabs.add(bytes); | ||
size += bytes.length; | ||
} | ||
|
||
public void reset() { | ||
size = 0; | ||
slabs.clear(); | ||
} | ||
|
||
@Override | ||
public void writeAllTo(OutputStream out) throws IOException { | ||
for (byte[] slab : slabs) { | ||
out.write(slab); | ||
} | ||
} | ||
|
||
@Override | ||
public long size() { | ||
return size; | ||
} | ||
|
||
/** | ||
* @param prefix a prefix to be used for every new line in the string | ||
* @return a text representation of the memory usage of this structure | ||
*/ | ||
public String memUsageString(String prefix) { | ||
return format("%s %s %d slabs, %,d bytes", prefix, getClass().getSimpleName(), slabs.size(), size); | ||
} | ||
|
||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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