Code Monkey home page Code Monkey logo

ion-c's Introduction

Amazon Ion C

A C implementation of the Ion data notation.

Build Status Build status

Setup

This repository contains a git submodule called ion-tests, which holds test data used by ion-c's unit tests.

The easiest way to clone the ion-c repository and initialize its ion-tests submodule is to run the following command.

$ git clone --recursive https://github.com/amazon-ion/ion-c.git ion-c

Alternatively, the submodule may be initialized independently from the clone by running the following commands.

$ git submodule init
$ git submodule update

The submodule points to the tip of the branch of the ion-tests repository specified in ion-c's .gitmodules file.

Pulling in Upstream Changes

To pull upstream changes into ion-c, start with a simple git pull. This will pull in any changes to ion-c itself (including any changes to its .gitmodules file), but not any changes to the ion-tests submodule. To make sure the submodule is up-to-date, use the following command.

$ git submodule update --remote

This will fetch and update the ion-tests submodule from the ion-tests branch currently specified in the .gitmodules file.

For detailed walkthroughs of git submodule usage, see the Git Tools documentation.

Building the Library

Use the provided scripts build-release.sh and build-debug.sh. Ensure that cmake is installed first.

On macOS

cmake can be installed using Homebrew: brew install cmake

Using the Library

A great way to get started is to use the Ion cookbook.

ion-c's People

Contributors

almann avatar cheqianh avatar desaikd avatar dlurton avatar gergodocziaim avatar hohle avatar hyandell avatar jobarr-amzn avatar m6w6 avatar marcbowes avatar mijamo911 avatar nirosys avatar popematt avatar raganhan avatar rgantt avatar ruhland avatar sadderchris avatar soospeter avatar tgregg avatar therapon avatar yosoufe avatar zslayton avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ion-c's Issues

Support local symbol table append

Add support for appending to a local symbol table, as prescribed by the spec.

E.g.

$ion_1_0
$ion_symbol_table::
{
  imports:[{ name:"com.amazon.ols.symbols.offer", version:1, max_id:75 },
           { name:"com.amazon.ims3.symbols.submission", version:1, max_id:100 }],
  symbols:["local_symbol"]
}
submission::{ /* ... */ local_symbol  /* ... */ }
$ion_symbol_table::
{
  imports:$ion_symbol_table,
  symbols:["another one"]
}

ion_reader_read_* gives misleading error message when given reader is bad

If you call one of the ion_reader methods (for example ion_reader_read_timestamp) with a bad hREADER pointer, the methods fail with IERR_INVALID_STATE, which is misleading. There should be a specific error to indicate that an invalid reader was provided. The current code implies that the method is being called at a bad point in the reader's state-transition model, which isn't the case.

Todo: preallocate pages

ion_initialize_page_pool in ion_allocation.c: should we pre-allocate pages when we initialize the page pool?

Clarify and make consistent the purpose of the p_bytes_flushed output parameter to ion_writer_finish and ion_writer_flush

This parameter is documented as "the number of bytes written into the buffer/stream". Is that the total number of bytes ever written to the stream, or the total number of bytes written to the stream by that call? The behavior appears to be inconsistent between text and binary writers. This should be fixed, and the documentation clarified.

Another option is to deprecate the current flush/finish functions in favor of versions without the output parameter. Users would be directed to use ion_stream_get_position to get the size of the stream. They should do this anyway until this issue is resolved.

Page pool thread safety issue

The memory page pool used by the text parser isn't thread safe. We can disable it by setting the number of pages to zero (trivially calling through to the built-in memory management functions) or upgrade to C11 and take advantage of atomic operations

Improve documentation of the ION_INT lifecycle

The memory ownership contract and lifecycle for an ION_INT is currently not documented, and may be confusing to users. For example, when must ion_int_alloc, ion_int_free, and ion_int_init be used?

Make ION_CATALOG user-implementable.

Currently, the only implementation of ION_CATALOG is as an in-memory store for ION_SYMBOL_TABLEs. ION_CATALOG should be treated as an interface that allows users to optionally provide lookup logic. This can be used, e.g., to lazily or remotely retrieve shared symbol tables.

Todo: timegm()

ion_timestamp_to_time_t in ion_timestamp.c: timegm() fails for timestamps before the Unix epoch. It is also unportable!

Test coverage: writer

Add tests that write out various values and then verify the emitted bits (some overlap with round-tripping)

Fails to build in Release mode on macOS 10.13.4/Xcode 9.3

I tried building ion-c: the debug build works fine (./build-debug.sh) but the release build fails with the error:

