org.apache.hadoop.hbase.filter.ByteArrayComparable Java Examples

The following examples show how to use org.apache.hadoop.hbase.filter.ByteArrayComparable. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RangerAuthorizationCoprocessor.java    From ranger with Apache License 2.0 6 votes vote down vote up
@Override
public boolean preCheckAndPutAfterRowLock(ObserverContext<RegionCoprocessorEnvironment> c, byte[] row, byte[] family, byte[] qualifier, CompareOperator compareOp,
										  ByteArrayComparable comparator, Put put, boolean result) throws IOException {
	final boolean ret;

	if(LOG.isDebugEnabled()) {
		LOG.debug("==> RangerAuthorizationCoprocessor.preCheckAndPutAfterRowLock()");
	}

	try {
		activatePluginClassLoader();
		ret = implRegionObserver.preCheckAndPutAfterRowLock(c, row, family, qualifier, compareOp, comparator, put, result);
	} finally {
		deactivatePluginClassLoader();
	}

	if(LOG.isDebugEnabled()) {
		LOG.debug("<== RangerAuthorizationCoprocessor.preCheckAndPutAfterRowLock()");
	}
	return ret;
}
 
Example #2
Source File: ScannerModel.java    From hbase with Apache License 2.0 6 votes vote down vote up
public ByteArrayComparableModel(
    ByteArrayComparable comparator) {
  String typeName = comparator.getClass().getSimpleName();
  ComparatorType type = ComparatorType.valueOf(typeName);
  this.type = typeName;
  switch (type) {
    case BinaryComparator:
    case BinaryPrefixComparator:
      this.value = Bytes.toString(Base64.getEncoder().encode(comparator.getValue()));
      break;
    case BitComparator:
      this.value = Bytes.toString(Base64.getEncoder().encode(comparator.getValue()));
      this.op = ((BitComparator)comparator).getOperator().toString();
      break;
    case NullComparator:
      break;
    case RegexStringComparator:
    case SubstringComparator:
      this.value = Bytes.toString(comparator.getValue());
      break;
    default:
      throw new RuntimeException("unhandled filter type: " + type);
  }
}
 
Example #3
Source File: ProtobufUtil.java    From hbase with Apache License 2.0 6 votes vote down vote up
/**
 * Convert a protocol buffer Comparator to a ByteArrayComparable
 *
 * @param proto the protocol buffer Comparator to convert
 * @return the converted ByteArrayComparable
 */
@SuppressWarnings("unchecked")
public static ByteArrayComparable toComparator(ComparatorProtos.Comparator proto)
throws IOException {
  String type = proto.getName();
  String funcName = "parseFrom";
  byte [] value = proto.getSerializedComparator().toByteArray();
  try {
    Class<?> c = Class.forName(type, true, ClassLoaderHolder.CLASS_LOADER);
    Method parseFrom = c.getMethod(funcName, byte[].class);
    if (parseFrom == null) {
      throw new IOException("Unable to locate function: " + funcName + " in type: " + type);
    }
    return (ByteArrayComparable)parseFrom.invoke(null, value);
  } catch (Exception e) {
    throw new IOException(e);
  }
}
 
Example #4
Source File: RegionCoprocessorHost.java    From hbase with Apache License 2.0 6 votes vote down vote up
/**
 * Supports Coprocessor 'bypass'.
 * @param row row to check
 * @param family column family
 * @param qualifier column qualifier
 * @param op the comparison operation
 * @param comparator the comparator
 * @param put data to put if check succeeds
 * @return true or false to return to client if default processing should be bypassed, or null
 * otherwise
 */
public Boolean preCheckAndPut(final byte [] row, final byte [] family,
    final byte [] qualifier, final CompareOperator op,
    final ByteArrayComparable comparator, final Put put)
    throws IOException {
  boolean bypassable = true;
  boolean defaultResult = false;
  if (coprocEnvironments.isEmpty()) {
    return null;
  }
  return execOperationWithResult(
      new ObserverOperationWithResult<RegionObserver, Boolean>(regionObserverGetter,
          defaultResult,  bypassable) {
        @Override
        public Boolean call(RegionObserver observer) throws IOException {
          return observer.preCheckAndPut(this, row, family, qualifier,
              op, comparator, put, getResult());
        }
      });
}
 
