public TableMeta(String dataFormat, KeyValueSet propertySet) { this.dataFormat = dataFormat; this.propertySet = new KeyValueSet(propertySet); }
public static KeyValueSet newPhysicalProperties(CatalogProtos.StoreType type) { KeyValueSet options = new KeyValueSet(); if (CatalogProtos.StoreType.CSV == type) { options.set(CSVFILE_DELIMITER, DEFAULT_FIELD_DELIMITER); } else if (CatalogProtos.StoreType.RCFILE == type) { options.set(RCFILE_SERDE, DEFAULT_BINARY_SERDE); } else if (CatalogProtos.StoreType.SEQUENCEFILE == type) { options.set(SEQUENCEFILE_SERDE, DEFAULT_TEXT_SERDE); options.set(SEQUENCEFILE_DELIMITER, DEFAULT_FIELD_DELIMITER); } else if (type == CatalogProtos.StoreType.PARQUET) { options.set(ParquetOutputFormat.BLOCK_SIZE, PARQUET_DEFAULT_BLOCK_SIZE); options.set(ParquetOutputFormat.PAGE_SIZE, PARQUET_DEFAULT_PAGE_SIZE); options.set(ParquetOutputFormat.COMPRESSION, PARQUET_DEFAULT_COMPRESSION_CODEC_NAME); options.set(ParquetOutputFormat.ENABLE_DICTIONARY, PARQUET_DEFAULT_IS_DICTIONARY_ENABLED); options.set(ParquetOutputFormat.VALIDATION, PARQUET_DEFAULT_IS_VALIDATION_ENABLED); } return options; }
public static KeyValueSetProto convertFromMap(Map<String, String> map) { return new KeyValueSet(map).getProto(); }
public boolean getBool(String key, Boolean defaultVal) { if (containsKey(key)) { String strVal = get(key, null); return strVal != null && strVal.equalsIgnoreCase(TRUE_STR); } else if (defaultVal != null) { return defaultVal; } else { return false; } }
@Override public SessionProto getProto() { SessionProto.Builder builder = SessionProto.newBuilder(); builder.setSessionId(getSessionId()); builder.setUsername(getUserName()); builder.setCurrentDatabase(getCurrentDatabase()); builder.setLastAccessTime(lastAccessTime); KeyValueSet variables = new KeyValueSet(); synchronized (sessionVariables) { variables.putAll(this.sessionVariables); builder.setVariables(variables.getProto()); return builder.build(); } }
options = new KeyValueSet(); options.putAll(table.getParameters()); options.remove("EXTERNAL"); options.remove(serdeConstants.SERIALIZATION_NULL_FORMAT); options.set(StorageConstants.TEXT_DELIMITER, StringEscapeUtils.escapeJava(fieldDelimiter)); options.set(StorageConstants.TEXT_NULL, StringEscapeUtils.escapeJava(nullFormat)); options.set(StorageConstants.RCFILE_NULL, StringEscapeUtils.escapeJava(nullFormat)); String serde = properties.getProperty(serdeConstants.SERIALIZATION_LIB); if (LazyBinaryColumnarSerDe.class.getName().equals(serde)) { options.set(StorageConstants.RCFILE_SERDE, StorageConstants.DEFAULT_BINARY_SERDE); } else if (ColumnarSerDe.class.getName().equals(serde)) { options.set(StorageConstants.RCFILE_SERDE, StorageConstants.DEFAULT_TEXT_SERDE); options.set(StorageConstants.TEXT_DELIMITER, StringEscapeUtils.escapeJava(fieldDelimiter)); options.set(StorageConstants.TEXT_NULL, StringEscapeUtils.escapeJava(nullFormat)); String serde = properties.getProperty(serdeConstants.SERIALIZATION_LIB); if (LazyBinarySerDe.class.getName().equals(serde)) { options.set(StorageConstants.SEQUENCEFILE_SERDE, StorageConstants.DEFAULT_BINARY_SERDE); } else if (LazySimpleSerDe.class.getName().equals(serde)) { options.set(StorageConstants.SEQUENCEFILE_SERDE, StorageConstants.DEFAULT_TEXT_SERDE); options.set(StorageConstants.TEXT_REGEX, properties.getProperty(RegexSerDe.INPUT_REGEX)); options.set(StorageConstants.TEXT_REGEX_CASE_INSENSITIVE, properties.getProperty(RegexSerDe.INPUT_REGEX_CASE_SENSITIVE)); options.set(StorageConstants.TEXT_REGEX_OUTPUT_FORMAT_STRING, properties.getProperty("output.format.string"));
KeyValueSet options = new KeyValueSet(); options.putAll(expr.getParams()); insertNode.setOptions(options);
public void putOption(String key, String val) { options.set(key, val); }
public Session(SessionProto proto) { sessionId = proto.getSessionId(); userName = proto.getUsername(); currentDatabase = proto.getCurrentDatabase(); lastAccessTime = proto.getLastAccessTime(); KeyValueSet keyValueSet = new KeyValueSet(proto.getVariables()); sessionVariables = keyValueSet.getAllKeyValus(); }
public TableProto getProto() { TableProto.Builder builder = TableProto.newBuilder(); builder.setDataFormat(dataFormat); builder.setParams(options.getProto()); return builder.build(); }
public String getOption(String key, String defaultValue) { return options.get(key, defaultValue); }
public KeyValueSet(Map<String, String> keyVals) { this(); putAll(keyVals); }
table.setDbName(databaseName); table.setTableName(tableName); table.setParameters(new HashMap<>(tableDesc.getMeta().getPropertySet().getAllKeyValus())); if (tableDesc.getMeta().getPropertySet().containsKey(StorageConstants.RCFILE_NULL)) { table.putToParameters(serdeConstants.SERIALIZATION_NULL_FORMAT, StringEscapeUtils.unescapeJava(tableDesc.getMeta().getProperty(StorageConstants.RCFILE_NULL)));
private static void buildWithClause(final StringBuilder sb, TableMeta meta) { KeyValueSet options = meta.getOptions(); if (options != null && options.size() > 0) { sb.append(" WITH ("); // sort table properties in an lexicographic order of the property keys. Map.Entry<String, String>[] entries = meta.getOptions().getAllKeyValus().entrySet().toArray( new Map.Entry[meta.getOptions().size()]); Arrays.sort(entries, new Comparator<Map.Entry<String, String>>() { @Override public int compare(Map.Entry<String, String> o1, Map.Entry<String, String> o2) { return o1.getKey().compareTo(o2.getKey()); } }); // Join all properties by comma (',') sb.append(StringUtils.join(entries, ", ", new Function<Map.Entry<String, String>, String>() { @Override public String apply(Map.Entry<String, String> e) { return "'" + e.getKey() + "'='" + e.getValue() + "'"; } })); sb.append(")"); } }
public Map<String,String> toMap() { return getPropertySet().getAllKeyValus(); }
@Test public final void testAlterTableUnsetProperty() throws Exception { executeDDL("table2_ddl.sql", "table2.tbl", "ALTY"); String tableName = IdentifierUtil.buildFQName(getCurrentDatabase(), "alty"); assertTrue(catalog.existsTable(tableName)); TableDesc tableDesc = catalog.getTableDesc(tableName); TableMeta tableMeta = tableDesc.getMeta(); assertEquals(tableMeta.getPropertySet().size(), 3); assertNotNull(tableMeta.getProperty("timezone")); assertNotNull(tableMeta.getProperty("text.null")); assertEquals(tableMeta.getProperty("text.delimiter"), "\\u002b"); executeDDL("alter_table_unset_property_delimiter.sql", null); tableDesc = catalog.getTableDesc(tableName); tableMeta = tableDesc.getMeta(); assertEquals(tableMeta.getPropertySet().size(), 2); assertNotNull(tableMeta.getProperty("timezone")); assertNotNull(tableMeta.getProperty("text.null")); assertFalse(tableMeta.getPropertySet().containsKey("text.delimiter")); executeDDL("alter_table_unset_not_exists_property.sql", null); tableDesc = catalog.getTableDesc(tableName); tableMeta = tableDesc.getMeta(); assertEquals(tableMeta.getPropertySet().size(), 2); assertNotNull(tableMeta.getProperty("timezone")); assertNotNull(tableMeta.getProperty("text.null")); assertFalse(tableMeta.getPropertySet().containsKey("text.delimiter")); }
public boolean containsOption(String key) { return options.containsKey(key); }
@Override public SessionProto getProto() { SessionProto.Builder builder = SessionProto.newBuilder(); builder.setSessionId(getSessionId()); builder.setUsername(getUserName()); builder.setCurrentDatabase(getCurrentDatabase()); builder.setLastAccessTime(lastAccessTime); KeyValueSet variables = new KeyValueSet(); synchronized (sessionVariables) { variables.putAll(this.sessionVariables); builder.setVariables(variables.getProto()); return builder.build(); } }
KeyValueSet options = new KeyValueSet(); options.putAll(expr.getParams()); insertNode.setOptions(options);
public void setBool(String key, boolean val) { set(key, val ? TRUE_STR : FALSE_STR); }