[ 
https://issues.apache.org/jira/browse/LUCY-67?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Marvin Humphrey updated LUCY-67:
--------------------------------

    Attachment: Folder.pm
                Folder.c
                Folder.bp

Subclasses of Folder implement a handful of abstract methods which operate
only on immediate "local" files within the directory: Local_Open_FileHandle(),
Local_Delete(), and so on.  The recursion is all taken care of within Folder.c
in methods such as Open_FileHandle() and Delete(), sparing the subclasses from
having to take on that tricky task.  Client code will call the recursing
Folder methods, rather than the "Local" variants.

Folder has a few more client methods than Lucene's Directory.  Some are
absolutely necessary:

{code:none}
/** Open a FileHandle, or set Err_error and return NULL on failure.
 *
 * @param path A relative filepath.
 * @param flags FileHandle flags.
 * @return a FileHandle, or NULL.
 */
public incremented FileHandle*
Open_FileHandle(Folder *self, const CharBuf *path, u32_t flags);

/** Open a DirHandle or set Err_error and return NULL on failure.
 *
 * @param path Path to a subdirectory, relative to the Folder's path.  If
 * empty or NULL, returns a DirHandle for this Folder.
 * @return a DirHandle, or NULL.
 */
public incremented DirHandle*
Open_Dir(Folder *self, const CharBuf *path = NULL);

/** Create a subdirectory.
 * 
 * @param path A relative filepath.
 * @return true on success, false on failure (sets Err_error).
 */
public bool_t
MkDir(Folder *self, const CharBuf *path);
{code}

A few are more for convenience and might possibly be stripped or implemented
differently if paring down Folder becomes a priority.

{code:none}
/** Recursively list all files and directories in the Folder.
 *
 * @return an unsorted array of relative filepaths.
 */
incremented VArray*
List_R(Folder *self);

/** Delete recursively, starting at <code>path</code>
 *
 * @param path A relative filepath specifying a file or subdirectory.
 * @return true if the whole tree is deleted successfully, false if any
 * part remains.
 */
public bool_t
Delete_Tree(Folder *self, const CharBuf *path);

/** Read a file and return its contents.
 *
 * @param path A relative filepath.
 * @param return the file's contents.
 */
public incremented ByteBuf*
Slurp_File(Folder *self, const CharBuf *path);

/** Perform implementation-specific initialization.  For example: FSFolder
 * creates its own directory.
 */
public abstract void
Initialize(Folder *self);

/** Verify that operations may be performed on this Folder.
 * 
 * @return true on success.
 */
public abstract bool_t 
Check(Folder *self);
{code}

There is one method, Hard_Link() which is included for now, but may be removed
in the future depending on how we decide to implement locks.

{code}
/** Create a hard link at path <code>to</code> pointing at the existing
 * file <code>from</code>, or set Err_error and return false on failure.
 * 
 * @return true on success, false on failure.
 */
public abstract bool_t
Hard_Link(Folder *self, const CharBuf *from, const CharBuf *to);
{code}

I have prepared test cases for Folder, but they are implemented at present
using RAMFolder; it would have been too much work to create a test-only
MockFolder class.  The Folder test files will be contributed in a separate
issue after RAMFolder goes into the Lucy repository.


> Folder -- an index directory.
> -----------------------------
>
>                 Key: LUCY-67
>                 URL: https://issues.apache.org/jira/browse/LUCY-67
>             Project: Lucy
>          Issue Type: Sub-task
>          Components: Core
>            Reporter: Marvin Humphrey
>            Assignee: Marvin Humphrey
>            Priority: Blocker
>         Attachments: Folder.bp, Folder.c, Folder.pm
>
>
> Folder is an abstract class representing an index directory.  Unlike Lucene's
> Directory class, Folder can contain subdirectories, which are implemented
> using additional, nested Folder instances and recursion.
> The subdirectory support requirement increases Folder's size and complexity,
> but of course it is mandatory if segments are to be implemented as individual
> directories.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to