Example #5
Source File: RegionCoprocessorHost.java    From hbase with Apache License 2.0 6 votes vote down vote up
/**
 * Supports Coprocessor 'bypass'.
 * @param row row to check
 * @param family column family
 * @param qualifier column qualifier
 * @param op the comparison operation
 * @param comparator the comparator
 * @param put data to put if check succeeds
 * @return true or false to return to client if default processing should be bypassed, or null
 *   otherwise
 */
@edu.umd.cs.findbugs.annotations.SuppressWarnings(value="NP_BOOLEAN_RETURN_NULL",
    justification="Null is legit")
public Boolean preCheckAndPutAfterRowLock(
    final byte[] row, final byte[] family, final byte[] qualifier, final CompareOperator op,
    final ByteArrayComparable comparator, final Put put) throws IOException {
  boolean bypassable = true;
  boolean defaultResult = false;
  if (coprocEnvironments.isEmpty()) {
    return null;
  }
  return execOperationWithResult(
      new ObserverOperationWithResult<RegionObserver, Boolean>(regionObserverGetter,
          defaultResult, bypassable) {
        @Override
        public Boolean call(RegionObserver observer) throws IOException {
          return observer.preCheckAndPutAfterRowLock(this, row, family, qualifier,
              op, comparator, put, getResult());
        }
      });
}
 
Example #6
Source File: RegionCoprocessorHost.java    From hbase with Apache License 2.0 6 votes vote down vote up
/**
 * @param row row to check
 * @param family column family
 * @param qualifier column qualifier
 * @param op the comparison operation
 * @param comparator the comparator
 * @param put data to put if check succeeds
 * @throws IOException e
 */
public boolean postCheckAndPut(final byte [] row, final byte [] family,
    final byte [] qualifier, final CompareOperator op,
    final ByteArrayComparable comparator, final Put put,
    boolean result) throws IOException {
  if (this.coprocEnvironments.isEmpty()) {
    return result;
  }
  return execOperationWithResult(
      new ObserverOperationWithResult<RegionObserver, Boolean>(regionObserverGetter, result) {
        @Override
        public Boolean call(RegionObserver observer) throws IOException {
          return observer.postCheckAndPut(this, row, family, qualifier,
              op, comparator, put, getResult());
        }
      });
}
 
Example #7
Source File: RegionCoprocessorHost.java    From hbase with Apache License 2.0 6 votes vote down vote up
/**
 * Supports Coprocessor 'bypass'.
 * @param row row to check
 * @param family column family
 * @param qualifier column qualifier
 * @param op the comparison operation
 * @param comparator the comparator
 * @param delete delete to commit if check succeeds
 * @return true or false to return to client if default processing should be bypassed, or null
 *   otherwise
 */
public Boolean preCheckAndDelete(final byte [] row, final byte [] family,
    final byte [] qualifier, final CompareOperator op,
    final ByteArrayComparable comparator, final Delete delete)
    throws IOException {
  boolean bypassable = true;
  boolean defaultResult = false;
  if (coprocEnvironments.isEmpty()) {
    return null;
  }
  return execOperationWithResult(
      new ObserverOperationWithResult<RegionObserver, Boolean>(regionObserverGetter,
          defaultResult, bypassable) {
        @Override
        public Boolean call(RegionObserver observer) throws IOException {
          return observer.preCheckAndDelete(this, row, family,
              qualifier, op, comparator, delete, getResult());
        }
      });
}
 
Example #8
Source File: RangerAuthorizationCoprocessor.java    From ranger with Apache License 2.0 6 votes vote down vote up
@Override
public boolean postCheckAndDelete(ObserverContext<RegionCoprocessorEnvironment> c, byte[] row,byte[] family, byte[] qualifier, CompareOperator compareOp,
								  ByteArrayComparable comparator, Delete delete, boolean result)	throws IOException {
	final boolean ret;

	if(LOG.isDebugEnabled()) {
		LOG.debug("==> RangerAuthorizationCoprocessor.postCheckAndDelete()");
	}

	try {
		activatePluginClassLoader();
		ret = implRegionObserver.postCheckAndDelete(c, row, family, qualifier, compareOp, comparator, delete, result);
	} finally {
		deactivatePluginClassLoader();
	}

	if(LOG.isDebugEnabled()) {
		LOG.debug("<== RangerAuthorizationCoprocessor.postCheckAndDelete()");
	}
	return ret;
}
 
