如何枚举 Data Lake Store 中的文件子集?

How to enumerate a subset of files in Data Lake Store?

我在 Data Lake Store 中存储了大量文件 - 我现在需要获取 最新 文件。

因为我还没有找到更好的方法,我目前的方法是列出所有文件并查看修改日期。但是,我怀疑在处理大量文件时可能会导致一些问题。 API 有一种限制它的方法,通过调用以下方法:

var statuses = _client.FileSystem.ListFileStatus(_store._dlsAccountName, "/the/path", 2);

这只会给我 2 个文件。但是,它们似乎按字母顺序返回。

有谁知道如何:

如您所述,函数 ListFileStatus 结果未按修改时间排序。我也没有在 Microsoft.Azure.Management.DataLake.Store SDK 中找到列出最新文件的功能。

change the way the list file status returns results?

是的,如FileStatus has modification time 属性,我们可以使用以下代码列出最新文件。

var number = 2;
var statuses = _client.FileSystem.ListFileStatus(_store._dlsAccountName, "/the/path").FileStatuses.FileStatus.ToList().OrderByDescending(x=>x.ModificationTime).Take(number);

我自己测试过,它工作正常。