@JsonIgnore public String getQualifiedName() { return namespace.isEmptyNamespace() || namespace.getName().equals("met") ? tablename : namespace.getName() + "." + tablename; }
public static String getTableReferenceString(String tableName, Namespace namespace) { Preconditions.checkArgument(isTableNameValid(tableName), "%s is not a valid table name", tableName); String namespaceName = namespace.getName(); // Hacks for schemas that were created before namespaces were created. if (namespace.isEmptyNamespace() || namespaceName.equals("met")) { return "TableReference.createWithEmptyNamespace(\"" + tableName + "\")"; } else { return "TableReference.createFromFullyQualifiedName(\"" + namespace.getName() + "." + tableName + "\")"; } }
@Value.Check protected final void check() { Preconditions.checkState( metadataTable().getNamespace().isEmptyNamespace(), "'metadataTable' should have empty namespace'"); }
@Override public TableReference getMappedTableName(TableReference tableRef) throws TableMappingNotFoundException { if (tableRef.getNamespace().isEmptyNamespace()) { return tableRef; } if (tableMap.get().containsKey(tableRef)) { TableReference shortName = tableMap.get().get(tableRef); validateShortName(tableRef, shortName); return tableMap.get().get(tableRef); } else { updateTableMap(); TableReference shortTableName = tableMap.get().get(tableRef); if (shortTableName != null) { return shortTableName; } throw new TableMappingNotFoundException("Unable to resolve full name for table reference " + tableRef); } }
@Override public TableReference addTable(TableReference tableRef) { if (tableRef.getNamespace().isEmptyNamespace()) { return tableRef; } if (tableMap.get().containsKey(tableRef)) { return tableMap.get().get(tableRef); } Cell key = Cell.create(getBytesForTableRef(tableRef), AtlasDbConstants.NAMESPACE_SHORT_COLUMN_BYTES); String shortName = AtlasDbConstants.NAMESPACE_PREFIX + Preconditions.checkNotNull(uniqueLongSupplier.get(), "uniqueLongSupplier returned null"); byte[] value = PtBytes.toBytes(shortName); try { kv.putUnlessExists(AtlasDbConstants.NAMESPACE_TABLE, ImmutableMap.of(key, value)); } catch (KeyAlreadyExistsException e) { return getAlreadyExistingMappedTableName(tableRef); } return TableReference.createWithEmptyNamespace(shortName); }
private TableReference truncateNamespace(TableReference tableRef) { if (tableRef.getNamespace().isEmptyNamespace()) { return tableRef; } String namespace = tableRef.getNamespace().getName(); namespace = truncate(namespace, MAX_NAMESPACE_LENGTH); return TableReference.create(Namespace.create(namespace), tableRef.getTablename()); }
@JsonIgnore public String getQualifiedName() { return namespace.isEmptyNamespace() || namespace.getName().equals("met") ? tablename : namespace.getName() + "." + tablename; }
public static String getTableReferenceString(String tableName, Namespace namespace) { Preconditions.checkArgument(isTableNameValid(tableName), "%s is not a valid table name", tableName); String namespaceName = namespace.getName(); // Hacks for schemas that were created before namespaces were created. if (namespace.isEmptyNamespace() || namespaceName.equals("met")) { return "TableReference.createWithEmptyNamespace(\"" + tableName + "\")"; } else { return "TableReference.createFromFullyQualifiedName(\"" + namespace.getName() + "." + tableName + "\")"; } }
@Value.Check protected final void check() { Preconditions.checkState( metadataTable().getNamespace().isEmptyNamespace(), "'metadataTable' should have empty namespace'"); }
@Override public TableReference getMappedTableName(TableReference tableRef) throws TableMappingNotFoundException { if (tableRef.getNamespace().isEmptyNamespace()) { return tableRef; } if (tableMap.get().containsKey(tableRef)) { TableReference shortName = tableMap.get().get(tableRef); validateShortName(tableRef, shortName); return tableMap.get().get(tableRef); } else { updateTableMap(); TableReference shortTableName = tableMap.get().get(tableRef); if (shortTableName != null) { return shortTableName; } throw new TableMappingNotFoundException("Unable to resolve full name for table reference " + tableRef); } }
@Override public TableReference addTable(TableReference tableRef) { if (tableRef.getNamespace().isEmptyNamespace()) { return tableRef; } if (tableMap.get().containsKey(tableRef)) { return tableMap.get().get(tableRef); } Cell key = Cell.create(getBytesForTableRef(tableRef), AtlasDbConstants.NAMESPACE_SHORT_COLUMN_BYTES); String shortName = AtlasDbConstants.NAMESPACE_PREFIX + Preconditions.checkNotNull(uniqueLongSupplier.get(), "uniqueLongSupplier returned null"); byte[] value = PtBytes.toBytes(shortName); try { kv.putUnlessExists(AtlasDbConstants.NAMESPACE_TABLE, ImmutableMap.of(key, value)); } catch (KeyAlreadyExistsException e) { return getAlreadyExistingMappedTableName(tableRef); } return TableReference.createWithEmptyNamespace(shortName); }
private TableReference truncateNamespace(TableReference tableRef) { if (tableRef.getNamespace().isEmptyNamespace()) { return tableRef; } String namespace = tableRef.getNamespace().getName(); namespace = truncate(namespace, MAX_NAMESPACE_LENGTH); return TableReference.create(Namespace.create(namespace), tableRef.getTablename()); }