Example #9
Source File: RangerAuthorizationCoprocessor.java    From ranger with Apache License 2.0 6 votes vote down vote up
@Override
public boolean preCheckAndDeleteAfterRowLock(ObserverContext<RegionCoprocessorEnvironment> c, byte[] row, byte[] family, byte[] qualifier, CompareOperator compareOp,
											 ByteArrayComparable comparator, Delete delete, boolean result) throws IOException {
	final boolean ret;

	if(LOG.isDebugEnabled()) {
		LOG.debug("==> RangerAuthorizationCoprocessor.preCheckAndDeleteAfterRowLock()");
	}

	try {
		activatePluginClassLoader();
		ret = implRegionObserver.preCheckAndDeleteAfterRowLock(c, row, family, qualifier, compareOp, comparator, delete, result);
	} finally {
		deactivatePluginClassLoader();
	}

	if(LOG.isDebugEnabled()) {
		LOG.debug("<== RangerAuthorizationCoprocessor.preCheckAndDeleteAfterRowLock()");
	}
	return ret;
}
 
Example #10
Source File: RangerAuthorizationCoprocessor.java    From ranger with Apache License 2.0 6 votes vote down vote up
@Override
public boolean postCheckAndPut(ObserverContext<RegionCoprocessorEnvironment> c, byte[] row, byte[] family, byte[] qualifier, CompareOperator compareOp,
							   ByteArrayComparable comparator, Put put, boolean result) throws IOException {
	final boolean ret;

	if(LOG.isDebugEnabled()) {
		LOG.debug("==> RangerAuthorizationCoprocessor.postCheckAndPut()");
	}

	try {
		activatePluginClassLoader();
		ret = implRegionObserver.postCheckAndPut(c, row, family, qualifier, compareOp, comparator, put, result);
	} finally {
		deactivatePluginClassLoader();
	}

	if(LOG.isDebugEnabled()) {
		LOG.debug("<== RangerAuthorizationCoprocessor.postCheckAndPut()");
	}
	return ret;
}
 
Example #11
Source File: RangerAuthorizationCoprocessor.java    From ranger with Apache License 2.0 6 votes vote down vote up
@Override
public boolean preCheckAndPut(ObserverContext<RegionCoprocessorEnvironment> c, byte[] row, byte[] family, byte[] qualifier, CompareOperator compareOp, ByteArrayComparable comparator, Put put, boolean result) throws IOException {
	final boolean ret;

	if(LOG.isDebugEnabled()) {
		LOG.debug("==> RangerAuthorizationCoprocessor.preCheckAndPut()");
	}

	try {
		activatePluginClassLoader();
		ret = implRegionObserver.preCheckAndPut(c, row, family, qualifier, compareOp, comparator, put, result);
	} finally {
		deactivatePluginClassLoader();
	}

	if(LOG.isDebugEnabled()) {
		LOG.debug("<== RangerAuthorizationCoprocessor.preCheckAndPut()");
	}

	return ret;
}
 
Example #12
Source File: RangerAuthorizationCoprocessor.java    From ranger with Apache License 2.0 6 votes vote down vote up
@Override
public boolean preCheckAndDelete(ObserverContext<RegionCoprocessorEnvironment> c, byte[] row, byte[] family, byte[] qualifier, CompareOperator compareOp, ByteArrayComparable comparator, Delete delete, boolean result) throws IOException {
	final boolean ret;

	if(LOG.isDebugEnabled()) {
		LOG.debug("==> RangerAuthorizationCoprocessor.preCheckAndDelete()");
	}

	try {
		activatePluginClassLoader();
		ret = implRegionObserver.preCheckAndDelete(c, row, family, qualifier, compareOp, comparator, delete, result);
	} finally {
		deactivatePluginClassLoader();
	}

	if(LOG.isDebugEnabled()) {
		LOG.debug("<== RangerAuthorizationCoprocessor.preCheckAndDelete()");
	}

	return ret;
}
 
Example #13
Source File: RegionCoprocessorHost.java    From hbase with Apache License 2.0 6 votes vote down vote up
/**
 * Supports Coprocessor 'bypass'.
 * @param row row to check
 * @param family column family
 * @param qualifier column qualifier
 * @param op the comparison operation
 * @param comparator the comparator
 * @param delete delete to commit if check succeeds
 * @return true or false to return to client if default processing should be bypassed,
 * or null otherwise
 */
