Debian Codegraph @

src/main/org/h2/store/LobStorageInterface.java

raw
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 java.io.IOException;
9 import java.io.InputStream;
10 import java.io.Reader;
11
12 import org.h2.value.ValueBlob;
13 import org.h2.value.ValueClob;
14 import org.h2.value.ValueLob;
15
16 /**
17 * A mechanism to store and retrieve lob data.
18 */
19 public interface LobStorageInterface {
20
21 /**
22 * Create a CLOB object.
23 *
24 * @param reader the reader
25 * @param maxLength the maximum length (-1 if not known)
26 * @return the LOB
27 */
28 ValueClob createClob(Reader reader, long maxLength);
29
30 /**
31 * Create a BLOB object.
32 *
33 * @param in the input stream
34 * @param maxLength the maximum length (-1 if not known)
35 * @return the LOB
36 */
37 ValueBlob createBlob(InputStream in, long maxLength);
38
39 /**
40 * Copy a lob.
41 *
42 * @param old the old lob
43 * @param tableId the new table id
44 * @return the new lob
45 */
46 ValueLob copyLob(ValueLob old, int tableId);
47
48 /**
49 * Get the input stream for the given lob, only called on server side of a TCP connection.
50 *
51 * @param lobId the lob id
52 * @param byteCount the number of bytes to read, or -1 if not known
53 * @return the stream
54 * @throws IOException on failure
55 */
56 InputStream getInputStream(long lobId, long byteCount) throws IOException;
57
58 /**
59 * Get the input stream for the given lob
60 *
61 * @param lobId the lob id
62 * @param tableId the able id
63 * @param byteCount the number of bytes to read, or -1 if not known
64 * @return the stream
65 * @throws IOException on failure
66 */
67 InputStream getInputStream(long lobId, int tableId, long byteCount) throws IOException;
68
69 /**
70 * Delete a LOB (from the database, if it is stored there).
71 *
72 * @param lob the lob
73 */
74 void removeLob(ValueLob lob);
75
76 /**
77 * Remove all LOBs for this table.
78 *
79 * @param tableId the table id
80 */
81 void removeAllForTable(int tableId);
82
83 /**
84 * Whether the storage is read-only
85 *
86 * @return true if yes
87 */
88 boolean isReadOnly();
89
90 /**
91 * Close LobStorage and release all resources
92 */
93 default void close() {}
94 }