从Azure Data Lake Gen 2删除未刷新的文件

从Azure Data Lake Gen 2删除未刷新的文件,azure,azure-data-lake,azure-data-lake-gen2,Azure,Azure Data Lake,Azure Data Lake Gen2,要先将文件上载到ADL,您需要: 使用?resource=file参数执行put请求(这将在ADL上创建一个文件) 使用?action=append&position=参数将数据追加到文件中 最后,您需要使用?action=flush&position= 我的问题是: 有没有办法告诉服务器,如果数据没有被刷新(写入),数据应该存在多长时间。 由于您需要先创建一个文件来将数据写入其中,因此可能会出现刷新不发生的情况,并且您会被数据池中的一个空文件卡住 我在网上找不到关于这件事的任何消息 欢迎提

要先将文件上载到ADL,您需要:

  • 使用
    ?resource=file
    参数执行put请求(这将在ADL上创建一个文件)
  • 使用
    ?action=append&position=
    参数将数据追加到文件中
  • 最后,您需要使用
    ?action=flush&position=
我的问题是:

有没有办法告诉服务器,如果数据没有被刷新(写入),数据应该存在多长时间。

由于您需要先创建一个文件来将数据写入其中,因此可能会出现刷新不发生的情况,并且您会被数据池中的一个空文件卡住

我在网上找不到关于这件事的任何消息


欢迎提供任何信息。

更新0219:

如果只调用
附加api
,而不调用
刷新api
,则未提交的数据将在7天内保存在azure中

未提交的数据将在7天后自动删除,并且无法从您的终端删除


原文:

Azure Datalake Storage Gen2的SDK已经准备就绪,您可以使用它比使用rest api更轻松地操作ADLS Gen2

如果您使用的是.NET/c#,那么Azure Datalake Storage Gen2有一个SDK:

下面是如何使用此SDK操作ADLS Gen2的官方文档,下面的c代码用于删除ADLS Gen2的文件/上传文件:

        static void Main(string[] args)
        {
            string accountName = "xxx";
            string accountKey = "xxx";

            StorageSharedKeyCredential sharedKeyCredential =
        new StorageSharedKeyCredential(accountName, accountKey);

            string dfsUri = "https://" + accountName + ".dfs.core.windows.net";

            DataLakeServiceClient dataLakeServiceClient = new DataLakeServiceClient
                (new Uri(dfsUri), sharedKeyCredential);

            DataLakeFileSystemClient fileSystemClient = dataLakeServiceClient.GetFileSystemClient("w22");
            DataLakeDirectoryClient directoryClient = fileSystemClient.GetDirectoryClient("t2");

            // use this line of code to delete a file
            //directoryClient.DeleteFile("22.txt");


            //use the code below to upload a file
            //DataLakeFileClient fileClient = directoryClient.CreateFile("22.txt");
            //FileStream fileStream = File.OpenRead("d:\\foo2.txt");

            //long fileSize = fileStream.Length;
            //fileClient.Append(fileStream, offset: 0);
            //fileClient.Flush(position: fileSize);

            Console.WriteLine("**completed**");
            Console.ReadLine();
        }
对于Java,请参考以下内容


有关Python,请参阅此。

更新的0219:

如果只调用
附加api
,而不调用
刷新api
,则未提交的数据将在7天内保存在azure中

未提交的数据将在7天后自动删除,并且无法从您的终端删除


原文:

Azure Datalake Storage Gen2的SDK已经准备就绪,您可以使用它比使用rest api更轻松地操作ADLS Gen2

如果您使用的是.NET/c#,那么Azure Datalake Storage Gen2有一个SDK:

下面是如何使用此SDK操作ADLS Gen2的官方文档,下面的c代码用于删除ADLS Gen2的文件/上传文件:

        static void Main(string[] args)
        {
            string accountName = "xxx";
            string accountKey = "xxx";

            StorageSharedKeyCredential sharedKeyCredential =
        new StorageSharedKeyCredential(accountName, accountKey);

            string dfsUri = "https://" + accountName + ".dfs.core.windows.net";

            DataLakeServiceClient dataLakeServiceClient = new DataLakeServiceClient
                (new Uri(dfsUri), sharedKeyCredential);

            DataLakeFileSystemClient fileSystemClient = dataLakeServiceClient.GetFileSystemClient("w22");
            DataLakeDirectoryClient directoryClient = fileSystemClient.GetDirectoryClient("t2");

            // use this line of code to delete a file
            //directoryClient.DeleteFile("22.txt");


            //use the code below to upload a file
            //DataLakeFileClient fileClient = directoryClient.CreateFile("22.txt");
            //FileStream fileStream = File.OpenRead("d:\\foo2.txt");

            //long fileSize = fileStream.Length;
            //fileClient.Append(fileStream, offset: 0);
            //fileClient.Flush(position: fileSize);

            Console.WriteLine("**completed**");
            Console.ReadLine();
        }
对于Java,请参考以下内容


对于Python,请参考此内容。

我的问题不是如何上传文件,我已经可以这样做了。我需要更多关于未刷新文件的情况以及如何删除它们的信息。@3Jumph,好的。我想确认一下,您想知道未提交的数据(通过追加操作)在azure中会存在多长时间?以及如何删除未提交的数据(而不是空文件)?Young是的,我对数据发生了什么很感兴趣。我还想知道,如果文件未刷新,是否有方法删除该文件(RESTAPI删除操作除外)。我希望这事能澄清up@3Jumph,我已更新我的答案。如果你还有更多问题,请告诉我:)你能告诉我信息的来源吗?我的问题不是如何上传文件,我已经可以上传了。我需要更多关于未刷新文件的情况以及如何删除它们的信息。@3Jumph,好的。我想确认一下,您想知道未提交的数据(通过追加操作)在azure中会存在多长时间?以及如何删除未提交的数据(而不是空文件)?Young是的,我对数据发生了什么很感兴趣。我还想知道,如果文件未刷新,是否有方法删除该文件(RESTAPI删除操作除外)。我希望这事能澄清up@3Jumph,我已更新我的答案。如果你还有更多问题,请告诉我:)你能告诉我信息的来源吗?在那之后我再也不需要别的了。