use of org.solbase.common.SolbaseException in project Solbase by Photobucket.
the class IndexWriter method addDocument.
public void addDocument(Put documentPut, Document doc) {
byte[] docId = documentPut.getRow();
String uniqId = doc.get("global_uniq_id");
if (uniqId != null && docId != null) {
// for remote server update via solr update, we want to use
// getDocTable(), but for now map/red can use local htable
HTableInterface docTable = SolbaseUtil.getDocTable();
// insert document to doctable
try {
documentPut.add(SolbaseUtil.timestampColumnFamilyName, SolbaseUtil.tombstonedColumnFamilyQualifierBytes, Bytes.toBytes(0));
docTable.put(documentPut);
} catch (IOException e) {
throw new SolbaseException(SolbaseException.ErrorCode.SERVER_ERROR, e.getMessage());
} finally {
SolbaseUtil.releaseTable(docTable);
}
// need to insert to docKeyIdMap
Put mapping = new Put(Bytes.toBytes(uniqId));
mapping.add(Bytes.toBytes("docId"), Bytes.toBytes(""), SolbaseUtil.randomize(docId));
mapping.add(SolbaseUtil.docIdColumnFamilyName, SolbaseUtil.tombstonedColumnFamilyQualifierBytes, Bytes.toBytes(0));
updateDocKeyIdMap(mapping);
logger.info("adding document: " + Bytes.toInt(SolbaseUtil.randomize(docId)) + " uniqId: " + uniqId);
} else {
if (uniqId == null) {
logger.info("uniqId is null: " + doc.toString());
} else if (docId == null) {
logger.info("docId is null: " + doc.toString());
} else {
logger.info("both uniqId and docId are null: " + doc.toString());
}
}
}
use of org.solbase.common.SolbaseException in project Solbase by Photobucket.
the class IndexWriter method deleteDocKeyIdMap.
public void deleteDocKeyIdMap(Put mappingPut) {
// for remote server update via solr update, we want to use
// getDocTable(), but for now map/red can use local htable
HTableInterface mappingTable = SolbaseUtil.getDocKeyIdMapTable();
// insert document to doctable
try {
Delete delete = new Delete(mappingPut.getRow());
mappingTable.delete(delete);
} catch (IOException e) {
throw new SolbaseException(SolbaseException.ErrorCode.SERVER_ERROR, e.getMessage());
} finally {
SolbaseUtil.releaseTable(mappingTable);
}
}
Aggregations