question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Uniqueness of IDs

See original GitHub issue

I’m submitting a

  • bug report.
  • feature request.

Current Behaviour:

For the purpose of the hydra-agent to identify every node in its graph uniquely and make it point to the right hydrus resource, it cannot rely on database’s primary keys as they may change as pk are dropped and substituted. So possibly we need a way to identify every resource instance uniquely in hydrus adn the agent. For example:

{
  "@context": "/api/contexts/Drone.jsonld", 
  "@id": "/api/DroneCollection/2", 
  "@type": "Drone", 
  "DroneID": "2", 
  "MaxSpeed": "300", 
  "Sensor": "Temperature", 
  "State": {
    "@type": "State", 
    "Battery": "81", 
    "Direction": "W", 
    "Position": "0.856901647439813,14.05823948684688", 
    "Speed": "100", 
    "Status": "Confirming"
  }, 
  "model": "xyz", 
  "name": "Drone 1"
}

If it happens that this instance is deleted and substituted by another drone (that is a different model or with different maxSpeed for example), it may happen that the same id “2” could be assigned to this new drone creating inconsistency between the data stored in the server and the referenced pk “2” stored in the agent.

Expected Behaviour:

Every instance has to be referenced by a unique id, possibly generated by hashing the values of certain properties in the instance

Discussed solution

We may need to add "hydra:required": true for every properties in the Resource that may be considered part of a UniqueConstraint, then make the model to create a UniqueConstraint on the properties specified as required. So the server and the client can generate the same checksum by using the values like md5(str({"@id": "...", "@type": "", "prop1": "value1", "prop2": "value2"}))

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
IamRaviTejaG-zzcommented, Jun 30, 2018

@xadahiya Just my two cents! How about simply using the Python’s uuid module. It generates a unique ID everytime.

1reaction
xadahiyacommented, Jun 28, 2018

for generating the hash can we consider md5("name+timestamp)

Not every object will have a name property. You can see State or Area data for example. The properties can highly vary and the best way to tackle this is to use some of the object properties (“Required ones”) to generate the checksum.

Also, note that we have “required”, “writeonly” and “readonly” properties for each class in the APIDoc so it makes sense to implement that mechanism and use it to generate unique IDs or checksums.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unique ID Numbers | Identification for Development - ID4D
Unique ID Numbers In any ID system, identifying numbers—including unique ID numbers (UINs), also sometimes known as national ID numbers (NINs)—are the most ......
Read more >
Unique identifier - Wikipedia
A unique identifier (UID) is an identifier that is guaranteed to be unique among all identifiers used for those objects and for a...
Read more >
Unique IDs - IBM
Unique IDs are numbers that are generated by the Cúram infrastructure for use as unique database keys. They come in two types: Human-readable...
Read more >
Unique IDs in programming - LinkedIn
Most people have probably come across what is usually called a UUID (universally unique ID) while using software.
Read more >
When Working with Element IDs, Make Them Unique
Under accessibility checks, you may have an issue labeled "Element IDs are not unique" highlighted on your website.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found