use of org.apache.hadoop.hive.metastore.model.MSerDeInfo in project hive by apache.
the class ObjectStore method updateSerdeURI.
/**
* The following APIs
*
* - updateSerdeURI
*
* is used by HiveMetaTool. This API **shouldn't** be exposed via Thrift.
*/
public UpdateSerdeURIRetVal updateSerdeURI(URI oldLoc, URI newLoc, String serdeProp, boolean isDryRun) {
boolean committed = false;
Query query = null;
Map<String, String> updateLocations = new HashMap<>();
List<String> badRecords = new ArrayList<>();
UpdateSerdeURIRetVal retVal = null;
try {
openTransaction();
query = pm.newQuery(MSerDeInfo.class);
List<MSerDeInfo> mSerdes = (List<MSerDeInfo>) query.execute();
pm.retrieveAll(mSerdes);
for (MSerDeInfo mSerde : mSerdes) {
if (mSerde.getParameters().containsKey(serdeProp)) {
String schemaLoc = mSerde.getParameters().get(serdeProp);
URI schemaLocURI = null;
try {
schemaLocURI = new Path(schemaLoc).toUri();
} catch (IllegalArgumentException e) {
badRecords.add(schemaLoc);
}
if (schemaLocURI == null) {
badRecords.add(schemaLoc);
} else {
if (shouldUpdateURI(schemaLocURI, oldLoc)) {
String newSchemaLoc = schemaLoc.replaceAll(oldLoc.toString(), newLoc.toString());
updateLocations.put(schemaLocURI.toString(), newSchemaLoc);
if (!isDryRun) {
mSerde.getParameters().put(serdeProp, newSchemaLoc);
}
}
}
}
}
committed = commitTransaction();
if (committed) {
retVal = new UpdateSerdeURIRetVal(badRecords, updateLocations);
}
return retVal;
} finally {
rollbackAndCleanup(committed, query);
}
}
use of org.apache.hadoop.hive.metastore.model.MSerDeInfo in project hive by apache.
the class ObjectStore method getSerDeInfo.
@Override
public SerDeInfo getSerDeInfo(String serDeName) throws NoSuchObjectException, MetaException {
boolean committed = false;
try {
openTransaction();
MSerDeInfo mSerDeInfo = getMSerDeInfo(serDeName);
if (mSerDeInfo == null) {
throw new NoSuchObjectException("No SerDe named " + serDeName);
}
SerDeInfo serde = convertToSerDeInfo(mSerDeInfo);
committed = commitTransaction();
return serde;
} finally {
if (!committed)
rollbackTransaction();
;
}
}
use of org.apache.hadoop.hive.metastore.model.MSerDeInfo in project hive by apache.
the class ObjectStore method getMSerDeInfo.
private MSerDeInfo getMSerDeInfo(String serDeName) throws MetaException {
Query query = null;
try {
query = pm.newQuery(MSerDeInfo.class, "name == serDeName");
query.declareParameters("java.lang.String serDeName");
query.setUnique(true);
MSerDeInfo mSerDeInfo = (MSerDeInfo) query.execute(serDeName);
pm.retrieve(mSerDeInfo);
return mSerDeInfo;
} finally {
if (query != null)
query.closeAll();
}
}
use of org.apache.hadoop.hive.metastore.model.MSerDeInfo in project hive by apache.
the class ObjectStore method addSerde.
@Override
public void addSerde(SerDeInfo serde) throws AlreadyExistsException, MetaException {
boolean committed = false;
try {
openTransaction();
if (getMSerDeInfo(serde.getName()) != null) {
throw new AlreadyExistsException("Serde with name " + serde.getName() + " already exists");
}
MSerDeInfo mSerde = convertToMSerDeInfo(serde);
pm.makePersistent(mSerde);
committed = commitTransaction();
} finally {
if (!committed)
rollbackTransaction();
}
}
Aggregations