---
name: "Catmandu::DirectoryIndex::Number"
section: "3pm"
platform: "linux"
package: "libcatmandu-filestore-perl"
version: "1.16-3"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/Catmandu::DirectoryIndex::Number"
---

# Catmandu::DirectoryIndex::Number(3pm)

A natural number based directory translator

## NAME

Catmandu::DirectoryIndex::Number - A natural number based directory translator

## SYNOPSIS

```
    use Catmandu::DirectoryIndex::Number;
    my $p = Catmandu::DirectoryIndex::Number->new(
        base_dir => "/data",
        keysize => 9
    );
    # get mapping for id: { _id => 1234, _path => "/data/000/001/234" }
    # can be undef
    my $mapping = $p->get(1234);
    # create mapping for id. Path created if necessary
    my $mapping = $p->add(1234);
    # Catmandu::DirectoryIndex::Number is a Catmandu::Iterable
    # Returns list of records: [{ _id => "000001234", _path => "/data/000/001/234" }]
    my $mappings = $p->to_array();
```

## METHODS

### new( base\_dir =\> $base\_dir , keysize =\> NUM )

Create a new Catmandu::DirectoryIndex::Number with the following configuration parameters:

- base\_dir

  See Catmandu::DirectoryIndex

- keysize

  By default the directory structure is 3 levels deep. With the keysize option a deeper nesting can be created. The keysize needs to be a multiple of 3.

## LIMITATIONS

The keys in this directory can only be natural numbers 0,1,2 ...

## INHERITED METHODS

This Catmandu::DirectoryIndex::Number implements:

- Catmandu::DirectoryIndex

  ## SEE ALSO

Catmandu::DirectoryIndex
