Review Board 1.7.22


For Jira HIVE-4398

Review Request #10757 - Created April 24, 2013 and updated

Ashish Vaidya
0.11
HIVE-4398
Reviewers
hive
ashutoshc, thejas
hive
Addressing latest comments from Thejas. This keeps OperationManager.java unchanged.

 
branches/branch-0.11/service/src/java/org/apache/hive/service/cli/session/HiveSessionImpl.java
Revision 1475989 New Change
[20] 16 lines
[+20]
17
 */
17
 */
18

    
   
18

   
19
package org.apache.hive.service.cli.session;
19
package org.apache.hive.service.cli.session;
20

    
   
20

   
21
import java.util.HashMap;
21
import java.util.HashMap;

    
   
22
import java.util.HashSet;
22
import java.util.List;
23
import java.util.List;
23
import java.util.Map;
24
import java.util.Map;

    
   
25
import java.util.Set;
24

    
   
26

   
25
import org.apache.hadoop.hive.conf.HiveConf;
27
import org.apache.hadoop.hive.conf.HiveConf;
26
import org.apache.hadoop.hive.metastore.HiveMetaStoreClient;
28
import org.apache.hadoop.hive.metastore.HiveMetaStoreClient;
27
import org.apache.hadoop.hive.metastore.IMetaStoreClient;
29
import org.apache.hadoop.hive.metastore.IMetaStoreClient;
28
import org.apache.hadoop.hive.metastore.api.MetaException;
30
import org.apache.hadoop.hive.metastore.api.MetaException;
[+20] [20] 33 lines
[+20] [+] public class HiveSessionImpl implements HiveSession {
62
      "org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe";
64
      "org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe";
63

    
   
65

   
64
  private SessionManager sessionManager;
66
  private SessionManager sessionManager;
65
  private OperationManager operationManager;
67
  private OperationManager operationManager;
66
  private IMetaStoreClient metastoreClient = null;
68
  private IMetaStoreClient metastoreClient = null;

    
   
69
  private final Set<OperationHandle> opHandleSet = new HashSet<OperationHandle>();
67

    
   
70

   
68
  public HiveSessionImpl(String username, String password, Map<String, String> sessionConf) {
71
  public HiveSessionImpl(String username, String password, Map<String, String> sessionConf) {
69
    this.username = username;
72
    this.username = username;
70
    this.password = password;
73
    this.password = password;
71

    
   
74

   
[+20] [20] 90 lines
[+20] [+] public OperationHandle executeStatement(String statement, Map<String, String> confOverlay)
162
    acquire();
165
    acquire();
163
    try {
166
    try {
164
      ExecuteStatementOperation operation = getOperationManager()
167
      ExecuteStatementOperation operation = getOperationManager()
165
          .newExecuteStatementOperation(getSession(), statement, confOverlay);
168
          .newExecuteStatementOperation(getSession(), statement, confOverlay);
166
      operation.run();
169
      operation.run();
167
      return operation.getHandle();
170
      OperationHandle opHandle = operation.getHandle();

    
   
171
      opHandleSet.add(opHandle);

    
   
172
      return opHandle;
168
    } finally {
173
    } finally {
169
      release();
174
      release();
170
    }
175
    }
171
  }
176
  }
172

    
   
177

   
173
  public OperationHandle getTypeInfo()
178
  public OperationHandle getTypeInfo()
174
      throws HiveSQLException {
179
      throws HiveSQLException {
175
    acquire();
180
    acquire();
176
    try {
181
    try {
177
      GetTypeInfoOperation operation = getOperationManager().newGetTypeInfoOperation(getSession());
182
      GetTypeInfoOperation operation = getOperationManager().newGetTypeInfoOperation(getSession());
178
      operation.run();
183
      operation.run();
179
      return operation.getHandle();
184
      OperationHandle opHandle = operation.getHandle();

    
   
185
      opHandleSet.add(opHandle);

    
   
186
      return opHandle;
180
    } finally {
187
    } finally {
181
      release();
188
      release();
182
    }
189
    }
183
  }
190
  }
184

    
   
191

   
185
  public OperationHandle getCatalogs()
192
  public OperationHandle getCatalogs()
186
      throws HiveSQLException {
193
      throws HiveSQLException {
187
    acquire();
194
    acquire();
188
    try {
195
    try {
189
      GetCatalogsOperation operation = getOperationManager().newGetCatalogsOperation(getSession());
196
      GetCatalogsOperation operation = getOperationManager().newGetCatalogsOperation(getSession());
190
      operation.run();
197
      operation.run();
191
      return operation.getHandle();
198
      OperationHandle opHandle = operation.getHandle();

    
   
199
      opHandleSet.add(opHandle);

    
   
200
      return opHandle;
192
    } finally {
201
    } finally {
193
      release();
202
      release();
194
    }
203
    }
195
  }
204
  }
196

    
   
205

   
197
  public OperationHandle getSchemas(String catalogName, String schemaName)
206
  public OperationHandle getSchemas(String catalogName, String schemaName)
198
      throws HiveSQLException {
207
      throws HiveSQLException {
199
      acquire();
208
      acquire();
200
    try {
209
    try {
201
      GetSchemasOperation operation =
210
      GetSchemasOperation operation =
202
          getOperationManager().newGetSchemasOperation(getSession(), catalogName, schemaName);
211
          getOperationManager().newGetSchemasOperation(getSession(), catalogName, schemaName);
203
      operation.run();
212
      operation.run();
204
      return operation.getHandle();
213
      OperationHandle opHandle = operation.getHandle();

    
   
214
      opHandleSet.add(opHandle);

    
   
215
      return opHandle;
205
    } finally {
216
    } finally {
206
      release();
217
      release();
207
    }
218
    }
208
  }
219
  }
209

    
   
220

   
210
  public OperationHandle getTables(String catalogName, String schemaName, String tableName,
221
  public OperationHandle getTables(String catalogName, String schemaName, String tableName,
211
      List<String> tableTypes)
222
      List<String> tableTypes)
212
      throws HiveSQLException {
223
      throws HiveSQLException {
213
      acquire();
224
      acquire();
214
    try {
225
    try {
215
      MetadataOperation operation =
226
      MetadataOperation operation =
216
          getOperationManager().newGetTablesOperation(getSession(), catalogName, schemaName, tableName, tableTypes);
227
          getOperationManager().newGetTablesOperation(getSession(), catalogName, schemaName, tableName, tableTypes);
217
      operation.run();
228
      operation.run();
218
      return operation.getHandle();
229
      OperationHandle opHandle = operation.getHandle();

    
   
230
      opHandleSet.add(opHandle);

    
   
231
      return opHandle;
219
    } finally {
232
    } finally {
220
      release();
233
      release();
221
    }
234
    }
222
  }
235
  }
223

    
   
236

   
224
  public OperationHandle getTableTypes()
237
  public OperationHandle getTableTypes()
225
      throws HiveSQLException {
238
      throws HiveSQLException {
226
      acquire();
239
      acquire();
227
    try {
240
    try {
228
      GetTableTypesOperation operation = getOperationManager().newGetTableTypesOperation(getSession());
241
      GetTableTypesOperation operation = getOperationManager().newGetTableTypesOperation(getSession());
229
      operation.run();
242
      operation.run();
230
      return operation.getHandle();
243
      OperationHandle opHandle = operation.getHandle();

    
   
244
      opHandleSet.add(opHandle);

    
   
245
      return opHandle;
231
    } finally {
246
    } finally {
232
      release();
247
      release();
233
    }
248
    }
234
  }
249
  }
235

    
   
250

   
236
  public OperationHandle getColumns(String catalogName, String schemaName,
251
  public OperationHandle getColumns(String catalogName, String schemaName,
237
      String tableName, String columnName)  throws HiveSQLException {
252
      String tableName, String columnName)  throws HiveSQLException {
238
    acquire();
253
    acquire();
239
    try {
254
    try {
240
    GetColumnsOperation operation = getOperationManager().newGetColumnsOperation(getSession(),
255
    GetColumnsOperation operation = getOperationManager().newGetColumnsOperation(getSession(),
241
        catalogName, schemaName, tableName, columnName);
256
        catalogName, schemaName, tableName, columnName);
242
    operation.run();
257
    operation.run();
243
    return operation.getHandle();
258
    OperationHandle opHandle = operation.getHandle();

    
   
259
    opHandleSet.add(opHandle);

    
   
260
    return opHandle;
244
    } finally {
261
    } finally {
245
      release();
262
      release();
246
    }
263
    }
247
  }
264
  }
248

    
   
265

   
249
  public OperationHandle getFunctions(String catalogName, String schemaName, String functionName)
266
  public OperationHandle getFunctions(String catalogName, String schemaName, String functionName)
250
      throws HiveSQLException {
267
      throws HiveSQLException {
251
    acquire();
268
    acquire();
252
    try {
269
    try {
253
      GetFunctionsOperation operation = getOperationManager()
270
      GetFunctionsOperation operation = getOperationManager()
254
          .newGetFunctionsOperation(getSession(), catalogName, schemaName, functionName);
271
          .newGetFunctionsOperation(getSession(), catalogName, schemaName, functionName);
255
      operation.run();
272
      operation.run();
256
      return operation.getHandle();
273
      OperationHandle opHandle = operation.getHandle();

    
   
274
      opHandleSet.add(opHandle);

    
   
275
      return opHandle;
257
    } finally {
276
    } finally {
258
      release();
277
      release();
259
    }
278
    }
260
  }
279
  }
261

    
   
280

   
[+20] [20] 6 lines
[+20] [+] public void close() throws HiveSQLException {
268
       * closed at the end of the session
287
       * closed at the end of the session
269
       */
288
       */
270
      if (metastoreClient != null) {
289
      if (metastoreClient != null) {
271
        metastoreClient.close();
290
        metastoreClient.close();
272
      }
291
      }

    
   
292
      // Iterate through the opHandles and close their operations

    
   
293
      for (OperationHandle opHandle : opHandleSet) {

    
   
294
        operationManager.closeOperation(opHandle);

    
   
295
      }

    
   
296
      opHandleSet.clear();
273
    } finally {
297
    } finally {
274
      release();
298
      release();
275
    }
299
    }
276
  }
300
  }
277

    
   
301

   
[+20] [20] 20 lines
[+20] [+] public void cancelOperation(OperationHandle opHandle) throws HiveSQLException {
298

    
   
322

   
299
  @Override
323
  @Override
300
  public void closeOperation(OperationHandle opHandle) throws HiveSQLException {
324
  public void closeOperation(OperationHandle opHandle) throws HiveSQLException {
301
    acquire();
325
    acquire();
302
    try {
326
    try {
303
      sessionManager.getOperationManager().closeOperation(opHandle);
327
      operationManager.closeOperation(opHandle);

    
   
328
      opHandleSet.remove(opHandle);
304
    } finally {
329
    } finally {
305
      release();
330
      release();
306
    }
331
    }
307
  }
332
  }
308

    
   
333

   
[+20] [20] 36 lines
branches/branch-0.11/service/src/test/org/apache/hive/service/cli/session/TestHiveSession.java
New File
 
  1. branches/branch-0.11/service/src/java/org/apache/hive/service/cli/session/HiveSessionImpl.java: Loading...
  2. branches/branch-0.11/service/src/test/org/apache/hive/service/cli/session/TestHiveSession.java: Loading...