Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Datahub project Datahub DataHubGuidGenerator

From Leeroopedia


Knowledge Sources
Domains Java_SDK, Metadata_Management
Last Updated 2026-02-10 00:00 GMT

Overview

Description

DataHubGuidGenerator is a utility class that generates deterministic GUID strings for DataHub entities. It takes a Map<String, String> of key-value pairs, serializes them as JSON with sorted keys for deterministic output, and computes an MD5 hash of the resulting string. The hash is returned as a lowercase hexadecimal string.

The deterministic nature of this generator ensures that the same set of input key-value pairs always produces the same GUID, which is essential for consistent entity identification across different systems and invocations.

The class uses Lombok @Slf4j for logging and @SneakyThrows to propagate checked exceptions as unchecked.

Usage

Call the static dataHubGuid() method with a map of identifying properties. The method is typically used to generate unique identifiers for entities based on their distinguishing attributes (e.g., platform, name, environment).

Code Reference

Source Location

metadata-integration/java/datahub-client/src/main/java/io/datahubproject/models/util/DataHubGuidGenerator.java

Signature

@Slf4j
public class DataHubGuidGenerator {

    @SneakyThrows
    public static String dataHubGuid(Map<String, String> obj)
}

Import

import io.datahubproject.models.util.DataHubGuidGenerator;

I/O Contract

Inputs

Parameter Type Description
obj Map<String, String> Key-value pairs representing the identifying attributes of an entity

Outputs

Return Type Description
String A 32-character lowercase hexadecimal MD5 hash string

Algorithm:

  1. Configure Jackson ObjectMapper to sort map entries by keys
  2. Serialize the map to a JSON string
  3. Compute MD5 hash of the JSON bytes
  4. Convert hash bytes to lowercase hexadecimal string

Usage Examples

import io.datahubproject.models.util.DataHubGuidGenerator;
import java.util.Map;
import java.util.LinkedHashMap;

// Generate a GUID from entity properties
Map<String, String> properties = new LinkedHashMap<>();
properties.put("platform", "snowflake");
properties.put("name", "my_database.my_table");
properties.put("env", "PROD");

String guid = DataHubGuidGenerator.dataHubGuid(properties);
// Returns a deterministic 32-char hex string, e.g., "a1b2c3d4e5f6..."

// Same inputs always produce the same GUID
String guid2 = DataHubGuidGenerator.dataHubGuid(properties);
assert guid.equals(guid2);

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment