Skip to content

Conversation

sreemanthreddy27
Copy link

  1. Grammar Definitions
    The grammar file Directives.g4 defines the following tokens:
    fragment BYTE_UNIT
    : [Bb] // bytes
    | [Kk][Bb] // kilobytes
    | [Mm][Bb] // megabytes
    | [Gg][Bb] // gigabytes
    | [Tt][Bb] // terabytes
    | [Pp][Bb] // petabytes
    ;
    BYTE_SIZE
    : Number BYTE_UNIT
    ;
    fragment TIME_UNIT
    : 'ns' // nanoseconds
    | 'us' // microseconds
    | 'ms' // milliseconds
    | 's' // seconds
    | 'm' // minutes
    | 'h' // hours
    | 'd' // days
    ;
    TIME_DURATION
    : Number TIME_UNIT
    ;
  2. Test Implementation
    The DirectivesLexerTest.java includes comprehensive test cases:
    @test
    public void testByteSizeTokens() {
    String input = "1B 1KB 1MB 1GB 1TB 1PB";
    DirectivesLexer lexer = new DirectivesLexer(CharStreams.fromString(input));
    CommonTokenStream tokens = new CommonTokenStream(lexer);
    tokens.fill();
    List tokenList = tokens.getTokens();
    Assert.assertEquals(6, tokenList.size());
    for (Token token : tokenList) {
    Assert.assertEquals(DirectivesLexer.BYTE_SIZE, token.getType());
    }
    }
    @test
    public void testTimeDurationTokens() {
    String input = "1ns 1us 1ms 1s 1m 1h 1d";
    DirectivesLexer lexer = new DirectivesLexer(CharStreams.fromString(input));
    CommonTokenStream tokens = new CommonTokenStream(lexer);
    tokens.fill();
    List tokenList = tokens.getTokens();
    Assert.assertEquals(7, tokenList.size());
    for (Token token : tokenList) {
    Assert.assertEquals(DirectivesLexer.TIME_DURATION, token.getType());
    }
    }
    Testing
  3. Test Coverage
    The implementation includes tests for:
    Valid byte size tokens (B, KB, MB, GB, TB, PB)
    Valid time duration tokens (ns, us, ms, s, m, h, d)
    Invalid formats and error handling
    Case sensitivity handling
    Integration with AggregateStats directive
  4. Test Results
    All test cases are passing, including:
    Basic token recognition
    Unit conversion
    Error handling
    Integration tests

Copy link

google-cla bot commented Apr 16, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

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