Search in sources :

Example 6 with SolbaseException

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());
        }
    }
}
Also used : SolbaseException(org.solbase.common.SolbaseException) IOException(java.io.IOException) HTableInterface(org.apache.hadoop.hbase.client.HTableInterface) Put(org.apache.hadoop.hbase.client.Put)

Example 7 with SolbaseException

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);
    }
}
Also used : Delete(org.apache.hadoop.hbase.client.Delete) SolbaseException(org.solbase.common.SolbaseException) IOException(java.io.IOException) HTableInterface(org.apache.hadoop.hbase.client.HTableInterface)

Aggregations

SolbaseException (org.solbase.common.SolbaseException)7 IOException (java.io.IOException)6 HTableInterface (org.apache.hadoop.hbase.client.HTableInterface)4 TimeoutException (java.util.concurrent.TimeoutException)3 MemcachedException (net.rubyeye.xmemcached.exception.MemcachedException)3 Document (org.apache.lucene.document.Document)3 ParsedDoc (org.solbase.indexer.ParsedDoc)3 AtomicLong (java.util.concurrent.atomic.AtomicLong)2 Delete (org.apache.hadoop.hbase.client.Delete)2 Put (org.apache.hadoop.hbase.client.Put)2 ByteBuffer (java.nio.ByteBuffer)1 Result (org.apache.hadoop.hbase.client.Result)1 ResultScanner (org.apache.hadoop.hbase.client.ResultScanner)1 Scan (org.apache.hadoop.hbase.client.Scan)1 SolrException (org.apache.solr.common.SolrException)1 SchemaField (org.apache.solr.schema.SchemaField)1 TermDocMetadata (org.solbase.lucenehbase.TermDocMetadata)1