Skip to content

Conversation

@bvulaj
Copy link
Member

@bvulaj bvulaj commented Aug 16, 2016

No description provided.

@bvulaj bvulaj self-assigned this Aug 16, 2016
@bvulaj bvulaj removed their assignment Aug 16, 2016
@bvulaj
Copy link
Member Author

bvulaj commented Aug 16, 2016

Worth noting that we can probably make this change for array fields as well. I can either make it part of this PR or just merge this and I'll make another.

} else {
hidden.put(path.getLast(), val.toUpperCase());
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

...else (if val==null) and if hidden_sub_path exists, remove the field from there

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch. We didn't have that happening before and this logic makes it quite a bit easier to implement. I think there's another issue out there that we can close.

@bserdar
Copy link
Contributor

bserdar commented Aug 16, 2016

Lets make this for arrays as well

@bserdar
Copy link
Contributor

bserdar commented Aug 19, 2016

I believe you're making this much more complicated than it needs to be. First, instead of strings for field names, use Path. Second, you don't need a Map for field and its corresponding hidden field. A list of fields
(paths) should suffice. And the algorithm would look like this:

populateCaseInsensitiveField(Object doc,Path field) {
   if field.numSegments==1
       if doc.get(field) is a list (must be primitive list)
           add hidden field to doc, and populate the list
       else
           add hidden field to doc, populate field
  else if field[0]=='*'
       doc is a List. For every element of doc, populateCaseInsensitiveField(element, field.suffix(-1)
  else
       populateCaseInsensitiveField(doc.get(field[0],field.suffix(-1)
}

@bvulaj
Copy link
Member Author

bvulaj commented Aug 19, 2016

@bserdar that's fair. I'm still spending some time cleaning this up. Let me take a look at the algo.

} else if (field.numSegments() == 1) {
DBObject docObj = (DBObject) doc;
if (docObj.get(field.head(0)) == null) {
// no value, so nothing to populate
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove field from docObj.@hidden

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