Skip to content
This repository has been archived by the owner on Jun 27, 2023. It is now read-only.

Commit

Permalink
make shard width private
Browse files Browse the repository at this point in the history
  • Loading branch information
schomatis committed Oct 15, 2021
1 parent ec4a790 commit 6161095
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions io/directory.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ var log = logging.Logger("unixfs")
// ProtoNode doesn't use the Data field so this estimate is pretty accurate).
var HAMTShardingSize = 0

// DefaultShardWidth is the default value used for hamt sharding width.
// defaultShardWidth is the default value used for hamt sharding width.
// Needs to be a power of two (shard entry size) and multiple of 8 (bitfield size).
var DefaultShardWidth = 256
var defaultShardWidth = 256

// Directory defines a UnixFS directory. It is used for creating, reading and
// editing directories. It allows to work with different directory schemes,
Expand Down Expand Up @@ -597,7 +597,7 @@ func (d *UpgradeableDirectory) AddChild(ctx context.Context, name string, nd ipl
if !switchToHAMT {
return basicDir.AddChild(ctx, name, nd)
}
hamtDir, err = basicDir.SwitchToSharding(ctx, DefaultShardWidth)
hamtDir, err = basicDir.SwitchToSharding(ctx, defaultShardWidth)
if err != nil {
return err
}
Expand Down
8 changes: 4 additions & 4 deletions io/directory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func TestBasicDirectory_estimatedSize(t *testing.T) {

func TestHAMTDirectory_sizeChange(t *testing.T) {
ds := mdtest.Mock()
hamtDir, err := newEmptyHAMTDirectory(ds, DefaultShardWidth)
hamtDir, err := newEmptyHAMTDirectory(ds, defaultShardWidth)
assert.NoError(t, err)

testDirectorySizeEstimation(t, hamtDir, ds, func(dir Directory) int {
Expand Down Expand Up @@ -294,15 +294,15 @@ func TestIntegrityOfDirectorySwitch(t *testing.T) {
assert.NoError(t, err)

basicDir := newEmptyBasicDirectory(ds)
hamtDir, err := newEmptyHAMTDirectory(ds, DefaultShardWidth)
hamtDir, err := newEmptyHAMTDirectory(ds, defaultShardWidth)
assert.NoError(t, err)
for i := 0; i < 1000; i++ {
basicDir.AddChild(ctx, strconv.FormatUint(uint64(i), 10), child)
hamtDir.AddChild(ctx, strconv.FormatUint(uint64(i), 10), child)
}
compareDirectoryEntries(t, basicDir, hamtDir)

hamtDirFromSwitch, err := basicDir.SwitchToSharding(ctx, DefaultShardWidth)
hamtDirFromSwitch, err := basicDir.SwitchToSharding(ctx, defaultShardWidth)
assert.NoError(t, err)
basicDirFromSwitch, err := hamtDir.switchToBasic(ctx)
assert.NoError(t, err)
Expand Down Expand Up @@ -349,7 +349,7 @@ func TestHAMTEnumerationWhenComputingSize(t *testing.T) {
// How many leaf shards nodes (with value links,
// i.e., directory entries) do we need to reach the threshold.
thresholdToWidthRatio := 4
// Departing from DefaultShardWidth of 256 to reduce HAMT size in
// Departing from defaultShardWidth of 256 to reduce HAMT size in
// CreateCompleteHAMT.
// FIXME: Review number.
shardWidth := 16
Expand Down

0 comments on commit 6161095

Please sign in to comment.