@edu.umd.cs.findbugs.annotations.SuppressWarnings(value="NP_BOOLEAN_RETURN_NULL",
    justification="Null is legit")
public Boolean preCheckAndDeleteAfterRowLock(final byte[] row, final byte[] family,
    final byte[] qualifier, final CompareOperator op, final ByteArrayComparable comparator,
    final Delete delete) throws IOException {
  boolean bypassable = true;
  boolean defaultResult = false;
  if (coprocEnvironments.isEmpty()) {
    return null;
  }
  return execOperationWithResult(
      new ObserverOperationWithResult<RegionObserver, Boolean>(regionObserverGetter,
          defaultResult, bypassable) {
        @Override
        public Boolean call(RegionObserver observer) throws IOException {
          return observer.preCheckAndDeleteAfterRowLock(this, row,
              family, qualifier, op, comparator, delete, getResult());
        }
      });
}
 
Example #14
Source File: RegionCoprocessorHost.java    From hbase with Apache License 2.0 6 votes vote down vote up
/**
 * @param row row to check
 * @param family column family
 * @param qualifier column qualifier
 * @param op the comparison operation
 * @param comparator the comparator
 * @param delete delete to commit if check succeeds
 * @throws IOException e
 */
public boolean postCheckAndDelete(final byte [] row, final byte [] family,
    final byte [] qualifier, final CompareOperator op,
    final ByteArrayComparable comparator, final Delete delete,
    boolean result) throws IOException {
  if (this.coprocEnvironments.isEmpty()) {
    return result;
  }
  return execOperationWithResult(
      new ObserverOperationWithResult<RegionObserver, Boolean>(regionObserverGetter, result) {
        @Override
        public Boolean call(RegionObserver observer) throws IOException {
          return observer.postCheckAndDelete(this, row, family,
              qualifier, op, comparator, delete, getResult());
        }
      });
}
 
Example #15
Source File: DeserializedNumericComparator.java    From pentaho-hadoop-shims with Apache License 2.0 6 votes vote down vote up
/**
 * Needed for hbase-0.95+
 *
 * @throws java.io.IOException
 */
public static ByteArrayComparable parseFrom( final byte[] pbBytes ) {
  DataInput in = new DataInputStream( new ByteArrayInputStream( pbBytes ) );
  try {
    boolean m_isInteger = in.readBoolean();
    boolean m_isLongOrDouble = in.readBoolean();
    long m_longValue = in.readLong();
    double m_doubleValue = in.readDouble();
    if ( m_isInteger ) {
      return new DeserializedNumericComparator( m_isInteger, m_isLongOrDouble, m_longValue );
    } else {
      return new DeserializedNumericComparator( m_isInteger, m_isLongOrDouble, m_doubleValue );
    }
  } catch ( IOException e ) {
    throw new RuntimeException( "Unable to deserialize byte array", e );
  }
}
 
Example #16
Source File: PrivateCellUtil.java    From hbase with Apache License 2.0 5 votes vote down vote up
/**
 * Compare cell's qualifier against given comparator
 * @param cell the cell to use for comparison
 * @param comparator the {@link CellComparator} to use for comparison
 * @return result comparing cell's qualifier
 */
public static int compareQualifier(Cell cell, ByteArrayComparable comparator) {
  if (cell instanceof ByteBufferExtendedCell) {
    return comparator.compareTo(((ByteBufferExtendedCell) cell).getQualifierByteBuffer(),
      ((ByteBufferExtendedCell) cell).getQualifierPosition(), cell.getQualifierLength());
  }
  return comparator.compareTo(cell.getQualifierArray(), cell.getQualifierOffset(),
    cell.getQualifierLength());
}
 
Example #17
Source File: SimpleRegionObserver.java    From hbase with Apache License 2.0 5 votes vote down vote up
@Override
public boolean preCheckAndPut(ObserverContext<RegionCoprocessorEnvironment> e, byte[] row,
                              byte[] family, byte[] qualifier, CompareOperator compareOp, ByteArrayComparable comparator,
                              Put put, boolean result) throws IOException {
  ctPreCheckAndPut.incrementAndGet();
  return true;
}
 
