Interface MetadataSource
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Supplies the parsed footer of a file a reader opens, in place of the reader reading it.
Installed on a context with HardwoodContext.Builder.metadataSource(MetadataSource), the
source is asked for the footer of every file a reader opened against that context reads:
the first file when the reader is opened, and each further file of a multi-file reader
when the reader first needs it.
The source owns acquisition. It returns a footer for every file, and on a miss reads one
with ParsedFooter.readFrom(InputFile):
MetadataSource source = file -> {
ParsedFooter footer = cache.get(key(file));
if (footer == null) {
footer = ParsedFooter.readFrom(file);
cache.put(key(file), footer);
}
return footer;
};
The reader checks every supplied footer against the file before using it, and raises
StaleMetadataException when the footer does not describe the file.
The reader calls footerOf(InputFile) on the thread that opens it for the first file, and on
other threads for the further files of a multi-file read, several at once, so
implementations must be thread-safe. A call blocks the read waiting
on it; a source backed by a remote store keeps an in-process tier in front of it.
-
Method Summary
Modifier and TypeMethodDescriptionThe parsed footer offile.
-
Method Details