apple/turicreate

Inefficient implementation on checking if path is a s3 directory

开放

#3,049 创建于 2020年3月14日

 (0 条评论) (0 个反应) (0 位负责人)C++ (1,161 个派生)batch import
S3good first issue

仓库指标

星标
 (11,135 个星标)
PR 合并指标
 (30 天内没有已合并 PR)

描述

our current implementation of s3 is_directory is to exhaust all keys under a certain URL (a.k.a, prefix, "folder" or "group") and compare the URL with each item returned, e.g., Contents[Key] and CommonPrefixes. This is a bad practice if the URL contains many keys and the comparison is linear O(n).

Besides that, is_directory is widely used in our codebase, not to mention the time complexity, the network delay will be observable.

A solution should be,

  • head on URL assuming it's an object. If 404, then
  • list-objects --with-delimiter and --max-items=1, and check the CommonPrefixes section. You can provide an extra parameter to tell list_objects_impl to do so by setting the max keys to return.

贡献者指南