Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ConvMap<K, V>

Implementation of IMap that converts keys and values to 'parsed' representations using the given TypeConversion.

Type parameters

  • K

  • V

Hierarchy

  • ConvMap

Implements

Index

Constructors

  • Construct a new instance operating on the given map.

    Type parameters

    • K

    • V

    Parameters

    Returns ConvMap<K, V>

Accessors

Methods

  • [iterator](): IterableIterator<[K, V]>
  • clear(start?: K): void
  • Convenience function. Non-atomically iterates over the map's entries, deleting them.

    Note: For kernels older than 4.12, a start key must be passed. See keys.

    This is a wrapper around keys and delete.

    Parameters

    • Optional start: K

    Returns void

  • consumeEntries(start?: K): IterableIterator<[K, V]>
  • Convenience function. Non-atomically iterates through the map's entries, deleting them while iterating.

    This is a wrapper around keys and getDelete.

    Parameters

    • Optional start: K

    Returns IterableIterator<[K, V]>

  • delete(key: K): boolean
  • Delete a single map entry.

    Returns true if an entry was found and deleted, false otherwise.

    Parameters

    • key: K

    Returns boolean

  • deleteBatch(keys: K[]): void
  • Perform delete operation on the passed entries.

    Since Linux 5.6.

    Unlike in delete, an entry isn't found, ENOENT will be thrown and no more entries will be processed.

    Note that if an error is thrown, part of the entries could already have been processed. The thrown error includes a count field that, if not undefined, corresponds to the amount of processed entries.

    Parameters

    • keys: K[]

    Returns void

  • entries(start?: K): IterableIterator<[K, V]>
  • Convenience function. Non-atomically iterates through the map's entries. Gets the next key before yielding the current one, making it suitable for deleting entries while iterating.

    Note: For kernels older than 4.12, a start key must be passed. See keys.

    This is a wrapper around keys and get.

    Parameters

    • Optional start: K

    Returns IterableIterator<[K, V]>

  • freeze(): void
  • Freezes the map, making it non-modifiable from userspace. The map stays writeable from BPF side.

    Since Linux 5.2.

    Returns void

  • get(key: K, flags?: number): undefined | V
  • Fetch the value for a single key.

    Parameters

    • key: K
    • Optional flags: number

    Returns undefined | V

    Entry value, or undefined if no such entry exists

  • getBatch(batchSize: number, flags?: number): IterableIterator<[K, V][]>
  • Iterate through the map entries.

    This works like entries but the iteration is performed in the kernel, returning many items at once. The interator yields each batch produced by the kernel, until an error is found or there are no more entries.

    batchSize specifies the requested size, but batches may be smaller. If the kernel returns a partial batch together with an error, the partial batch will be yielded before throwing the error. If the map is empty, nothing is yielded.

    Since Linux 5.6.

    Parameters

    • batchSize: number
    • Optional flags: number

    Returns IterableIterator<[K, V][]>

  • getDelete(key: K): undefined | V
  • Atomically deletes an entry and returns its former value, or undefined if no entry was found. This operation is generally implemented only for stack / queue types.

    Since Linux 4.20. Most map types probably won't implement this operation.

    Parameters

    • key: K

    Returns undefined | V

  • has(key: K): boolean
  • Convenience function. Tests if the map has an entry.

    Parameters

    • key: K

    Returns boolean

  • keys(start?: K): Generator<K, undefined, unknown>
  • Non-atomically iterates through the map's keys, starting by the key immediately following the passed one. If no key isn't passed or it doesn't exist, iteration starts by the first key in the map.

    Note: Not passing a key is only supported on kernels 4.12 and above.

    Because this calls BPF_MAP_GET_NEXT_KEY repeatedly, if the map's keys are deleted while it's being iterated (by this or another program), iteration could restart to the beginning. However, this method fetches the next key before yielding the current one, making it safe to delete the current key (and any past ones).

    Keep in mind that the order of keys depends on the type of map, and isn't necessarily guaranteed to be consistent.

    Parameters

    • Optional start: K

    Returns Generator<K, undefined, unknown>

  • set(key: K, value: V, flags?: number): ConvMap<K, V>
  • setBatch(entries: [K, V][], flags?: number): ConvMap<K, V>
  • Perform set operation on the passed entries.

    Since Linux 5.6.

    Note that if an error is thrown, part of the entries could already have been processed. The thrown error includes a count field that, if not undefined, corresponds to the amount of processed entries.

    Parameters

    • entries: [K, V][]
    • Optional flags: number

    Returns ConvMap<K, V>

  • values(start?: K): IterableIterator<V>
  • Convenience function. Non-atomically iterates through the map's values.

    Note: For kernels older than 4.12, a start key must be passed. See keys.

    This is a wrapper around keys and get.

    Parameters

    • Optional start: K

    Returns IterableIterator<V>

Generated using TypeDoc