Repository

class Repository(rootName: String, val fileName: File) : Closeable

A Repository manages a persistent IndexedFile of compiled modules.

**Metadata:**
1. #modules
2. For each module,
2.a. moduleArchive

**ModuleArchive:**
1. UTF8 rootRelativeName
2. digestCache size
3. For each cached digest,
3a. timestamp (long)
3b. digest (32 bytes)
4. #versions
5. For each version,
5a. ModuleVersionKey
5b. ModuleVersion

**ModuleVersionKey:**
1. isPackage (byte)
2. digest (32 bytes)

**ModuleVersion:**
1. moduleSize (long)
2. localImportNames size (int)
3. For each import name,
3a. UTF8 import name
4. entryPoints size (int)
5. For each entry point,
5a. UTF8 entry point name
6. compilations size (int)
7. For each compilation.
7a. ModuleCompilationKey
7b. ModuleCompilation
8. moduleHeaderRecordNumber (long)
9. stacksRecordNumber (long)

**ModuleCompilationKey:**
1. predecessorCompilationTimes length (int)
2. For each predecessor compilation time,
2a. predecessor compilation time (long)

**ModuleCompilation:**
1. compilationTime (long)
2. recordNumber (long) (serialized fast-load information)
3. recordNumberOfBlockPhrases (long) (serialized tuple of phrases)
4. recordNumberOfManifest (long) [ManifestRecord]
5. recordNumberOfStyling (long) [StylingRecord]
6. recordNumberOfPhrasePaths (long) [PhrasePathRecord]
7. recordNumberOfNamesIndex (long) [NamesIndex]

Author

Todd L Smith

Richard Arriaga

Parameters

rootName

The name of the Avail root represented by the Repository.

fileName

The path to the indexed repository.

Throws

IndexedFileException

If an exception occurs.

Constructors

Link copied to clipboard
constructor(rootName: String, fileName: File)

Construct a new Repository.

Types

Link copied to clipboard
object Companion
Link copied to clipboard
class LimitedCache<K, V>(maximumSize: Int) : LinkedHashMap<K, V>

A Map which discards the oldest entry whenever an attempt is made to store more than the maximumSize elements in it.

Properties

Link copied to clipboard

The filename of the IndexedFile.

Functions

Link copied to clipboard
fun add(byteArray: ByteArray): Long

Forward add to the contained IndexedFile.

Link copied to clipboard
fun cleanModulesUnder(rootRelativePath: String)

Remove all compilations of the specified module. If it's a package, remove all compilations of any contained modules.

Link copied to clipboard
fun clear()

Clear the underlying Repository and discard any cached data. Set up the repository for subsequent usage.

Link copied to clipboard
open override fun close()

Close the underlying IndexedFile.

Link copied to clipboard
fun commit()

Write all pending data and metadata to the Repository.

Link copied to clipboard
fun commitIfStaleChanges(maximumChangeAgeMs: Long)

Commit the pending changes if they're more than the specified number of milliseconds old.

Link copied to clipboard
fun createModuleCompilation(compilationTime: Long, serializedBody: ByteArray, serializedBlockPhrases: ByteArray, manifest: ManifestRecord, stylingRecord: StylingRecord, phrasePaths: PhrasePathRecord, namesIndex: NamesIndex): ModuleCompilation

Construct a new ModuleCompilation, adding the serialized compiled module bytes to the repository without committing.

Link copied to clipboard
operator fun get(index: Long): ByteArray

Forward get operation to the contained IndexedFile.

Link copied to clipboard
fun getArchive(rootRelativeName: String): ModuleArchive

Look up the ModuleArchive with the specified name, creating one and adding it to my moduleMap if necessary.

Link copied to clipboard
fun markDirty()

If this repository is not already dirty, mark it as dirty as of now.

Link copied to clipboard

Reopen the IndexedFile and reinitialize the Repository.

Link copied to clipboard
open override fun toString(): String