| 1 |
/* |
| 2 |
* Copyright 2004-2023 H2 Group. Multiple-Licensed under the MPL 2.0, |
| 3 |
* and the EPL 1.0 (https://h2database.com/html/license.html). |
| 4 |
* Initial Developer: H2 Group |
| 5 |
*/ |
| 6 |
package org.h2.store; |
| 7 |
|
| 8 |
import org.h2.message.DbException; |
| 9 |
import org.h2.util.SmallLRUCache; |
| 10 |
import org.h2.util.TempFileDeleter; |
| 11 |
import org.h2.value.CompareMode; |
| 12 |
|
| 13 |
/** |
| 14 |
* A data handler contains a number of callback methods, mostly related to CLOB |
| 15 |
* and BLOB handling. The most important implementing class is a database. |
| 16 |
*/ |
| 17 |
public interface DataHandler { |
| 18 |
|
| 19 |
/** |
| 20 |
* Get the database path. |
| 21 |
* |
| 22 |
* @return the database path |
| 23 |
*/ |
| 24 |
String getDatabasePath(); |
| 25 |
|
| 26 |
/** |
| 27 |
* Open a file at the given location. |
| 28 |
* |
| 29 |
* @param name the file name |
| 30 |
* @param mode the mode |
| 31 |
* @param mustExist whether the file must already exist |
| 32 |
* @return the file |
| 33 |
*/ |
| 34 |
FileStore openFile(String name, String mode, boolean mustExist); |
| 35 |
|
| 36 |
/** |
| 37 |
* Check if the simulated power failure occurred. |
| 38 |
* This call will decrement the countdown. |
| 39 |
* |
| 40 |
* @throws DbException if the simulated power failure occurred |
| 41 |
*/ |
| 42 |
void checkPowerOff() throws DbException; |
| 43 |
|
| 44 |
/** |
| 45 |
* Check if writing is allowed. |
| 46 |
* |
| 47 |
* @throws DbException if it is not allowed |
| 48 |
*/ |
| 49 |
void checkWritingAllowed() throws DbException; |
| 50 |
|
| 51 |
/** |
| 52 |
* Get the maximum length of a in-place large object |
| 53 |
* |
| 54 |
* @return the maximum size |
| 55 |
*/ |
| 56 |
int getMaxLengthInplaceLob(); |
| 57 |
|
| 58 |
/** |
| 59 |
* Get the temp file deleter mechanism. |
| 60 |
* |
| 61 |
* @return the temp file deleter |
| 62 |
*/ |
| 63 |
TempFileDeleter getTempFileDeleter(); |
| 64 |
|
| 65 |
/** |
| 66 |
* Get the synchronization object for lob operations. |
| 67 |
* |
| 68 |
* @return the synchronization object |
| 69 |
*/ |
| 70 |
Object getLobSyncObject(); |
| 71 |
|
| 72 |
/** |
| 73 |
* Get the lob file list cache if it is used. |
| 74 |
* |
| 75 |
* @return the cache or null |
| 76 |
*/ |
| 77 |
SmallLRUCache<String, String[]> getLobFileListCache(); |
| 78 |
|
| 79 |
/** |
| 80 |
* Get the lob storage mechanism to use. |
| 81 |
* |
| 82 |
* @return the lob storage mechanism |
| 83 |
*/ |
| 84 |
LobStorageInterface getLobStorage(); |
| 85 |
|
| 86 |
/** |
| 87 |
* Read from a lob. |
| 88 |
* |
| 89 |
* @param lobId the lob id |
| 90 |
* @param hmac the message authentication code |
| 91 |
* @param offset the offset within the lob |
| 92 |
* @param buff the target buffer |
| 93 |
* @param off the offset within the target buffer |
| 94 |
* @param length the number of bytes to read |
| 95 |
* @return the number of bytes read |
| 96 |
*/ |
| 97 |
int readLob(long lobId, byte[] hmac, long offset, byte[] buff, int off, int length); |
| 98 |
|
| 99 |
/** |
| 100 |
* Return compare mode. |
| 101 |
* |
| 102 |
* @return Compare mode. |
| 103 |
*/ |
| 104 |
CompareMode getCompareMode(); |
| 105 |
} |