Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CP-40669: Restore database should not require ref as the first #4781

Merged
merged 1 commit into from
Aug 30, 2022

Conversation

liulinC
Copy link
Collaborator

@liulinC liulinC commented Aug 30, 2022

attribute of row

When restore xapi database from xml file, xapi require ref be
the first attribute of row, This is not flexible, especially when
need to parse and save the xml files.

This commit fix this issue by search ref in the attribute list

Signed-off-by: Lin Liu lin.liu@citrix.com

attribute of row

When restore xapi database from xml file, xapi require ref be
the first attribute of row, This is not flexible, especially when
need to parse and save the xml files.

This commit fix this issue by search ref in the attribute list

Signed-off-by: Lin Liu <lin.liu@citrix.com>
| (_, "row"), ((_, "ref"), rf) :: rest ->
(* Remove any other duplicate "ref"s which might have sneaked in there *)
let rest = List.filter (fun ((_, k), _) -> k <> "ref") rest in
| (_, "row"), rest ->
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Altogether, this code is traversing lists multiple times and is inefficient if these lists are long. But that problem is already pre-existing.

The problem at hand is to find the first "ref" entry and to ignore the others. The solution is to split the list based on the key and we expect to find at least one entry. I think the code achieving this could be kept closer together - a sketch is below:

let ref, rest =
  match List.partition (fun ((_, k) -> k = "ref")) rest with
  | r::_, rest -> r,rest
  | [] -> raise ...

@robhoes robhoes merged commit 896add0 into master Aug 30, 2022
@robhoes robhoes deleted the private/linl/dev branch August 30, 2022 12:33
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.

4 participants