Skip to content

Add every component's drift for Drift, as the specification says - #614

Draft
jwrosewell wants to merge 1 commit into
mainfrom
fix/drift-is-the-sum-of-the-components
Draft

jwrosewell wants to merge 1 commit into
mainfrom
fix/drift-is-the-sum-of-the-components

Conversation

@jwrosewell

Copy link
Copy Markdown
Contributor

Fixes #613.

The problem

DeviceDataHashDefault.getDriftInternal returned the smallest drift among the native results, one per component, starting from Integer.MAX_VALUE. The specification's match metrics table describes Drift as the total difference in character positions, and 51Degrees/specifications#39 says it in full: the drift of every component's result added together. The C++ results add them (ResultsHash.cpp#L183-L192), as do Go and the Node, PHP and Python wrappers, so the same evidence gave a smaller Drift here whenever more than one component drifted.

What changes

getDriftInternal adds the results' drift, as getDifferenceInternal, getMatchedNodesInternal and getIterationsInternal in the same class already do. A test gives two mocked native results drifts of 3 and 5 and reads 8 from getDrift.

How it was verified

mvn test-compile with -DskipNativeBuild=true on device-detection.hash.engine.on-premise and the modules it depends on compiles the change and the new test. The test itself needs the native library and the data file, which the pull request build provides.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Drift takes the smallest component's drift where the specification adds them

1 participant