Skip to content

Develop sreemanth #980

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

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

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