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
IonStructLite bugfixes #155
Merged
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,14 +34,14 @@ | |
import software.amazon.ion.impl.PrivateCurriedValueFactory; | ||
import software.amazon.ion.util.Equivalence; | ||
import java.util.Set; | ||
import software.amazon.ion.UnknownSymbolException; | ||
|
||
final class IonStructLite | ||
extends IonContainerLite | ||
implements IonStruct | ||
{ | ||
private static final int HASH_SIGNATURE = | ||
IonType.STRUCT.toString().hashCode(); | ||
|
||
// TODO amzn/ion-java#41: add support for _isOrdered | ||
|
||
IonStructLite(ContainerlessContext context, boolean isNull) | ||
|
@@ -54,14 +54,13 @@ private IonStructLite(IonStructLite existing, IonContext context) | |
super(existing, context, true); | ||
// field map can be shallow cloned due to it dealing with String and Integer | ||
// values - both of which are immutable constructs and so safe to retain as references | ||
this._field_map = null == _field_map | ||
? null | ||
: new HashMap<String, Integer>(existing._field_map); | ||
this._field_map = null == existing._field_map ? null : new HashMap<String, Integer>(existing._field_map); | ||
this._field_map_duplicate_count = existing._field_map_duplicate_count; | ||
this.hasNullFieldName = existing.hasNullFieldName; | ||
} | ||
|
||
private Map<String, Integer> _field_map; | ||
|
||
private boolean hasNullFieldName = false; | ||
|
||
public int _field_map_duplicate_count; | ||
|
||
|
@@ -402,9 +401,9 @@ public IonValue get(String fieldName) | |
IonValue field; | ||
|
||
if (field_idx < 0) { | ||
if(hasNullFieldName) throw new UnknownSymbolException("Unable to resolve fieldname due to null fields."); | ||
field = null; | ||
} | ||
else { | ||
} else { | ||
field = get_child(field_idx); | ||
} | ||
|
||
|
@@ -450,11 +449,6 @@ public boolean add(IonValue child) | |
{ | ||
// TODO validate in struct.setFieldName | ||
String text = child.getFieldNameSymbol().getText(); | ||
if (text != null) | ||
{ | ||
validateFieldName(text); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wow, this was silly. |
||
} | ||
|
||
IonValueLite concrete = (IonValueLite) child; | ||
_add(text, concrete); | ||
|
||
|
@@ -483,6 +477,7 @@ protected void handle(IonValue newValue) | |
*/ | ||
private void _add(String fieldName, IonValueLite child) | ||
{ | ||
hasNullFieldName |= fieldName == null; | ||
int size = get_child_count(); | ||
|
||
// add this to the Container child collection | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'Null fields' is what's happening within the implementation, but from an Ion perspective isn't the issue. I don't know if this is any less wordy than the original, but here's my stab at it:
"Unable to determine whether the field exists because the struct contains field names with unknown text."