Package ucar.unidata.io.zarr
Class RandomAccessDirectory
- java.lang.Object
-
- ucar.unidata.io.RandomAccessFile
-
- ucar.unidata.io.zarr.RandomAccessDirectory
-
- All Implemented Interfaces:
Closeable,DataInput,DataOutput,AutoCloseable,ucar.nc2.util.cache.FileCacheable
public class RandomAccessDirectory extends ucar.unidata.io.RandomAccessFile implements ucar.nc2.util.cache.FileCacheable, Closeable
This class allows a directory structure to be read in memory as a single file. RandomAccessDirectory implemented a tree structure with files as leaves. It is read-only - writes should use the leaf RandomAccessFile write methods
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classRandomAccessDirectory.ProviderHook into service provider interface to RandomAccessFileProvider.
-
Field Summary
Fields Modifier and Type Field Description protected intbufferSizeprotected List<RandomAccessDirectoryItem>children-
Fields inherited from class ucar.unidata.io.RandomAccessFile
allFiles, BIG_ENDIAN, bigEndian, buffer, bufferModified, bufferStart, dataEnd, dataSize, debugAccess, debugLeaks, defaultBufferSize, endOfFile, file, fileChannel, filePosition, LITTLE_ENDIAN, location, openFiles, readonly, showOpen, showRead
-
-
Constructor Summary
Constructors Constructor Description RandomAccessDirectory(String location)RandomAccessDirectory(String location, int bufferSize)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()RandomAccessDirectoryItemgetFileAtPos(int pos)Return the directory item containing the specified positionList<RandomAccessDirectoryItem>getFilesInPath(String path)Find all files in the store that fall under the given pathlonggetLastModified()booleanisDirectory()longlength()protected intread_(long pos, byte[] b, int offset, int len)longreadToByteChannel(WritableByteChannel dest, long offset, long nbytes)protected voidsetFileToPos(long pos)sets current RandomAccessFile to that containing pos saves start position on current RAFvoidwrite(int b)Not implemented - use write methods on the leaf RandomAccessFile e.g.voidwriteBytes(byte[] b, int off, int len)Not implemented - use write methods on the leaf RandomAccessFile e.g.-
Methods inherited from class ucar.unidata.io.RandomAccessFile
acquire, acquire, eject, enableDefaultGlobalFileCache, flush, getAllFiles, getBufferSize, getDebugLeaks, getDebugNbytes, getDebugNseeks, getFilePointer, getGlobalFileCache, getLocation, getMaxOpenFileCount, getOpenFileCount, getOpenFiles, getRandomAccessFile, isAtEndOfFile, order, order, reacquire, read, read, read, readBoolean, readBuffer, readByte, readBytes, readBytes, readChar, readDouble, readDouble, readFloat, readFloat, readFully, readFully, readInt, readInt, readIntUnbuffered, readLine, readLine, readLong, readLong, readShort, readShort, readString, readString, readStringMax, readStringMax, readUnsignedByte, readUnsignedShort, readUTF, release, searchForward, seek, setBufferSize, setDebugAccess, setDebugLeaks, setExtendMode, setFileCache, setGlobalFileCache, setMinLength, shutdown, skipBytes, skipBytes, toString, unread, write, write, writeBoolean, writeBoolean, writeByte, writeBytes, writeBytes, writeChar, writeChar, writeChar, writeChar, writeChar, writeChar, writeChars, writeChars, writeChars, writeDouble, writeDouble, writeDouble, writeDouble, writeDouble, writeDouble, writeFloat, writeFloat, writeFloat, writeFloat, writeFloat, writeFloat, writeInt, writeInt, writeInt, writeInt, writeInt, writeInt, writeLong, writeLong, writeLong, writeLong, writeLong, writeLong, writeShort, writeShort, writeShort, writeShort, writeShort, writeShort, writeUTF
-
-
-
-
Field Detail
-
children
protected List<RandomAccessDirectoryItem> children
-
bufferSize
protected int bufferSize
-
-
Constructor Detail
-
RandomAccessDirectory
public RandomAccessDirectory(String location) throws IOException
- Throws:
IOException
-
RandomAccessDirectory
public RandomAccessDirectory(String location, int bufferSize) throws IOException
- Throws:
IOException
-
-
Method Detail
-
getFileAtPos
public RandomAccessDirectoryItem getFileAtPos(int pos)
Return the directory item containing the specified position- Parameters:
pos-- Returns:
- Directory item containing bytes at `pos`
-
getFilesInPath
public List<RandomAccessDirectoryItem> getFilesInPath(String path) throws IOException
Find all files in the store that fall under the given path- Parameters:
path-- Returns:
- list of files in path
- Throws:
IOException
-
setFileToPos
protected void setFileToPos(long pos) throws IOExceptionsets current RandomAccessFile to that containing pos saves start position on current RAF- Parameters:
pos-- Throws:
IOException
-
close
public void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceucar.nc2.util.cache.FileCacheable- Overrides:
closein classucar.unidata.io.RandomAccessFile- Throws:
IOException
-
getLastModified
public long getLastModified()
- Specified by:
getLastModifiedin interfaceucar.nc2.util.cache.FileCacheable- Overrides:
getLastModifiedin classucar.unidata.io.RandomAccessFile
-
isDirectory
public boolean isDirectory()
- Overrides:
isDirectoryin classucar.unidata.io.RandomAccessFile
-
length
public long length()
- Overrides:
lengthin classucar.unidata.io.RandomAccessFile
-
readToByteChannel
public long readToByteChannel(WritableByteChannel dest, long offset, long nbytes) throws IOException
- Overrides:
readToByteChannelin classucar.unidata.io.RandomAccessFile- Throws:
IOException
-
read_
protected int read_(long pos, byte[] b, int offset, int len) throws IOException- Overrides:
read_in classucar.unidata.io.RandomAccessFile- Throws:
IOException
-
write
public void write(int b)
Not implemented - use write methods on the leaf RandomAccessFile e.g. getCurrentFile().write()- Specified by:
writein interfaceDataOutput- Overrides:
writein classucar.unidata.io.RandomAccessFile
-
writeBytes
public void writeBytes(byte[] b, int off, int len)Not implemented - use write methods on the leaf RandomAccessFile e.g. getCurrentFile().write()- Overrides:
writeBytesin classucar.unidata.io.RandomAccessFile
-
-