@Override public String toString() { StringBuffer buf = new StringBuffer(); buf.append(size()); buf.append(':'); if (size() > 0) { for (Map.Entry<String, String> entry : entrySet()) { int length = (entry.getKey() == null) ? 0 : entry.getKey().length(); buf.append(entry.getKey() == null ? 0 : length); buf.append(':'); if (length > 0) buf.append(entry.getKey()); length = (entry.getValue() == null) ? 0 : entry.getValue().length(); buf.append(length); buf.append(':'); if (length > 0) buf.append(entry.getValue()); } } return buf.toString(); }
StringableMap(String s) { String[] parts = s.split(":", 2); // read that many chars int numElements = Integer.valueOf(parts[0]); s = parts[1]; for (int i = 0; i < numElements; i++) { parts = s.split(":", 2); int len = Integer.valueOf(parts[0]); String key = null; if (len > 0) key = parts[1].substring(0, len); parts = parts[1].substring(len).split(":", 2); len = Integer.valueOf(parts[0]); String value = null; if (len > 0) value = parts[1].substring(0, len); s = parts[1].substring(len); put(key, value); } }
job.setBoolean(IS_MAJOR, isMajor); job.setBoolean(IS_COMPRESSED, sd.isCompressed()); job.set(TABLE_PROPS, new StringableMap(t.getParameters()).toString()); job.setInt(NUM_BUCKETS, sd.getNumBuckets()); job.set(ValidTxnList.VALID_TXNS_KEY, txns.toString());
private void getWriter(Reporter reporter, ObjectInspector inspector, int bucket) throws IOException { if (writer == null) { AcidOutputFormat.Options options = new AcidOutputFormat.Options(jobConf); options.inspector(inspector) .writingBase(jobConf.getBoolean(IS_MAJOR, false)) .isCompressed(jobConf.getBoolean(IS_COMPRESSED, false)) .tableProperties(new StringableMap(jobConf.get(TABLE_PROPS)).toProperties()) .reporter(reporter) .minimumTransactionId(jobConf.getLong(MIN_TXN, Long.MAX_VALUE)) .maximumTransactionId(jobConf.getLong(MAX_TXN, Long.MIN_VALUE)) .bucket(bucket); // Instantiate the underlying output format @SuppressWarnings("unchecked")//since there is no way to parametrize instance of Class AcidOutputFormat<WritableComparable, V> aof = instantiate(AcidOutputFormat.class, jobConf.get(OUTPUT_FORMAT_CLASS_NAME)); writer = aof.getRawRecordWriter(new Path(jobConf.get(TMP_LOCATION)), options); } }