Class TimestampsFilter

All Implemented Interfaces:
HintingFilter

@Public public class TimestampsFilter extends FilterBase implements HintingFilter
Filter that returns only cells whose timestamp (version) is in the specified list of timestamps (versions).

Note: Use of this filter overrides any time range/time stamp options specified using Get.setTimeRange(long, long), Scan.setTimeRange(long, long), Get.setTimestamp(long), or Scan.setTimestamp(long).

  • Field Details

  • Constructor Details

    • TimestampsFilter

      public TimestampsFilter(List<Long> timestamps)
      Constructor for filter that retains only the specified timestamps in the list.
    • TimestampsFilter

      public TimestampsFilter(List<Long> timestamps, boolean canHint)
      Constructor for filter that retains only those cells whose timestamp (version) is in the specified list of timestamps.
      Parameters:
      timestamps - list of timestamps that are wanted.
      canHint - should the filter provide a seek hint? This can skip past delete tombstones, so it should only be used when that is not an issue ( no deletes, or don't care if data becomes visible)
  • Method Details

    • getTimestamps

      public List<Long> getTimestamps()
      Returns the list of timestamps
    • init

      private void init()
    • getMin

      public long getMin()
      Gets the minimum timestamp requested by filter.
      Returns:
      minimum timestamp requested by filter.
    • filterRowKey

      public boolean filterRowKey(Cell cell) throws IOException
      Description copied from class: Filter
      Filters a row based on the row key. If this returns true, the entire row will be excluded. If false, each KeyValue in the row will be passed to Filter.filterCell(Cell) below. If Filter.filterAllRemaining() returns true, then Filter.filterRowKey(Cell) should also return true. Concrete implementers can signal a failure condition in their code by throwing an IOException.
      Overrides:
      filterRowKey in class FilterBase
      Parameters:
      cell - The first cell coming in the new row
      Returns:
      true, remove entire row, false, include the row (maybe).
      Throws:
      IOException - in case an I/O or an filter specific failure needs to be signaled.
    • filterCell

      Description copied from class: Filter
      A way to filter based on the column family, column qualifier and/or the column value. Return code is described below. This allows filters to filter only certain number of columns, then terminate without matching ever column. If filterRowKey returns true, filterCell needs to be consistent with it. filterCell can assume that filterRowKey has already been called for the row. If your filter returns ReturnCode.NEXT_ROW, it should return ReturnCode.NEXT_ROW until Filter.reset() is called just in case the caller calls for the next row. Concrete implementers can signal a failure condition in their code by throwing an IOException.
      Overrides:
      filterCell in class Filter
      Parameters:
      c - the Cell in question
      Returns:
      code as described below
      See Also:
    • getNextCellHint

      public Cell getNextCellHint(Cell currentCell) throws IOException
      Pick the next cell that the scanner should seek to. Since this can skip any number of cells any of which can be a delete this can resurect old data. The method will only be used if canHint was set to true while creating the filter.
      Overrides:
      getNextCellHint in class FilterBase
      Returns:
      KeyValue which must be next seeked. return null if the filter is not sure which key to seek to next.
      Throws:
      IOException - This will never happen.
    • createFilterFromArguments

      public static Filter createFilterFromArguments(ArrayList<byte[]> filterArguments)
    • toByteArray

      public byte[] toByteArray()
      Returns The filter serialized using pb
      Overrides:
      toByteArray in class FilterBase
      Returns:
      The filter serialized using pb
    • parseFrom

      public static TimestampsFilter parseFrom(byte[] pbBytes) throws DeserializationException
      Parse a serialized representation of TimestampsFilter
      Parameters:
      pbBytes - A pb serialized TimestampsFilter instance
      Returns:
      An instance of TimestampsFilter made from bytes
      Throws:
      DeserializationException - if an error occurred
      See Also:
    • areSerializedFieldsEqual

      Returns true if and only if the fields of the filter that are serialized are equal to the corresponding fields in other. Used for testing.
      Overrides:
      areSerializedFieldsEqual in class FilterBase
      Returns:
      true if and only if the fields of the filter that are serialized are equal to the corresponding fields in other. Used for testing.
    • toString

      public String toString()
      Description copied from class: FilterBase
      Return filter's info for debugging and logging purpose.
      Overrides:
      toString in class FilterBase
    • toString

      protected String toString(int maxTimestamps)
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object