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

Adds a Macroize tool to enable conversion of Ion 1.0 data to Ion 1.1 using specified macros and text patterns. #990

Open
wants to merge 1 commit into
base: ion-11-encoding
Choose a base branch
from

Conversation

tgregg
Copy link
Contributor

@tgregg tgregg commented Nov 11, 2024

Description of changes:

This is an early (v0.1) version of the tool with many TODOs and known limitations (see the JavaDoc on MacroizeSpec.java). However, I think it's useful enough to make available now while we continue iterating. I also have a version of the tool that does basic macro detection, but that will be added in a future PR.

The tool may be invoked by building the ion-java jar and using

java -cp ion-java.jar com.amazon.ion.apps.macroize.Macroize

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@@ -24,7 +24,7 @@ public abstract class IonEncodingVersion<BinaryWriterBuilder, TextWriterBuilder>
* Ion 1.0, see the <a href="https://amazon-ion.github.io/ion-docs/docs/binary.html">binary</a> and
* <a href="https://amazon-ion.github.io/ion-docs/docs/text.html">text</a> specification.
*/
public static IonEncodingVersion<IonBinaryWriterBuilder, IonTextWriterBuilder> ION_1_0 = new IonEncodingVersion<IonBinaryWriterBuilder, IonTextWriterBuilder>(0) {
public static final IonEncodingVersion<IonBinaryWriterBuilder, IonTextWriterBuilder> ION_1_0 = new IonEncodingVersion<IonBinaryWriterBuilder, IonTextWriterBuilder>(0) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure why Spotless just found these now, but this is a good change, though unrelated to the rest of the PR.

@@ -21,7 +21,7 @@
* in an IndexOutOfBoundsException. The number 10 is chosen because it is the maximum number of bytes required to write
* a long value as a FlexInt or VarInt.
*/
/*package*/ final class WriteBuffer implements Closeable
public final class WriteBuffer implements Closeable
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is being used in Macroize, which is in a different Java package. We can rename this class using the _Private_ prefix if we want to maintain the existing convention to denote that this shouldn't be used by users of the library.

Comment on lines +326 to +333
if (((IonValueLite) element)._context.getContextSymbolTable() != getContextForIndex(null, index).getContextSymbolTable()) {
// Note: this isn't impossible to support, but it requires care in the case where 'element' may depend
// on symbol table mappings unique to its own context. In order to sidestep this complexity until a use
// case is identified for it, only setting the element at an index that uses the same symbol table is
// currently supported.
throw new UnsupportedOperationException();
}
return super.set(index, element);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The JavaDoc for this method still says it's unsupported. I haven't felt the need to change that to mark this as officially supported since it has a known limitation. I'm happy to move this functionality to an internal-only method if we prefer that.

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.

1 participant