Interface Importer
- All Superinterfaces:
AutoCloseable
,Closeable
Allows to run an import. For performance reasons, imports are run without transactions.
Since import is multi threaded, implementations must be thread-safe.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interface
Interface for processing database records encountered duringwalk(org.opends.server.backends.pluggable.spi.TreeName, java.util.concurrent.Executor, int, org.opends.server.backends.pluggable.spi.Importer.RecordProcessor)
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Clears the tree whose name is provided.void
close()
long
Returns the memory required by this storage to run the import.openCursor
(TreeName treeName) Opens a cursor on the tree whose name is provided.void
put
(TreeName treeName, ByteString key, ByteString value) Creates a record with the provided key and value in the tree identified by the provided name.read
(TreeName treeName, ByteString key) Reads the record's value associated to the provided key, in the tree whose name is provided.void
walk
(TreeName treeName, Executor executor, int parallelism, Importer.RecordProcessor entryProcessor) Walks the tree whose name is provided, and processes each entry with the provided entry processor.
-
Method Details
-
clearTree
Clears the tree whose name is provided. Ensures that an empty tree with the given name exists. If the tree already exists, all the data it contains will be deleted. If not, an empty tree will be created.- Parameters:
treeName
- name of the tree to clear
-
put
Creates a record with the provided key and value in the tree identified by the provided name. At the end of this method, the record is visible byread(TreeName, ByteString)
andopenCursor(TreeName)
methods of this instance. The record is guaranteed to be persisted only afterclose()
.- Parameters:
treeName
- the tree namekey
- the new record's keyvalue
- the new record's value
-
read
Reads the record's value associated to the provided key, in the tree whose name is provided.- Parameters:
treeName
- the tree namekey
- the record's key- Returns:
- the record's value, or
null
if none exists
-
openCursor
Opens a cursor on the tree whose name is provided. Cursors are predictable only if there is no pendingput(TreeName, ByteString, ByteString)
operations. Indeed, once opened, cursors might not reflect changes.- Parameters:
treeName
- the tree name- Returns:
- a new cursor
-
walk
void walk(TreeName treeName, Executor executor, int parallelism, Importer.RecordProcessor entryProcessor) Walks the tree whose name is provided, and processes each entry with the provided entry processor. The iteration is optimized for speed. As such, the order at which entry are processed is undefined and might change between invocations.- Parameters:
treeName
- the tree nameexecutor
- the executor to use for parallel processingparallelism
- the number of parallel walkerentryProcessor
- the entry processor invoked for each entry
-
getRequiredMemory
long getRequiredMemory()Returns the memory required by this storage to run the import. This is an estimation of the memory required to run the import. Includes database cache, temporary buffers, etc.- Returns:
- The memory required by this storage to run the import, in bytes.
-
close
void close()- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-