Superls.MergedIndex (superls v1.2.3)

View Source
iex> mi = Superls.Store.get_merged_index_from_store("test", "" = _passwd)
`[{"/media/vol1",
   %{
     "ACTION" => %{
       "filename1 ACTION" => %{
         size: 0,
         atime: 1_742_806_274,
         mtime: 1_742_806_274
       },
       "filename2 ACTION" => %{
         size: 0,
         atime: 1_742_806_274,
        mtime: 1_742_806_274
       }
     },
     "filename1" => %{
       "filename1 ACTION" => %{
        size: 0,
        atime: 1_742_806_274,
        mtime: 1_742_806_274
      }
     },
     "filename2" => %{
       "filename2 ACTION" => %{
         size: 0,
         atime: 1_742_806_274,
         mtime: 1_742_806_274
       }
     }
   }},
 {"/media/vol2 ⭐️",
   %{
     "JAZZ" => %{
       "filename3 JAZZ" => %{
         size: 0,
         atime: 1_742_806_274,
         mtime: 1_742_806_274
      }
    },
     "filename3" => %{
        "filename3 JAZZ" => %{
          size: 0,
          atime: 1_742_806_274,
          mtime: 1_742_806_274
     }
    }
  }}]`

This sample shows a merged index from 2 volumes, /media/vol1 and /media/vol2 ⭐️.

Each index holds a map of tags.

Last, each tag references all files that contain the tag.

This merged index is stored encrypted or not on the local filesystem.

Summary

Functions

Returns a list of files referenced by the merged index tags by volume.

Returns a volume-flattened files list.

Count the tags

return the metrics as a map restricted to limit_tags_count most used tags.

Returns a list of files sorted by the oldness cmd from the date date and limited in size by ndays.

Returns a list of files sorted by the oldness cmd from the date date and limited in size by ndays.

Returns a map containing best jaro distances as a numerical key and their associated matching files.

Returns a list of files sorted by the oldness cmd and limited in size by nentries.

Returns a sorted list of files with similar size.

Return a map of {tag => count}.

Types

file_entry()

@type file_entry() :: %{size: integer(), atime: integer(), mtime: integer()}

file_name()

@type file_name() :: Path.t()

relative_path()

@type relative_path() :: Path.t()

t()

@opaque t()

tag()

@type tag() :: String.t()

tag_entry()

@type tag_entry() :: %{required(file_name()) => file_entry()}

tags()

@type tags() :: %{required(tag()) => tag_entry()}

vol_tags()

@opaque vol_tags()

volume()

@type volume() :: String.t()

Functions

files_index_from_tags(mi, prefix_tag? \\ true)

@spec files_index_from_tags(t(), boolean()) :: [
  [{volume(), %{required(file_name()) => map()}}]
]

Returns a list of files referenced by the merged index tags by volume.

flatten_files_vol(files_vol)

@spec flatten_files_vol(files_vol :: [{volume(), %{required(file_name()) => map()}}]) ::
  [
    {file_name(), map()}
  ]

Returns a volume-flattened files list.

get_num_tags(mi)

@spec get_num_tags(t()) :: count :: integer()

Count the tags

metrics(mi, limit_tags_count \\ 500)

@spec metrics(t(), limit_tags_count :: integer()) :: %{
  num_tags: integer(),
  num_files: integer(),
  files: [file_name()],
  num_tags: integer(),
  tags: [tag()],
  most_frequent: String.t()
}

return the metrics as a map restricted to limit_tags_count most used tags.

search_bydate(mi, cmd, date, ndays)

@spec search_bydate(t(), cmd :: String.t(), date :: Date.t(), ndays :: integer()) :: [
  {file_name(), map()}
]

Returns a list of files sorted by the oldness cmd from the date date and limited in size by ndays.

  iex> mi |> MergedIndex.search_bydate("xo", "10.03.31", 50)
  [..]

search_bytag(mi, tags_string)

@spec search_bytag(t(), tags_string :: String.t()) :: term()

Returns a list of files sorted by the oldness cmd from the date date and limited in size by ndays.

  iex> mi |> MergedIndex.search_bydate("xo", "10.03.31", 50)
  [..]

search_duplicated_tags(mi)

@spec search_duplicated_tags(t()) :: %{
  required(jaro :: float()) => [{file1 :: tuple(), file2 :: tuple()}]
}

Returns a map containing best jaro distances as a numerical key and their associated matching files.

search_oldness(mi, cmd, nentries)

@spec search_oldness(t(), cmd :: String.t(), nentries :: integer()) :: [
  {file_name(), file_attr_tags :: map(), volume()}
]

Returns a list of files sorted by the oldness cmd and limited in size by nentries.

  iex> mi |> MergedIndex.search_oldness("xo", 50)
  [..]

search_similar_size(mi)

@spec search_similar_size(t()) :: [
  {size :: integer(), [{file_name(), file_attr_tags :: map()}]}
]

Returns a sorted list of files with similar size.

tag_freq(mi)

@spec tag_freq(t()) :: %{required(tag()) => occurence :: integer()}

Return a map of {tag => count}.