@Override public Put writeProperty(final Put put, Property property) { byte[] type = PropertyValueUtils.Bytes.getTypeByte(property.getValue()); byte[] bytesWithoutType = PropertyValueUtils.Bytes.getRawBytesWithoutType(property.getValue()); put.addColumn(CF_PROPERTY_TYPE_BYTES, Bytes.toBytes(property.getKey()), type); put.addColumn(CF_PROPERTY_VALUE_BYTES, Bytes.toBytes(property.getKey()), bytesWithoutType); return put; }
Bytes.toBytesBinary(key), compareOp, PropertyValueUtils.Bytes.getTypeByte(value));
Bytes.toBytesBinary(key), negate ? CompareFilter.CompareOp.NOT_EQUAL : CompareFilter.CompareOp.EQUAL, PropertyValueUtils.Bytes.getTypeByte(min));
/** * Test the toHBaseFilter function */ @Test public void testToHBaseFilter() { HBasePropLargerThan<Vertex> vertexFilter = new HBasePropLargerThan<>(propertyKey, propertyValue, isInclude); FilterList expectedFilter = new FilterList(FilterList.Operator.MUST_PASS_ALL); SingleColumnValueFilter valueFilter = new SingleColumnValueFilter( Bytes.toBytesBinary(CF_PROPERTY_VALUE), Bytes.toBytesBinary(propertyKey), isInclude ? CompareFilter.CompareOp.GREATER_OR_EQUAL : CompareFilter.CompareOp.GREATER, new BinaryComparator(PropertyValueUtils.Bytes.getRawBytesWithoutType(propertyValue))); // Define that the entire row will be skipped if the column is not found valueFilter.setFilterIfMissing(true); SingleColumnValueFilter typeFilter = new SingleColumnValueFilter( Bytes.toBytesBinary(CF_PROPERTY_TYPE), Bytes.toBytesBinary(propertyKey), CompareFilter.CompareOp.EQUAL, PropertyValueUtils.Bytes.getTypeByte(propertyValue)); // Define that the entire row will be skipped if the column is not found typeFilter.setFilterIfMissing(true); expectedFilter.addFilter(valueFilter); expectedFilter.addFilter(typeFilter); assertEquals("Failed during filter comparison for type [" + propertyType + "].", expectedFilter.toString(), vertexFilter.toHBaseFilter(false).toString()); }
/** * Test the toHBaseFilter function */ @Test public void testToHBaseFilter() { HBasePropEquals<Vertex> vertexFilter = new HBasePropEquals<>(propertyKey, propertyValue); FilterList expectedFilter = new FilterList(FilterList.Operator.MUST_PASS_ALL); SingleColumnValueFilter valueFilter = new SingleColumnValueFilter( Bytes.toBytesBinary(CF_PROPERTY_VALUE), Bytes.toBytesBinary(propertyKey), CompareFilter.CompareOp.EQUAL, PropertyValueUtils.Bytes.getRawBytesWithoutType(propertyValue)); // Define that the entire row will be skipped if the column is not found valueFilter.setFilterIfMissing(true); SingleColumnValueFilter typeFilter = new SingleColumnValueFilter( Bytes.toBytesBinary(CF_PROPERTY_TYPE), Bytes.toBytesBinary(propertyKey), CompareFilter.CompareOp.EQUAL, PropertyValueUtils.Bytes.getTypeByte(propertyValue)); // Define that the entire row will be skipped if the column is not found typeFilter.setFilterIfMissing(true); expectedFilter.addFilter(valueFilter); expectedFilter.addFilter(typeFilter); assertEquals("Failed during filter comparison for type [" + propertyType + "].", expectedFilter.toString(), vertexFilter.toHBaseFilter(false).toString()); }
/** * Test static function {@link PropertyValueUtils.Bytes#getTypeByte(PropertyValue)} */ @Test public void testGetTypeByte() { assertArrayEquals(new byte[] {type}, PropertyValueUtils.Bytes.getTypeByte(propertyValue)); }