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

Catalog Handler interface to support dynamic encode padding by length #1075

Merged
merged 1 commit into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,8 @@ public int encode(
}

@Override
public int encodePadding()
public int encodePadding(
int length)
{
return MAX_PADDING_LENGTH;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public void shouldVerifyMaxPadding()
{
ApicurioCatalogHandler catalog = new ApicurioCatalogHandler(config, context, 0L);

assertEquals(9, catalog.encodePadding());
assertEquals(9, catalog.encodePadding(0));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,8 @@ public int encode(
}

@Override
public int encodePadding()
public int encodePadding(
int length)
{
return MAX_PADDING_LENGTH;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public void shouldVerifyMaxPadding()
{
KarapaceCatalogHandler catalog = new KarapaceCatalogHandler(config, context, 0L);

assertEquals(5, catalog.encodePadding());
assertEquals(5, catalog.encodePadding(0));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,16 @@ default int encode(
return encoder.accept(traceId, bindingId, schemaId, data, index, length, next);
}

default int encodePadding()
default int encodePadding(
int length)
{
return 0;
}

default int decodePadding(
DirectBuffer data,
int index,
int length)
{
return 0;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public int padding(
int index,
int length)
{
return handler.encodePadding();
return handler.encodePadding(length);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public int padding(
int index,
int length)
{
int padding = 0;
int padding = handler.decodePadding(data, index, length);
if (VIEW_JSON.equals(view))
{
int schemaId = handler.resolve(data, index, length);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public int padding(
int index,
int length)
{
return handler.encodePadding();
return handler.encodePadding(length);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,15 @@ public JsonReadConverterHandler(
super(config, context);
}

@Override
public int padding(
DirectBuffer data,
int index,
int length)
{
return handler.decodePadding(data, index, length);
}

@Override
public int convert(
long traceId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public int padding(
int index,
int length)
{
return handler.encodePadding();
return handler.encodePadding(length);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public int padding(
int index,
int length)
{
int padding = 0;
int padding = handler.decodePadding(data, index, length);
if (VIEW_JSON.equals(view))
{
int schemaId = handler.resolve(data, index, length);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public int padding(
? catalog.id
: handler.resolve(subject, catalog.version);

return handler.encodePadding() + supplyIndexPadding(schemaId);
return handler.encodePadding(length) + supplyIndexPadding(schemaId);
}

@Override
Expand Down