Example #18
Source File: SimpleRegionObserver.java    From hbase with Apache License 2.0 5 votes vote down vote up
@Override
public boolean preCheckAndPutAfterRowLock(ObserverContext<RegionCoprocessorEnvironment> e,
    byte[] row, byte[] family, byte[] qualifier, CompareOperator compareOp,
    ByteArrayComparable comparator, Put put, boolean result) throws IOException {
  ctPreCheckAndPutAfterRowLock.incrementAndGet();
  return true;
}
 
Example #19
Source File: SimpleRegionObserver.java    From hbase with Apache License 2.0 5 votes vote down vote up
@Override
public boolean postCheckAndPut(ObserverContext<RegionCoprocessorEnvironment> e, byte[] row,
                               byte[] family, byte[] qualifier, CompareOperator compareOp, ByteArrayComparable comparator,
                               Put put, boolean result) throws IOException {
  ctPostCheckAndPut.incrementAndGet();
  return true;
}
 
Example #20
Source File: SimpleRegionObserver.java    From hbase with Apache License 2.0 5 votes vote down vote up
@Override
public boolean preCheckAndDelete(ObserverContext<RegionCoprocessorEnvironment> e, byte[] row,
                                 byte[] family, byte[] qualifier, CompareOperator compareOp, ByteArrayComparable comparator,
                                 Delete delete, boolean result) throws IOException {
  ctPreCheckAndDelete.incrementAndGet();
  return true;
}
 
Example #21
Source File: TestPassCustomCellViaRegionObserver.java    From hbase with Apache License 2.0 5 votes vote down vote up
@Override
public boolean preCheckAndPut(ObserverContext<RegionCoprocessorEnvironment> c, byte[] row,
  byte[] family, byte[] qualifier, CompareOperator op, ByteArrayComparable comparator, Put put,
  boolean result) throws IOException {
  put.add(createCustomCell(put));
  COUNT.incrementAndGet();
  return result;
}
 
Example #22
Source File: TestPassCustomCellViaRegionObserver.java    From hbase with Apache License 2.0 5 votes vote down vote up
@Override
public boolean preCheckAndDelete(ObserverContext<RegionCoprocessorEnvironment> c, byte[] row,
  byte[] family, byte[] qualifier, CompareOperator op, ByteArrayComparable comparator,
  Delete delete, boolean result) throws IOException {
  delete.add(createCustomCell(delete));
  COUNT.incrementAndGet();
  return result;
}
 
Example #23
Source File: ProtobufUtil.java    From hbase with Apache License 2.0 5 votes vote down vote up
/**
 * Convert a ByteArrayComparable to a protocol buffer Comparator
 *
 * @param comparator the ByteArrayComparable to convert
 * @return the converted protocol buffer Comparator
 */
public static ComparatorProtos.Comparator toComparator(ByteArrayComparable comparator) {
  ComparatorProtos.Comparator.Builder builder = ComparatorProtos.Comparator.newBuilder();
  builder.setName(comparator.getClass().getName());
  builder.setSerializedComparator(UnsafeByteOperations.unsafeWrap(comparator.toByteArray()));
  return builder.build();
}
 
Example #24
Source File: SimpleRegionObserver.java    From hbase with Apache License 2.0 5 votes vote down vote up
@Override
public boolean preCheckAndDeleteAfterRowLock(ObserverContext<RegionCoprocessorEnvironment> e,
    byte[] row, byte[] family, byte[] qualifier, CompareOperator compareOp,
    ByteArrayComparable comparator, Delete delete, boolean result) throws IOException {
  ctPreCheckAndDeleteAfterRowLock.incrementAndGet();
  return true;
}
 
Example #25
Source File: SimpleRegionObserver.java    From hbase with Apache License 2.0 5 votes vote down vote up
@Override
public boolean postCheckAndDelete(ObserverContext<RegionCoprocessorEnvironment> e, byte[] row,
                                  byte[] family, byte[] qualifier, CompareOperator compareOp, ByteArrayComparable comparator,
                                  Delete delete, boolean result) throws IOException {
  ctPostCheckAndDelete.incrementAndGet();
  return true;
}
 
