forked from parquet-go/parquet-go
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added levelled buffers Signed-off-by: Joe Elliott <[email protected]> * remove debug log Signed-off-by: Joe Elliott <[email protected]> * align to the pool size to reduce waste Signed-off-by: Joe Elliott <[email protected]> * ^ is xor :) Signed-off-by: Joe Elliott <[email protected]> * review Signed-off-by: Joe Elliott <[email protected]> * removed reset and resize. added comments Signed-off-by: Joe Elliott <[email protected]> * remove clone Signed-off-by: Joe Elliott <[email protected]> * try 32 Signed-off-by: Joe Elliott <[email protected]> * catch buffer too small Signed-off-by: Joe Elliott <[email protected]> * use numValues Signed-off-by: Joe Elliott <[email protected]> * internal test Signed-off-by: Joe Elliott <[email protected]> Signed-off-by: Joe Elliott <[email protected]>
- Loading branch information
1 parent
0309c7d
commit 948ea8c
Showing
4 changed files
with
120 additions
and
49 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package parquet | ||
|
||
import ( | ||
"math" | ||
"math/rand" | ||
"testing" | ||
) | ||
|
||
func TestBufferAlwaysCorrectSize(t *testing.T) { | ||
var p bufferPool | ||
for i := 0; i < 1000; i++ { | ||
sz := rand.Intn(1024 * 1024) | ||
buff := p.get(sz) | ||
if len(buff.data) != sz { | ||
t.Errorf("Expected buffer of size %d, got %d", sz, len(buff.data)) | ||
} | ||
p.put(buff) | ||
} | ||
} | ||
|
||
func TestLevelledPoolIndex(t *testing.T) { | ||
tcs := []struct { | ||
sz int | ||
expected int | ||
}{ | ||
{ | ||
sz: 1023, | ||
expected: 0, | ||
}, | ||
{ | ||
sz: 1024, | ||
expected: 1, | ||
}, | ||
{ | ||
sz: -1, | ||
expected: 0, | ||
}, | ||
{ | ||
sz: 16*1024*1024 - 1, | ||
expected: 14, | ||
}, | ||
{ | ||
sz: 16 * 1024 * 1024, | ||
expected: 15, | ||
}, | ||
{ | ||
sz: math.MaxInt, | ||
expected: 15, | ||
}, | ||
} | ||
|
||
for _, tc := range tcs { | ||
if actual := levelledPoolIndex(tc.sz); actual != tc.expected { | ||
t.Errorf("Expected index %d for size %d, got %d", tc.expected, tc.sz, actual) | ||
} | ||
} | ||
} |
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