code: public static byte[] scalarValueToBinary(TableDefinition tableDef, String fieldName, String fieldValue) {
          if (fieldValue == null || fieldValue.length() == 0) {
              return null;    // means "don't store".
          }
          FieldDefinition fieldDef = tableDef.getFieldDef(fieldName);
          if (fieldDef != null && fieldDef.isBinaryField()) {
              return fieldDef.getEncoding().decode(fieldValue);
          } else {
              return Utils.toBytes(fieldValue);
          }
      }
docs: Convert the given scalar value to binary form. This method returns the appropriate
  format for storage based on the scalar's type. This method is the twin of
  {@link #scalarValueToString(TableDefinition, String, byte[])}
  
  @param tableDef      {@link TableDefinition} of table in which field resides.
  @param fieldName     Scalar field name.
  @param fieldValue    Field value in string form (may be null).
  @return              Binary storage format.