@Test public void addingTableWithoutNamespaceIsNoop() throws TableMappingNotFoundException { assertThat(tableMapping.addTable(TABLE_EMPTY_NAMESPACE)).isEqualTo(TABLE_EMPTY_NAMESPACE); verify(kvs, times(1)).putUnlessExists(eq(AtlasDbConstants.NAMESPACE_TABLE), anyMap()); }
@Override public TableReference addTable(TableReference tableRef) { if (tableRef.getNamespace().isEmptyNamespace()) { return tableRef; } TableReference existingShortName = tableMap.get().get(tableRef); if (existingShortName != null) { return existingShortName; } Cell key = getKeyCellForTable(tableRef); String shortName = AtlasDbConstants.NAMESPACE_PREFIX + uniqueLongSupplier.getAsLong(); byte[] value = PtBytes.toBytes(shortName); try { kvs.putUnlessExists(AtlasDbConstants.NAMESPACE_TABLE, ImmutableMap.of(key, value)); } catch (KeyAlreadyExistsException e) { return getAlreadyExistingMappedTableName(tableRef); } return TableReference.createWithEmptyNamespace(shortName); }
KvTableMappingService implements TableMappingService { @Override public TableReference addTable(TableReference tableRef) { if (tableRef.getNamespace().isEmptyNamespace()) { return tableRef; } TableReference existingShortName = tableMap.get().get(tableRef); if (existingShortName != null) { return existingShortName; } Cell key = getKeyCellForTable(tableRef); String shortName = AtlasDbConstants.NAMESPACE_PREFIX + uniqueLongSupplier.getAsLong(); byte[] value = PtBytes.toBytes(shortName); try { kvs.putUnlessExists(AtlasDbConstants.NAMESPACE_TABLE, ImmutableMap.of(key, value)); } catch (KeyAlreadyExistsException e) { return getAlreadyExistingMappedTableName(tableRef); } return TableReference.createWithEmptyNamespace(shortName); } }
KvTableMappingService implements TableMappingService { @Override public TableReference addTable(TableReference tableRef) { if (tableRef.getNamespace().isEmptyNamespace()) { return tableRef; } TableReference existingShortName = tableMap.get().get(tableRef); if (existingShortName != null) { return existingShortName; } Cell key = getKeyCellForTable(tableRef); String shortName = AtlasDbConstants.NAMESPACE_PREFIX + uniqueLongSupplier.getAsLong(); byte[] value = PtBytes.toBytes(shortName); try { kvs.putUnlessExists(AtlasDbConstants.NAMESPACE_TABLE, ImmutableMap.of(key, value)); } catch (KeyAlreadyExistsException e) { return getAlreadyExistingMappedTableName(tableRef); } return TableReference.createWithEmptyNamespace(shortName); } protected  KvTableMappingService(KeyValueService kvs, LongSupplier uniqueLongSupplier, Pattern namespaceValidation); }
KvTableMappingService implements TableMappingService { @Override public TableReference addTable(TableReference tableRef) { if (tableRef.getNamespace().isEmptyNamespace()) { return tableRef; } TableReference existingShortName = tableMap.get().get(tableRef); if (existingShortName != null) { return existingShortName; } Cell key = getKeyCellForTable(tableRef); String shortName = AtlasDbConstants.NAMESPACE_PREFIX + uniqueLongSupplier.getAsLong(); byte[] value = PtBytes.toBytes(shortName); try { kvs.putUnlessExists(AtlasDbConstants.NAMESPACE_TABLE, ImmutableMap.of(key, value)); } catch (KeyAlreadyExistsException e) { return getAlreadyExistingMappedTableName(tableRef); } return TableReference.createWithEmptyNamespace(shortName); } protected  KvTableMappingService(KeyValueService kvs, LongSupplier uniqueLongSupplier, Pattern namespaceValidation); static KvTableMappingService create(KeyValueService kvs, LongSupplier uniqueLongSupplier); static KvTableMappingService createWithCustomNamespaceValidation(
            KeyValueService kvs,
            LongSupplier uniqueLongSupplier,
            Pattern namespaceValidation); static void createNamespaceTable(KeyValueService keyValueService); @Override TableReference addTable(TableReference tableRef); static byte[] getBytesForTableRef(TableReference tableRef); @Override void removeTable(TableReference tableRef); @Override void removeTables(Set<TableReference> tableRefs); @Override TableReference getMappedTableName(TableReference tableRef); @Override Map<TableReference, T> mapToShortTableNames(Map<TableReference, T> toMap); @Override Map<TableReference, TableReference> generateMapToFullTableNames(Set<TableReference> tableRefs); }
KvTableMappingService implements TableMappingService { @Override public TableReference addTable(TableReference tableRef) { if (tableRef.getNamespace().isEmptyNamespace()) { return tableRef; } TableReference existingShortName = tableMap.get().get(tableRef); if (existingShortName != null) { return existingShortName; } Cell key = getKeyCellForTable(tableRef); String shortName = AtlasDbConstants.NAMESPACE_PREFIX + uniqueLongSupplier.getAsLong(); byte[] value = PtBytes.toBytes(shortName); try { kvs.putUnlessExists(AtlasDbConstants.NAMESPACE_TABLE, ImmutableMap.of(key, value)); } catch (KeyAlreadyExistsException e) { return getAlreadyExistingMappedTableName(tableRef); } return TableReference.createWithEmptyNamespace(shortName); } protected  KvTableMappingService(KeyValueService kvs, LongSupplier uniqueLongSupplier, Pattern namespaceValidation); static KvTableMappingService create(KeyValueService kvs, LongSupplier uniqueLongSupplier); static KvTableMappingService createWithCustomNamespaceValidation(
            KeyValueService kvs,
            LongSupplier uniqueLongSupplier,
            Pattern namespaceValidation); static void createNamespaceTable(KeyValueService keyValueService); @Override TableReference addTable(TableReference tableRef); static byte[] getBytesForTableRef(TableReference tableRef); @Override void removeTable(TableReference tableRef); @Override void removeTables(Set<TableReference> tableRefs); @Override TableReference getMappedTableName(TableReference tableRef); @Override Map<TableReference, T> mapToShortTableNames(Map<TableReference, T> toMap); @Override Map<TableReference, TableReference> generateMapToFullTableNames(Set<TableReference> tableRefs); static final TableMetadata NAMESPACE_TABLE_METADATA; }