Package org.apache.hbase.index.covered.update

Examples of org.apache.hbase.index.covered.update.ColumnTracker


  @Override
  public Pair<Scanner, IndexUpdate> getIndexedColumnsTableState(
      Collection<? extends ColumnReference> indexedColumns) throws IOException {
    ensureLocalStateInitialized(indexedColumns);
    // filter out things with a newer timestamp and track the column references to which it applies
    ColumnTracker tracker = new ColumnTracker(indexedColumns);
    synchronized (this.trackedColumns) {
      // we haven't seen this set of columns before, so we need to create a new tracker
      if (!this.trackedColumns.contains(tracker)) {
        this.trackedColumns.add(tracker);
      }
View Full Code Here


    // timestamp of the next update we need to track
    long minTs = ColumnTracker.NO_NEWER_PRIMARY_TABLE_ENTRY_TIMESTAMP;
    List<IndexedColumnGroup> columnHints = new ArrayList<IndexedColumnGroup>();
    for (IndexUpdate update : upserts) {
      // this is the one bit where we check the timestamps
      final ColumnTracker tracker = update.getIndexedColumns();
      long trackerTs = tracker.getTS();
      // update the next min TS we need to track
      if (trackerTs < minTs) {
        minTs = tracker.getTS();
      }
      // track index hints for the next round. Hint if we need an update for that column for the
      // next timestamp. These columns clearly won't need to update as we go through time as they
      // already match the most recent possible thing.
      boolean needsCleanup = false;
      if (tracker.hasNewerTimestamps()) {
        columnHints.add(tracker);
        // this update also needs to be cleaned up at the next timestamp because it not the latest.
        needsCleanup = true;
      }


      // only make the put if the index update has been setup
      if (update.isValid()) {
        byte[] table = update.getTableName();
        Mutation mutation = update.getUpdate();
        updateMap.addIndexUpdate(table, mutation);

        // only make the cleanup if we made a put and need cleanup
        if (needsCleanup) {
          // there is a TS for the interested columns that is greater than the columns in the
          // put. Therefore, we need to issue a delete at the same timestamp
          Delete d = new Delete(mutation.getRow());
          d.setTimestamp(tracker.getTS());
          updateMap.addIndexUpdate(table, d);
        }
      }
    }
    return minTs;
View Full Code Here

  }

  @Test
  public void testOnlyKeepsOlderTimestamps() {
    Collection<ColumnReference> columns = new ArrayList<ColumnReference>();
    ColumnTracker tracker = new ColumnTracker(columns);
    tracker.setTs(10);
    assertEquals("Column tracker didn't set original TS", 10, tracker.getTS());
    tracker.setTs(12);
    assertEquals("Column tracker allowed newer timestamp to be set.", 10, tracker.getTS());
    tracker.setTs(9);
    assertEquals("Column tracker didn't decrease set timestamp for smaller value", 9,
      tracker.getTS());
  }
View Full Code Here

  }

  @Test
  public void testHasNewerTimestamps() throws Exception {
    Collection<ColumnReference> columns = new ArrayList<ColumnReference>();
    ColumnTracker tracker = new ColumnTracker(columns);
    assertFalse("Tracker has newer timestamps when no ts set", tracker.hasNewerTimestamps());
    tracker.setTs(10);
    assertTrue("Tracker doesn't have newer timetamps with set ts", tracker.hasNewerTimestamps());
  }
View Full Code Here

TOP

Related Classes of org.apache.hbase.index.covered.update.ColumnTracker

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.