Skip to content

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

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

ben51degrees wants to merge 1 commit into
rcfrom
fix/drift-is-the-sum-of-the-components

Conversation

@ben51degrees

Copy link
Copy Markdown
Contributor

Fixes #16.

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.

Where it came from

Opened as a draft in device-detection-java as device-detection-java#614 before that repository was archived. The commit is the same, applied under device-detection/.

How it was checked

mvn -pl device-detection/device-detection.hash.engine.on-premise test -Dtest=DeviceDataTests with JDK 17 on Windows x64, against a native library built from this repository on 2 November and the Lite data file and evidence files from the data repository: 7 tests run, 0 failures, 0 errors, 0 skipped, the new DeviceData_Drift_IsTheSumOfTheResults among them. The pull request job builds the native library itself and runs the same tests on every configuration.

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.

2 participants