Skip to content

Commit

Permalink
append with flush
Browse files Browse the repository at this point in the history
  • Loading branch information
tanyasethi-msft committed Jan 12, 2024
1 parent c10d3f8 commit cef53c7
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
2 changes: 1 addition & 1 deletion sdk/storage/azdatalake/assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "go",
"TagPrefix": "go/storage/azdatalake",
"Tag": "go/storage/azdatalake_3ae5e1441b"
"Tag": "go/storage/azdatalake_7a31b2404b"
}
34 changes: 34 additions & 0 deletions sdk/storage/azdatalake/file/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3419,6 +3419,40 @@ func (s *RecordedTestSuite) TestDownloadDataContentMD5() {
_require.Equal(resp1.ContentMD5, mdf[:])
}

func (s *RecordedTestSuite) TestFileAppendWithFlushOption() {
_require := require.New(s.T())
testName := s.T().Name()

filesystemName := testcommon.GenerateFileSystemName(testName)
fsClient, err := testcommon.GetFileSystemClient(filesystemName, s.T(), testcommon.TestAccountDatalake, nil)
_require.NoError(err)
defer testcommon.DeleteFileSystem(context.Background(), _require, fsClient)

_, err = fsClient.Create(context.Background(), nil)
_require.NoError(err)

srcFileName := "src" + testcommon.GenerateFileName(testName)

srcFClient, err := testcommon.GetFileClient(filesystemName, srcFileName, s.T(), testcommon.TestAccountDatalake, nil)
_require.NoError(err)

resp, err := srcFClient.Create(context.Background(), nil)
_require.NoError(err)
_require.NotNil(resp)

contentSize := 1024 * 8 // 8KB
rsc, _ := testcommon.GenerateData(contentSize)
opts := &file.AppendDataOptions{
Flush: to.Ptr(true),
}
_, err = srcFClient.AppendData(context.Background(), 0, rsc, opts)
_require.NoError(err)

gResp2, err := srcFClient.GetProperties(context.Background(), nil)
_require.NoError(err)
_require.Equal(*gResp2.ContentLength, int64(contentSize))
}

func (s *RecordedTestSuite) TestFileAppendAndFlushData() {
_require := require.New(s.T())
testName := s.T().Name()
Expand Down
3 changes: 3 additions & 0 deletions sdk/storage/azdatalake/file/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,8 @@ type AppendDataOptions struct {
LeaseAccessConditions *LeaseAccessConditions
// CPKInfo contains optional parameters to perform encryption using customer-provided key.
CPKInfo *CPKInfo
//Flush Optional. If true, the file will be flushed after append.
Flush *bool
}

func (o *AppendDataOptions) format(offset int64, body io.ReadSeekCloser) (*generated.PathClientAppendDataOptions, *generated.LeaseAccessConditions, *generated.CPKInfo, error) {
Expand Down Expand Up @@ -280,6 +282,7 @@ func (o *AppendDataOptions) format(offset int64, body io.ReadSeekCloser) (*gener
cpkInfoOpts.EncryptionKeySHA256 = o.CPKInfo.EncryptionKeySHA256
cpkInfoOpts.EncryptionAlgorithm = o.CPKInfo.EncryptionAlgorithm
}
appendDataOptions.Flush = o.Flush
}
if o != nil && o.TransactionalValidation != nil {
_, err = o.TransactionalValidation.Apply(body, appendDataOptions)
Expand Down

0 comments on commit cef53c7

Please sign in to comment.