@Override public int hashCode() { return Objects.hash(Bytes.hashCode(getMinColumn()), getMinColumnInclusive(), Bytes.hashCode(getMaxColumn()), getMaxColumnInclusive()); } }
@Test public void testColumnRangeFilter() throws IOException { String filterString = "ColumnRangeFilter('abc', true, 'xyz', false)"; ColumnRangeFilter columnRangeFilter = doTestFilter(filterString, ColumnRangeFilter.class); assertEquals("abc", new String(columnRangeFilter.getMinColumn(), StandardCharsets.UTF_8)); assertEquals("xyz", new String(columnRangeFilter.getMaxColumn(), StandardCharsets.UTF_8)); assertTrue(columnRangeFilter.isMinColumnInclusive()); assertFalse(columnRangeFilter.isMaxColumnInclusive()); }
/** * @param o filter to serialize. * @return true if and only if the fields of the filter that are serialized are equal to the * corresponding fields in other. Used for testing. */ @Override boolean areSerializedFieldsEqual(Filter o) { if (o == this) { return true; } if (!(o instanceof ColumnRangeFilter)) { return false; } ColumnRangeFilter other = (ColumnRangeFilter) o; return Bytes.equals(this.getMinColumn(), other.getMinColumn()) && this.getMinColumnInclusive() == other.getMinColumnInclusive() && Bytes.equals(this.getMaxColumn(), other.getMaxColumn()) && this.getMaxColumnInclusive() == other.getMaxColumnInclusive(); }
@Test public void testColumnRangeFilter() throws IOException { String filterString = "ColumnRangeFilter('abc', true, 'xyz', false)"; ColumnRangeFilter columnRangeFilter = doTestFilter(filterString, ColumnRangeFilter.class); assertEquals("abc", new String(columnRangeFilter.getMinColumn(), StandardCharsets.UTF_8)); assertEquals("xyz", new String(columnRangeFilter.getMaxColumn(), StandardCharsets.UTF_8)); assertTrue(columnRangeFilter.isMinColumnInclusive()); assertFalse(columnRangeFilter.isMaxColumnInclusive()); }
case ColumnRangeFilter: ColumnRangeFilter crf = (ColumnRangeFilter)filter; this.minColumn = Bytes.toString(Base64.getEncoder().encode(crf.getMinColumn())); this.minColumnInclusive = crf.getMinColumnInclusive(); this.maxColumn = Bytes.toString(Base64.getEncoder().encode(crf.getMaxColumn()));
/** * @param o filter to serialize. * @return true if and only if the fields of the filter that are serialized are equal to the * corresponding fields in other. Used for testing. */ @Override boolean areSerializedFieldsEqual(Filter o) { if (o == this) { return true; } if (!(o instanceof ColumnRangeFilter)) { return false; } ColumnRangeFilter other = (ColumnRangeFilter) o; return Bytes.equals(this.getMinColumn(), other.getMinColumn()) && this.getMinColumnInclusive() == other.getMinColumnInclusive() && Bytes.equals(this.getMaxColumn(), other.getMaxColumn()) && this.getMaxColumnInclusive() == other.getMaxColumnInclusive(); }
/** * @param other * @return true if and only if the fields of the filter that are serialized * are equal to the corresponding fields in other. Used for testing. */ @Override boolean areSerializedFieldsEqual(Filter o) { if (o == this) return true; if (!(o instanceof ColumnRangeFilter)) return false; ColumnRangeFilter other = (ColumnRangeFilter)o; return Bytes.equals(this.getMinColumn(),other.getMinColumn()) && this.getMinColumnInclusive() == other.getMinColumnInclusive() && Bytes.equals(this.getMaxColumn(), other.getMaxColumn()) && this.getMaxColumnInclusive() == other.getMaxColumnInclusive(); }
/** * @param other * @return true if and only if the fields of the filter that are serialized * are equal to the corresponding fields in other. Used for testing. */ boolean areSerializedFieldsEqual(Filter o) { if (o == this) return true; if (!(o instanceof ColumnRangeFilter)) return false; ColumnRangeFilter other = (ColumnRangeFilter)o; return Bytes.equals(this.getMinColumn(),other.getMinColumn()) && this.getMinColumnInclusive() == other.getMinColumnInclusive() && Bytes.equals(this.getMaxColumn(), other.getMaxColumn()) && this.getMaxColumnInclusive() == other.getMaxColumnInclusive(); }
/** {@inheritDoc} */ @Override public Filter adapt(FilterAdapterContext context, ColumnRangeFilter filter) throws IOException { byte[] familyName = getSingleFamily(context.getScan()); QualifierRangeFilter rangeBuilder = FILTERS.qualifier().rangeWithinFamily(Bytes.toString(familyName)); if (filter.getMinColumn() != null) { ByteString startQualifier = ByteString.copyFrom(filter.getMinColumn()); if (filter.getMinColumnInclusive()) { rangeBuilder.startClosed(startQualifier); } else { rangeBuilder.startOpen(startQualifier); } } if (filter.getMaxColumn() != null) { ByteString endQualifier = ByteString.copyFrom(filter.getMaxColumn()); if (filter.getMaxColumnInclusive()) { rangeBuilder.endClosed(endQualifier); } else { rangeBuilder.endOpen(endQualifier); } } return rangeBuilder; }
/** {@inheritDoc} */ @Override public Filter adapt(FilterAdapterContext context, ColumnRangeFilter filter) throws IOException { byte[] familyName = getSingleFamily(context.getScan()); QualifierRangeFilter rangeBuilder = FILTERS.qualifier().rangeWithinFamily(Bytes.toString(familyName)); if (filter.getMinColumn() != null) { ByteString startQualifier = ByteString.copyFrom(filter.getMinColumn()); if (filter.getMinColumnInclusive()) { rangeBuilder.startClosed(startQualifier); } else { rangeBuilder.startOpen(startQualifier); } } if (filter.getMaxColumn() != null) { ByteString endQualifier = ByteString.copyFrom(filter.getMaxColumn()); if (filter.getMaxColumnInclusive()) { rangeBuilder.endClosed(endQualifier); } else { rangeBuilder.endOpen(endQualifier); } } return rangeBuilder; }
case ColumnRangeFilter: ColumnRangeFilter crf = (ColumnRangeFilter)filter; this.minColumn = Bytes.toString(Base64.getEncoder().encode(crf.getMinColumn())); this.minColumnInclusive = crf.getMinColumnInclusive(); this.maxColumn = Bytes.toString(Base64.getEncoder().encode(crf.getMaxColumn()));
break; case ColumnRangeFilter: this.minColumn = Base64.encodeBytes(((ColumnRangeFilter)filter).getMinColumn()); this.minColumnInclusive = ((ColumnRangeFilter)filter).getMinColumnInclusive(); this.maxColumn = Base64.encodeBytes(((ColumnRangeFilter)filter).getMaxColumn());
break; case ColumnRangeFilter: this.minColumn = Base64.encodeBytes(((ColumnRangeFilter)filter).getMinColumn()); this.minColumnInclusive = ((ColumnRangeFilter)filter).getMinColumnInclusive(); this.maxColumn = Base64.encodeBytes(((ColumnRangeFilter)filter).getMaxColumn());