Package com.salesforce.hbase.index.wal

Examples of com.salesforce.hbase.index.wal.IndexedKeyValue


      }
    }

    // we have all the WAL durability, so we just update the WAL entry and move on
    for (Pair<Mutation, byte[]> entry : indexUpdates) {
      edit.add(new IndexedKeyValue(entry.getSecond(), entry.getFirst()));
    }

    return true;
  }
View Full Code Here


    }

    // there is a little bit of excess here- we iterate all the non-indexed kvs for this check first
    // and then do it again later when getting out the index updates. This should be pretty minor
    // though, compared to the rest of the runtime
    IndexedKeyValue ikv = getFirstIndexedKeyValue(edit);
    /*
     * early exit - we have nothing to write, so we don't need to do anything else. NOTE: we don't
     * release the WAL Rolling lock (INDEX_UPDATE_LOCK) since we never take it in doPre if there are
     * no index updates.
     */
    if (ikv == null) {
      return;
    }

    /*
     * only write the update if we haven't already seen this batch. We only want to write the batch
     * once (this hook gets called with the same WALEdit for each Put/Delete in a batch, which can
     * lead to writing all the index updates for each Put/Delete).
     */
    if (!ikv.getBatchFinished()) {
      Collection<Pair<Mutation, byte[]>> indexUpdates = extractIndexUpdate(edit);

      // the WAL edit is kept in memory and we already specified the factory when we created the
      // references originally - therefore, we just pass in a null factory here and use the ones
      // already specified on each reference
      try {
          writer.writeAndKillYourselfOnFailure(indexUpdates);
      } finally {
        // With a custom kill policy, we may throw instead of kill the server.
        // Without doing this in a finally block (at least with the mini cluster),
        // the region server never goes down.

        // mark the batch as having been written. In the single-update case, this never gets check
        // again, but in the batch case, we will check it again (see above).
        ikv.markBatchFinished();
     
        // release the lock on the index, we wrote everything properly
        // we took the lock for each Put/Delete, so we have to release it a matching number of times
        // batch cases only take the lock once, so we need to make sure we don't over-release the
        // lock.
View Full Code Here

   */
  private Collection<Pair<Mutation, byte[]>> extractIndexUpdate(WALEdit edit) {
    Collection<Pair<Mutation, byte[]>> indexUpdates = new ArrayList<Pair<Mutation, byte[]>>();
    for (KeyValue kv : edit.getKeyValues()) {
      if (kv instanceof IndexedKeyValue) {
        IndexedKeyValue ikv = (IndexedKeyValue) kv;
        indexUpdates.add(new Pair<Mutation, byte[]>(ikv.getMutation(), ikv.getIndexTable()));
      }
    }

    return indexUpdates;
  }
View Full Code Here

    addMutation(withPutsAndDeletes, p, FAMILY);
    edits.add(withPutsAndDeletes);
   
    WALEdit justIndexUpdates = new WALEdit();
    byte[] table = Bytes.toBytes("targetTable");
    IndexedKeyValue ikv = new IndexedKeyValue(table, p);
    justIndexUpdates.add(ikv);
    edits.add(justIndexUpdates);

    WALEdit mixed = new WALEdit();
    addMutation(mixed, d, FAMILY);
View Full Code Here

TOP

Related Classes of com.salesforce.hbase.index.wal.IndexedKeyValue

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.