Example #26
Source File: AccessController.java    From hbase with Apache License 2.0 5 votes vote down vote up
@Override
public boolean preCheckAndPut(final ObserverContext<RegionCoprocessorEnvironment> c,
    final byte [] row, final byte [] family, final byte [] qualifier,
    final CompareOperator op,
    final ByteArrayComparable comparator, final Put put,
    final boolean result) throws IOException {
  User user = getActiveUser(c);
  checkForReservedTagPresence(user, put);

  // Require READ and WRITE permissions on the table, CF, and KV to update
  RegionCoprocessorEnvironment env = c.getEnvironment();
  Map<byte[],? extends Collection<byte[]>> families = makeFamilyMap(family, qualifier);
  AuthResult authResult = permissionGranted(OpType.CHECK_AND_PUT,
      user, env, families, Action.READ, Action.WRITE);
  AccessChecker.logResult(authResult);
  if (!authResult.isAllowed()) {
    if (cellFeaturesEnabled && !compatibleEarlyTermination) {
      put.setAttribute(CHECK_COVERING_PERM, TRUE);
    } else if (authorizationEnabled) {
      throw new AccessDeniedException("Insufficient permissions " +
        authResult.toContextString());
    }
  }

  byte[] bytes = put.getAttribute(AccessControlConstants.OP_ATTRIBUTE_ACL);
  if (bytes != null) {
    if (cellFeaturesEnabled) {
      addCellPermissions(bytes, put.getFamilyCellMap());
    } else {
      throw new DoNotRetryIOException("Cell ACLs cannot be persisted");
    }
  }
  return result;
}
 
Example #27
Source File: HBaseFilterBuilder.java    From pxf with Apache License 2.0 5 votes vote down vote up
/**
 * Handles simple column-operator-constant expressions.
 * Creates a special filter in the case the column is the row key column.
 *
 * @param hBaseColumn  the HBase column
 * @param operator the simple column operator
 * @param data         the optional operand
 * @return the {@link Filter} for the given simple column operator
 */
private Filter processSimpleColumnOperator(HBaseColumnDescriptor hBaseColumn,
                                           Operator operator,
                                           OperandNode data) {
    // The value of lastOperand has to be stored after visiting
    // the operand child of this node.
    ByteArrayComparable comparator = getComparator(
            hBaseColumn.columnTypeCode(),
            data);

    /*
     * If row key is of type TEXT, allow filter in start/stop row
     * key API in HBaseAccessor/Scan object.
     */
    if (data != null && isTextualRowKey(hBaseColumn)) {
        storeStartEndKeys(operator, data.toString());
    }

    if (hBaseColumn.isKeyColumn()) {
        // Special filter for row key column
        return new RowFilter(
                OPERATORS_MAP.get(operator),
                comparator);
    } else {
        return new SingleColumnValueFilter(
                hBaseColumn.columnFamilyBytes(),
                hBaseColumn.qualifierBytes(),
                OPERATORS_MAP.get(operator),
                comparator);
    }
}
 
Example #28
Source File: HBaseDoubleComparator.java    From pxf with Apache License 2.0 5 votes vote down vote up
public static ByteArrayComparable parseFrom(final byte[] pbBytes) throws DeserializationException {
    ComparatorProtos.ByteArrayComparable proto;
    try {
        proto = ComparatorProtos.ByteArrayComparable.parseFrom(pbBytes);
    } catch (InvalidProtocolBufferException e) {
        throw new DeserializationException(e);
    }

    return new HBaseDoubleComparator(Bytes.toDouble(proto.getValue().toByteArray()));
}
 
Example #29
Source File: HBaseFloatComparator.java    From pxf with Apache License 2.0 5 votes vote down vote up
public static ByteArrayComparable parseFrom(final byte[] pbBytes) throws DeserializationException {
    ComparatorProtos.ByteArrayComparable proto;
    try {
        proto = ComparatorProtos.ByteArrayComparable.parseFrom(pbBytes);
    } catch (InvalidProtocolBufferException e) {
        throw new DeserializationException(e);
    }

    return new HBaseFloatComparator(Bytes.toFloat(proto.getValue().toByteArray()));
}
 
Example #30
Source File: HBaseIntegerComparator.java    From pxf with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the comparator serialized using Protocol Buffers.
 *
 * @return serialized comparator
 */
@Override
public byte[] toByteArray() {
	ComparatorProtos.ByteArrayComparable.Builder builder = ComparatorProtos.ByteArrayComparable.newBuilder();
	builder.setValue(ByteString.copyFrom(getValue()));
	return builder.build().toByteArray();
}