Refine search
public static void setEndKey(Configuration conf, byte[] endKey) { conf.set(END_BASE64, Base64.encodeBytes(endKey)); }
/** * Main program. Used for testing. * * Encodes or decodes two files from the command line * * @param args command arguments */ public static void main(String[] args) { if (args.length < 3) { usage("Not enough arguments."); } else { String flag = args[0]; String infile = args[1]; String outfile = args[2]; if (flag.equals("-e")) { // encode encodeFileToFile(infile, outfile); } else if (flag.equals("-d")) { // decode decodeFileToFile(infile, outfile); } else { usage("Unknown flag: " + flag); } } } // end main
throws IOException, ClassNotFoundException { Job job = null; boolean isDryRun = conf.getBoolean(DRY_RUN_CONF_KEY, false); try (Connection connection = ConnectionFactory.createConnection(conf)) { try (Admin admin = connection.getAdmin()) { String actualSeparator = conf.get(SEPARATOR_CONF_KEY); if (actualSeparator != null) { conf.set(SEPARATOR_CONF_KEY, Base64.encodeBytes(actualSeparator.getBytes()));
/** * Handles common parameter initialization that a subclass might want to leverage. * @param context */ protected void doSetup(Context context) { Configuration conf = context.getConfiguration(); // If a custom separator has been used, // decode it back from Base64 encoding. separator = conf.get(ImportTsv.SEPARATOR_CONF_KEY); if (separator == null) { separator = ImportTsv.DEFAULT_SEPARATOR; } else { separator = new String(Base64.decode(separator)); } // Should never get 0 as we are setting this to a valid value in job // configuration. ts = conf.getLong(ImportTsv.TIMESTAMP_CONF_KEY, 0); skipBadLines = context.getConfiguration().getBoolean( ImportTsv.SKIP_LINES_CONF_KEY, true); badLineCount = context.getCounter("ImportTsv", "Bad Lines"); }
String actualSeparator = conf.get(SEPARATOR_CONF_KEY); if (actualSeparator != null) { conf.set(SEPARATOR_CONF_KEY, Base64.encodeBytes(actualSeparator.getBytes())); String mapperClassName = conf.get(MAPPER_CONF_KEY); Class mapperClass = mapperClassName != null ? Class.forName(mapperClassName) : DEFAULT_MAPPER;
/** * Handles common parameter initialization that a subclass might want to leverage. * @param context */ protected void doSetup(Context context) { Configuration conf = context.getConfiguration(); // If a custom separator has been used, // decode it back from Base64 encoding. separator = conf.get(ImportTsv.SEPARATOR_CONF_KEY); if (separator == null) { separator = ImportTsv.DEFAULT_SEPARATOR; } else { separator = new String(Base64.decode(separator)); } skipBadLines = context.getConfiguration().getBoolean(ImportTsv.SKIP_LINES_CONF_KEY, true); badLineCount = context.getCounter("ImportTsv", "Bad Lines"); }
/** * Encodes a byte array into Base64 notation. Does not GZip-compress data. * * @param source The data to convert * @param off Offset in array where conversion should begin * @param len Length of data to convert * @return encoded byte array * @since 1.4 */ public static String encodeBytes(byte[] source, int off, int len) { return encodeBytes(source, off, len, NO_OPTIONS); } // end encodeBytes
@Override public Object toObject(String value) { if (value == null || value.length() == 0) { return null; } return Base64.decode(value); }
byte[] inToken = Base64.decode(serviceTicketBase64); byte[] res = gssContext.acceptSecContext(inToken, 0, inToken.length); if(res != null) { outToken = Base64.encodeBytes(res).replace("\n", "");
buffer[position++] = (byte) theByte; if (position >= bufferLength) { // Enough to encode. out.write(encode3to4(b4, buffer, bufferLength, options)); lineLength += 4; if (breakLines && lineLength >= MAX_LINE_LENGTH) { buffer[position++] = (byte) theByte; if (position >= bufferLength) { // Enough to output. int len = decode4to3(buffer, 0, b4, 0, options); out.write(b4, 0, len); position = 0;
byte[] DECODABET = getDecodabet(options); b4[b4Posn++] = sbiCrop; if (b4Posn > 3) { outBuffPosn += decode4to3(b4, 0, outBuff, outBuffPosn, options); b4Posn = 0;
/** * Encodes up to the first three bytes of array <var>threeBytes</var> and * returns a four-byte array in Base64 notation. The actual number of * significant bytes in your array is given by <var>numSigBytes</var>. The * array <var>threeBytes</var> needs only be as big as <var>numSigBytes</var>. * Code can reuse a byte array by passing a four-byte array as <var>b4</var>. * * @param b4 A reusable byte array to reduce array instantiation * @param threeBytes the array to convert * @param numSigBytes the number of significant bytes in your array * @param options options for get alphabet * @return four byte array in Base64 notation. * @since 1.5.1 */ protected static byte[] encode3to4(byte[] b4, byte[] threeBytes, int numSigBytes, int options) { encode3to4(threeBytes, 0, numSigBytes, b4, 0, options); return b4; } // end encode3to4
/** * Reads <tt>infile</tt> and decodes it to <tt>outfile</tt>. * * @param infile Input file * @param outfile Output file * @since 2.2 */ public static void decodeFileToFile(String infile, String outfile) { byte[] decoded = decodeFromFile(infile); OutputStream out = null; try { out = new BufferedOutputStream(new FileOutputStream(outfile)); out.write(decoded); } catch (IOException e) { LOG.error("error decoding from file " + infile + " to " + outfile, e); } finally { if (out != null) { try { out.close(); } catch (Exception e) { LOG.error("error closing " + outfile, e); } } } // end finally } // end decodeFileToFile
String actualSeparator = conf.get(SEPARATOR_CONF_KEY); if (actualSeparator != null) { conf.set(SEPARATOR_CONF_KEY, Base64.encodeBytes(actualSeparator.getBytes())); String mapperClassName = conf.get(MAPPER_CONF_KEY); Class mapperClass = mapperClassName != null ? Class.forName(mapperClassName) : DEFAULT_MAPPER;
/** * Handles common parameter initialization that a subclass might want to leverage. * @param context */ protected void doSetup(Context context) { Configuration conf = context.getConfiguration(); // If a custom separator has been used, // decode it back from Base64 encoding. separator = conf.get(ImportTsv.SEPARATOR_CONF_KEY); if (separator == null) { separator = ImportTsv.DEFAULT_SEPARATOR; } else { separator = new String(Base64.decode(separator)); } // Should never get 0 as we are setting this to a valid value in job // configuration. ts = conf.getLong(ImportTsv.TIMESTAMP_CONF_KEY, 0); skipBadLines = context.getConfiguration().getBoolean( ImportTsv.SKIP_LINES_CONF_KEY, true); badLineCount = context.getCounter("ImportTsv", "Bad Lines"); hfileOutPath = conf.get(ImportTsv.BULK_OUTPUT_CONF_KEY); }
/** * Handles common parameter initialization that a subclass might want to leverage. * @param context */ protected void doSetup(Context context) { Configuration conf = context.getConfiguration(); // If a custom separator has been used, // decode it back from Base64 encoding. separator = conf.get(ImportTsv.SEPARATOR_CONF_KEY); if (separator == null) { separator = ImportTsv.DEFAULT_SEPARATOR; } else { separator = new String(Base64.decode(separator)); } skipBadLines = context.getConfiguration().getBoolean(ImportTsv.SKIP_LINES_CONF_KEY, true); logBadLines = context.getConfiguration().getBoolean(ImportTsv.LOG_BAD_LINES_CONF_KEY, false); badLineCount = context.getCounter("ImportTsv", "Bad Lines"); }
/** * Encodes a byte array into Base64 notation. Does not GZip-compress data. * * @param source The data to convert * @return encoded byte array * @since 1.4 */ public static String encodeBytes(byte[] source) { return encodeBytes(source, 0, source.length, NO_OPTIONS); } // end encodeBytes
@Override public Object toObject(String value) { if (value == null || value.length() == 0) { return null; } return Base64.decode(value); }
buffer[position++] = (byte) theByte; if (position >= bufferLength) { // Enough to encode. out.write(encode3to4(b4, buffer, bufferLength, options)); lineLength += 4; if (breakLines && lineLength >= MAX_LINE_LENGTH) { buffer[position++] = (byte) theByte; if (position >= bufferLength) { // Enough to output. int len = decode4to3(buffer, 0, b4, 0, options); out.write(b4, 0, len); position = 0;