Skip to content

Commit d3277b4

Browse files
committed
Improve code quality of the Thin mode code
1 parent 23cef69 commit d3277b4

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed

lib/thin/lob.js

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,21 @@ class ThinLobImpl extends LobImpl {
5959
}
6060
}
6161

62+
//---------------------------------------------------------------------------
63+
// getChunkSize()
64+
//
65+
// Internal method for returning the chunk size of the LOB.
66+
//---------------------------------------------------------------------------
6267
getChunkSize() {
6368
return this._chunkSize;
6469
}
6570

71+
//---------------------------------------------------------------------------
72+
// _getChunkSizeAsync()
73+
//
74+
// Internal method for returning the chunk size of the LOB fetched from
75+
// the database.
76+
//---------------------------------------------------------------------------
6677
async _getChunkSizeAsync() {
6778
this.checkConn();
6879
const options = {
@@ -73,29 +84,60 @@ class ThinLobImpl extends LobImpl {
7384
this._chunkSize = this._pieceSize = await this._sendMessage(options);
7485
}
7586

87+
//---------------------------------------------------------------------------
88+
// getLength()
89+
//
90+
// Internal method for returning the length of a LOB.
91+
//---------------------------------------------------------------------------
7692
getLength() {
7793
return this._length;
7894
}
7995

96+
//---------------------------------------------------------------------------
97+
// getPieceSize()
98+
//
99+
// Internal method returning the size to use for each piece that is
100+
// transferred when reading from the LOB.
101+
//---------------------------------------------------------------------------
80102
getPieceSize() {
81103
return this._pieceSize;
82104
}
83105

106+
//---------------------------------------------------------------------------
107+
// setPieceSize()
108+
//
109+
// Internal method to set the pieceSize for LOBs.
110+
//---------------------------------------------------------------------------
84111
setPieceSize(value) {
85112
this._pieceSize = value;
86113
}
87114

115+
//---------------------------------------------------------------------------
116+
// getType()
117+
//
118+
// Internal method returning the datatype of LOBs.
119+
//---------------------------------------------------------------------------
88120
getType() {
89121
return this.dbType;
90122
}
91123

124+
//---------------------------------------------------------------------------
125+
// getData()
126+
//
127+
// Internal method returning the data obtained from the database.
128+
//---------------------------------------------------------------------------
92129
async getData(offset = 1, len = this._length) {
93130
if (!len) {
94131
len = this._length;
95132
}
96133
return await this.read(offset, len);
97134
}
98135

136+
//---------------------------------------------------------------------------
137+
// read()
138+
//
139+
// Internal method for reading a portion (or all) of the data in the LOB.
140+
//---------------------------------------------------------------------------
99141
async read(offset, length) {
100142
this.checkConn();
101143
const options = {
@@ -108,6 +150,11 @@ class ThinLobImpl extends LobImpl {
108150
return await this._sendMessage(options);
109151
}
110152

153+
//---------------------------------------------------------------------------
154+
// write()
155+
//
156+
// Internal method for writing data to the LOB object.
157+
//---------------------------------------------------------------------------
111158
async write(offset, data) {
112159
this.checkConn();
113160
const options = {
@@ -120,6 +167,11 @@ class ThinLobImpl extends LobImpl {
120167
this._length += data.length;
121168
}
122169

170+
//---------------------------------------------------------------------------
171+
// getCsfrm()
172+
//
173+
// Return the character set encoding used by the LOB.
174+
//---------------------------------------------------------------------------
123175
getCsfrm() {
124176
if (this.dbType._csfrm !== constants.CSFRM_NCHAR) {
125177
if (this._locator[constants.TNS_LOB_LOC_OFFSET_FLAG_3] &
@@ -155,11 +207,21 @@ class ThinLobImpl extends LobImpl {
155207
await this._getChunkSizeAsync();
156208
}
157209

210+
//---------------------------------------------------------------------------
211+
// checkConn()
212+
//
213+
// Internal method to check the connection.
214+
//---------------------------------------------------------------------------
158215
checkConn() {
159216
if (!this.conn.nscon.connected)
160217
errors.throwErr(errors.ERR_INVALID_CONNECTION);
161218
}
162219

220+
//---------------------------------------------------------------------------
221+
// close()
222+
//
223+
// Internal method to close the LOBs using piggyback mechanism.
224+
//---------------------------------------------------------------------------
163225
close() {
164226
this.checkConn();
165227
if (this._isTempLob) {
@@ -169,6 +231,11 @@ class ThinLobImpl extends LobImpl {
169231
}
170232
}
171233

234+
//---------------------------------------------------------------------------
235+
// init()
236+
//
237+
// Internal method to initialize LOBs.
238+
//---------------------------------------------------------------------------
172239
init(conn, locator, dbType, len, chunkSize) {
173240
this.dirtyLength = false;
174241
this.conn = conn;

0 commit comments

Comments
 (0)