protected Text getBinaryValue(ConstantObjectInspector objInspector) throws IOException {
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    if (objInspector instanceof PrimitiveObjectInspector) {
      LazyUtils.writePrimitive(out, objInspector.getWritableConstantValue(),
          (PrimitiveObjectInspector) objInspector);
    } else {
      return getUtf8Value(objInspector);
    }

    out.close();
    return new Text(out.toByteArray());
  }
Attempts to construct the binary value from the given inspector. Falls back to UTF8 encoding
when the value cannot be coerced into binary.

@return Binary value when possible, utf8 otherwise
@throws IOException
accumulo-handler/src/java/org/apache/hadoop/hive/accumulo/predicate/AccumuloRangeGenerator.java