[ 71%] Linking CXX executable all_tests
Undefined symbols for architecture x86_64:
  "join_path(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)", referenced from:
      __GLOBAL__sub_I_test_vectors.cpp in test_vectors.cpp.o
      IonCli_ProcessBasic_Test::TestBody() in test_ion_cli.cpp.o
      IonCli_CompareNullsBasic_Test::TestBody() in test_ion_cli.cpp.o
      IonCli_CompareListsEquivs_Test::TestBody() in test_ion_cli.cpp.o
      IonCli_CompareSexpsNonequivs_Test::TestBody() in test_ion_cli.cpp.o
      IonCli_CompareAnnotatedIvmsEmbeddedNonequivs_Test::TestBody() in test_ion_cli.cpp.o
      IonCli_CompareMultipleInputFiles_Test::TestBody() in test_ion_cli.cpp.o
      ...
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [test/all_tests] Error 1
make[1]: *** [test/CMakeFiles/all_tests.dir/all] Error 2
make: *** [all] Error 2

I'm using the latest master branch (0903060), macOS 10.13.4, the Clang that came with Xcode 9.3, and latest CMake from Homebrew:

$ clang --version
Apple LLVM version 9.1.0 (clang-902.0.39.1)
Target: x86_64-apple-darwin17.5.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
$ cmake --version
cmake version 3.11.2

Evaluate the impact of not imposing upper bounds

The ion reader and writer options declare user-configurable upper bounds for things like maximum annotation count, maximum container depth, etc. This allows memory to be preallocated and reused. Ideally, there would be a similarly-performant solution which does not require upper bounds.

Improve float-to-string conversion using Ryu

The text writer currently uses sprintf for its float-to-string conversions. Ryu may provide an opportunity to improve both the correctness and performance of this conversion.

From the authors:

We present Ryū, a new routine to convert binary floating point numbers to their decimal representations using only fixed-size integer operations, and prove its correctness. Ryū is simpler and approximately three times faster than the previously fastest implementation.

See also:

Binary artifacts

Laundry list o' platforms:

android
fireos
kindle
ios
macos
windows (WinNTx86-64)
Linux x86-64 (rpm?)

intptr_t is wrong size on x86_64

  • intptr_t is an integer that is at least as big as the largest pointer. So, the %d is technically fine on i386 GCC (sizeof(intptr_t) == sizeof(int)), but should be %lld on x86_64 GCC (sizeof(intptr_t) == sizeof(int)). Really, we probably should be using the PRIdPTR macro from inttypes.h to be portable, so this is definitely a bug.
      intptr_t val = ...;
      printf("VALUE: %" PRIdPTR  "\n", val);
  • The gmtime_r call is a good call out--the CMake C_STANDARD option with 99 uses -std=gnu99.
  • We'll have to evaluate the downgrade of CMake and passing the CFLAGS in, I'm not sure this is the right thing to do.
  • Consider requiring use of CMake >= 3.5 (note that 3.5 is not available on Ubuntu 14.04).

Clean up reflexive comparison CLI output

As noted in #94 , non-test users of the CLI should be able to assume that the implementation is bug-free. Therefore, producing two ComparisonResults representing both A == B and B == A is unnecessary noise for these users.

Explore how to best handle this while retaining the utility of not assuming reflexivity for test users. For non-test users, it is probably best to detect reflexive comparisons and only output one ComparisonResult, raising an error if the results of A == B and B == A differ. This might work for test users too.

Convey helpful error messages

Error messages are only conveyed in debug builds, and even then, many failure paths do not provide helpful messages. It should be explored how to convey helpful error messages throughout the library, and how to balance any performance implications on release builds.

decimal precision

2000000000d100 roundtrips as 2.000000000d+109 within the event suite.
This is destructive.

Fix docopt on Windows

The docopt submodule, which generates an argument parser from the CLI help, generates runtime errors on Windows. This makes the CLI executable unusable on that platform.

This needs to be further investigated and fixed.

Cookbook

Need to add C examples to the cookbook

Fix ionizer

Known to be not working:

  • -o counts
  • -o types
  • -o none on invalid Ion (should error)

Known to be working:

  • -o pretty for the small set of files used to test by hand.
  • -o ugly for the small set of files used to test by hand.
  • -o binary for the small set of files used to test by hand.
  • --help

Unknown: the rest.

The tool needs its own unit testing.

Add automated testing for different preprocessor values

Certain components of the library, notably ion_extractor's ION_EXTRACTOR_MAX_NUM_PATHS and ION_EXTRACTOR_MAX_PATH_LENGTH, and decNumber's DECNUMDIGITS, allow preprocessor macros to be redefined by the user. Currently, there is no automated way of testing different values for these macros. Such automated testing needs to be added in order to improve coverage.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.