Skip to content

Commit

Permalink
Merge pull request #519 from project-tsurugi/LargeObjectCache
Browse files Browse the repository at this point in the history
add LargeObjectCache and related APIs
  • Loading branch information
t-horikawa authored Feb 5, 2025
2 parents 20cfc94 + a1d696c commit d1710cf
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright 2023-2025 Project Tsurugi.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.tsurugidb.tsubakuro.sql;

import java.io.IOException;
import java.nio.file.Path;
import java.util.Optional;

/**
* Represents large object cache.
*/
public interface LargeObjectCache extends AutoCloseable {

/**
* Returns the path of the file that represents the large object, only if it exists.
* The returned Path is available until close() of this object is invoked.
* @return the path of the file, or empty if it does not exist
*/
Optional<Path> find();

/**
* Copy the large object to the file indicated by the given path.
* Files created by this method are not affected by close() of this object.
* @param destination the path of the destination file
* @throws IOException if I/O error was occurred while copying the large object to the file
* or it encounters a situation where find() returns an empty Optional
*/
void copyTo(Path destination) throws IOException;

/**
* Closes the object cache. The file whose Path has been returned by find() may be deleted.
*/
@Override
void close();
}
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,26 @@ default FutureResponse<Reader> openReader(ClobReference ref) throws IOException
throw new UnsupportedOperationException();
}

/**
* Returns an object cache for the blob.
* @return a future response of a LargeObjectCache
* @param ref the blob reference
* @throws IOException if I/O error was occurred while sending request
*/
default FutureResponse<LargeObjectCache> getLargeObjectCache(BlobReference ref) throws IOException {
throw new UnsupportedOperationException();
}

/**
* Returns an object cache for the clob.
* @return a future response of a LargeObjectCache
* @param ref the clob reference
* @throws IOException if I/O error was occurred while sending request
*/
default FutureResponse<LargeObjectCache> getLargeObjectCache(ClobReference ref) throws IOException {
throw new UnsupportedOperationException();
}

/**
* Disposes the underlying server resources.
* Note that, this never closes the underlying {@link Session}.
Expand Down

0 comments on commit d1710cf

Please sign in to comment.