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

API-553 Compact serialization and Generic Records #1172

Merged
merged 154 commits into from
Apr 22, 2022
Merged
Show file tree
Hide file tree
Changes from 115 commits
Commits
Show all changes
154 commits
Select commit Hold shift + click to select a range
e138719
Some progress
srknzl Nov 5, 2021
12cdd6d
Finish defaultcompactwriter
srknzl Nov 8, 2021
68340e6
More progress
srknzl Nov 8, 2021
492b3b5
More progress
srknzl Nov 9, 2021
9331e1b
More progress
srknzl Nov 9, 2021
373dad1
More progress
srknzl Nov 10, 2021
59a1986
More progress
srknzl Nov 10, 2021
3025094
More progress
srknzl Nov 10, 2021
74648eb
--amend
srknzl Nov 15, 2021
af52fa5
More progress
srknzl Nov 24, 2021
b8e817c
More progress
srknzl Nov 24, 2021
9352fdd
Add should nullable primitive compact tests and fix bugs
srknzl Nov 25, 2021
c60b343
Add compact stream serializer test
srknzl Nov 26, 2021
3e389a9
Benchmark
srknzl Jan 7, 2022
00a6093
Make get use toDataAsync
srknzl Jan 7, 2022
ffb3d07
Test and bugfixes
srknzl Jan 7, 2022
7630c72
Eager deserilization for get
srknzl Jan 12, 2022
bdd42e8
First version
srknzl Jan 12, 2022
3b598fd
Non compiling but will be
srknzl Jan 12, 2022
d377698
Compiling
srknzl Jan 13, 2022
169f2ee
More changes
srknzl Jan 13, 2022
ab66a24
All tests passing except 2 compact unit tests
srknzl Jan 13, 2022
d05321a
Fix bug
srknzl Jan 14, 2022
9cf2299
Rename eventHandler map
srknzl Jan 14, 2022
356c9ff
Fix LostInvalicationsTest test
srknzl Jan 14, 2022
26627a9
Controlled serialization for map.get and map.put
srknzl Jan 19, 2022
0407e09
Add latency benchmark
srknzl Jan 21, 2022
fe7ad38
Fix typo
srknzl Jan 21, 2022
b5083c1
Delete index.html
srknzl Jan 21, 2022
29acffc
Updates
srknzl Jan 24, 2022
bd6ad32
Rename generic record methods with universal ones to match java client
srknzl Jan 25, 2022
b0606b7
Fix test and some leftover method names
srknzl Jan 25, 2022
ffd4234
Merge remote-tracking branch 'upstream/master' into compact-eager-des…
srknzl Jan 25, 2022
ea0da13
Test in progress
srknzl Jan 25, 2022
43dda2a
Finish generic records toString test
srknzl Jan 26, 2022
4694675
Add cause null check
srknzl Jan 27, 2022
6a234f6
Fix some tests
srknzl Jan 27, 2022
37571fa
Add clone(), delete internalgenericrecord interface
srknzl Jan 28, 2022
7c0a8ec
Fix tests
srknzl Jan 28, 2022
79a7536
Add more tests
srknzl Jan 28, 2022
262480e
Add basic tests
srknzl Jan 28, 2022
4e9a5b5
Delete unused methods of FieldKindBasedOperations
srknzl Jan 28, 2022
c2d484b
Fix bug and add arrayOfString field
srknzl Jan 28, 2022
1470780
Cleanup
srknzl Jan 31, 2022
8ad8cb9
Add some tests
srknzl Jan 31, 2022
d7f5466
Merge remote-tracking branch 'upstream/master' into compact-eager-des…
srknzl Jan 31, 2022
be2c2aa
Cleanup
srknzl Jan 31, 2022
fde4494
Cleanup
srknzl Jan 31, 2022
291c945
RabinFingerprint and SchemaWriter test
srknzl Feb 1, 2022
9cddcd3
Add tests, fix bug
srknzl Feb 1, 2022
09848a4
Add validation logic
srknzl Feb 2, 2022
1ccc6be
Add tests
srknzl Feb 2, 2022
1798434
write generic records validation and tests of it
srknzl Feb 3, 2022
e913b0a
Fix tests and new ones
srknzl Feb 3, 2022
f88dc3c
Add one field read/write test, convert hzClassName to hzClass to allo…
srknzl Feb 7, 2022
3e50c73
Add tests and delete try blocks that are only needed for java
srknzl Feb 8, 2022
d5cfeff
More tests
srknzl Feb 8, 2022
54f7865
More tests
srknzl Feb 9, 2022
ecd35cf
Add all tests with event test skipping
srknzl Feb 9, 2022
a978ce6
Update listener event compact test
srknzl Feb 10, 2022
db797f9
Add tests
srknzl Feb 10, 2022
4c1ca24
More changes
srknzl Feb 11, 2022
be2f701
Compact SQL tests
srknzl Feb 14, 2022
7c81449
getPartitionId supports compact
srknzl Feb 14, 2022
71dac8d
toData controlled ser. fixes and tests
srknzl Feb 14, 2022
b224496
MapProxy and Nearcache tests done
srknzl Feb 14, 2022
dd35314
Proxies done
srknzl Feb 15, 2022
a33d33f
Merge remote-tracking branch 'upstream/master' into compact-eager-des…
srknzl Feb 15, 2022
c14f75a
Eager deserialization
srknzl Feb 15, 2022
9449bec
Some fixes
srknzl Feb 15, 2022
dfa2069
Add api documentation of compact reader
srknzl Feb 15, 2022
c970711
Little fix
srknzl Feb 15, 2022
027a984
getAllInternal tries to deserialize now
srknzl Feb 15, 2022
eb59c24
Delete lazy SQL row deserialization test
srknzl Feb 15, 2022
5b8f703
API docs
srknzl Feb 15, 2022
c8e5075
Some docs and changes
srknzl Feb 16, 2022
f64d246
Some tests and apidoc
srknzl Feb 16, 2022
906695b
Add comment
srknzl Feb 16, 2022
437774a
API documentation wrap up
srknzl Feb 16, 2022
3ca0cb7
Some fixes
srknzl Feb 16, 2022
f58f4b7
Add documentation and code samples
srknzl Feb 16, 2022
e44f9cf
Add compact example to code samples
srknzl Feb 16, 2022
3abb432
Add a sentence sql docs
srknzl Feb 16, 2022
078c279
Some test and fixes
srknzl Feb 17, 2022
93e6b26
Some changes
srknzl Feb 17, 2022
d583b3a
more fixes
srknzl Feb 17, 2022
5d247d5
Fix test
srknzl Feb 18, 2022
07ff2c9
Fix bug
srknzl Feb 18, 2022
123694b
Separate docs and code samples
srknzl Feb 18, 2022
2f2ee76
HeadDataTest
srknzl Feb 18, 2022
9f23f55
Add tests for coverage
srknzl Feb 18, 2022
009e1ba
Some tests
srknzl Feb 18, 2022
deed32a
Add test
srknzl Feb 18, 2022
2eb7800
Some tests
srknzl Feb 18, 2022
b4ec4d5
Some tests added
srknzl Feb 21, 2022
84c552c
Merge remote-tracking branch 'upstream/master' into compact-eager-des…
srknzl Feb 21, 2022
250f60b
Fix a test
srknzl Feb 21, 2022
db9c378
Fix interfaces
srknzl Feb 22, 2022
3fe37d1
Delete compact generic record
srknzl Feb 22, 2022
878a571
Fix genericrecords.ts
srknzl Feb 22, 2022
478eda1
Remove portable specific methods from API since portable generic reco…
srknzl Feb 28, 2022
a7fd785
SQL reintroduce lazy deserialization
srknzl Mar 1, 2022
d0de342
Update api docs of readonlylazylist and readresultset
srknzl Mar 1, 2022
6e9781a
Fix a test
srknzl Mar 1, 2022
d7cbe95
Revert some unnecessary changes
srknzl Mar 2, 2022
3241a34
Merge remote-tracking branch 'upstream/master' into compact-eager-des…
srknzl Mar 2, 2022
6868e2e
Add new compatibility tests and add lazy deserialization
srknzl Mar 14, 2022
548552f
Revert LazyReadResultSetTest
srknzl Mar 15, 2022
9cd6ef6
Merge remote-tracking branch 'upstream/master' into compact-eager-des…
srknzl Mar 15, 2022
9129d4e
Backward compatibility changes
srknzl Mar 15, 2022
7540bfe
Add compact test resources jar
srknzl Mar 15, 2022
be78957
Add missing tests and change public API
srknzl Mar 15, 2022
d0e7268
Revert portable and aggregator change
srknzl Mar 16, 2022
ba9832d
Refactor compact serialization config
srknzl Mar 21, 2022
731a401
Fix tests
srknzl Mar 21, 2022
857acc4
Throw when the same schema is registered again
srknzl Mar 22, 2022
3ad4fc2
Add orDefaultMethods for CompactReader
srknzl Mar 24, 2022
eb5a828
Some of the review comments handled
srknzl Mar 24, 2022
6f0b3a3
Fix config builder unit test
srknzl Mar 25, 2022
e491119
Some review comments
srknzl Mar 25, 2022
1bdab48
Fix tests
srknzl Mar 28, 2022
229d32f
Some review comments handled
srknzl Mar 28, 2022
ad77545
Fix tests
srknzl Mar 28, 2022
48c7f23
Review comments
srknzl Mar 28, 2022
5ce3b09
Remove CompactSqlTest.js
srknzl Mar 28, 2022
0916f08
Fix tests
srknzl Mar 28, 2022
cc24bc5
Fix PartitionServiceTest
srknzl Mar 28, 2022
225129f
Remove compact test classes since they are added to the remote contro…
srknzl Mar 29, 2022
de6e41d
Review comments
srknzl Mar 30, 2022
3fce63e
Some review comments
srknzl Mar 31, 2022
500d02a
Some review comments
srknzl Mar 31, 2022
0c8efb0
Some more comments fixed
srknzl Mar 31, 2022
7aaad0f
More review comments
srknzl Mar 31, 2022
ccd9bc4
Some reviews
srknzl Mar 31, 2022
5d7244b
Review comments
srknzl Apr 1, 2022
0e2d63d
review comments
srknzl Apr 4, 2022
a4f2d64
Fix back compat issue
srknzl Apr 4, 2022
b0370fc
Make CompactUtil backward compatible
srknzl Apr 4, 2022
f34e659
Back compat issue fixed
srknzl Apr 5, 2022
3d228ea
Make class getClass() and typeName getTypeName() in CompactSerializer
srknzl Apr 11, 2022
85444e9
Merge remote-tracking branch 'upstream/master' into compact-eager-des…
srknzl Apr 11, 2022
e2616b3
Fix a typescript problem
srknzl Apr 11, 2022
e5d8b1a
Refactor CompactSerializer
srknzl Apr 11, 2022
34375d2
Merge remote-tracking branch 'upstream/master' into compact-eager-des…
srknzl Apr 11, 2022
3bbfced
Yuce's review comments handled
srknzl Apr 11, 2022
0c755d0
Add ReadOnlyLazyListCompactTest and cover more config builder code
srknzl Apr 12, 2022
da186e9
Fix copyrights after merge
srknzl Apr 12, 2022
3576403
Rename ReadonlyLazyListCompactTest to LazyDeserializationTest and add…
srknzl Apr 12, 2022
1435952
Delete a single excess newline
srknzl Apr 12, 2022
85d7a8f
Some review comments
srknzl Apr 15, 2022
b7479f6
Delete readXXOrDefault methods and add getFieldKind
srknzl Apr 18, 2022
3a074ca
Merge remote-tracking branch 'upstream/master' into compact-eager-des…
srknzl Apr 18, 2022
4231adc
Fix some tests
srknzl Apr 18, 2022
801696b
One whitespace change
srknzl Apr 18, 2022
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
127 changes: 127 additions & 0 deletions benchmark/map_latency_benchmark/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
/*
mdumandag marked this conversation as resolved.
Show resolved Hide resolved
* Copyright (c) 2008-2021, Hazelcast, Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
'use strict';

const { Client } = require('../../lib');
const fs = require('fs');

const CLUSTER_MEMBERS = ['10.212.1.117', '10.212.1.118'];
// const CLUSTER_MEMBERS = ['127.0.0.1'];
const KEY = 1;
const VALUE = 2;
const BENCHMARK_DURATION_SECONDS = 10;
const MAP_NAME = 'test';
const DEFAULT_NUMBER_TYPE = 'integer';

let benchmarkEnded = false;
let warmupEnded = false;

async function createClient() {
const client = await Client.newHazelcastClient({
serialization: {
defaultNumberType: DEFAULT_NUMBER_TYPE
},
network: {
clusterMembers: CLUSTER_MEMBERS
}
});
return client;
}

async function runPut(map) {
const start = process.hrtime.bigint();
await map.put(KEY, VALUE);
const end = process.hrtime.bigint();
return end - start;
}

async function runGet(map) {
const start = process.hrtime.bigint();
await map.get(KEY);
const end = process.hrtime.bigint();
return end - start;
}

async function runBenchMark(timeArray, client, runBenchmarkFn) {
const map = await client.getMap(MAP_NAME);

console.log('Warmup started for ', runBenchmarkFn.name);
while (!warmupEnded) {
await runBenchmarkFn(map);
}

console.log('Benchmark started for ', runBenchmarkFn.name);
while (!benchmarkEnded) {
const timeElapsed = await runBenchmarkFn(map);
timeArray.push(timeElapsed);
}
}

function setBenchmarkAsStartedAndSetTimer() {
benchmarkEnded = false;
warmupEnded = false;
const warmupDuration = BENCHMARK_DURATION_SECONDS * 1000 / 5;
const benchmarkDuration = warmupDuration + BENCHMARK_DURATION_SECONDS * 1000;

setTimeout(() => {
warmupEnded = true;
}, warmupDuration);
setTimeout(() => {
benchmarkEnded = true;
}, benchmarkDuration);
}

function convertToNumbersAndCalculateAverage(timeArray) {
const total = timeArray.reduce((acc, current) => {
return acc + current;
}, 0);
const average = Math.trunc(total / timeArray.length);
return average;
}

function writeToFile(filename, average, timeArray) {
fs.writeFileSync(filename, JSON.stringify({
average,
timeArray
}));
}

async function runBenchMarkAndLogToFile(client, runFn, runBenchmarkFn, filename) {
const timeArray = [];

setBenchmarkAsStartedAndSetTimer();

await runFn(timeArray, client, runBenchmarkFn);

const timeArrayNumbers = timeArray.map(x => Number(x));
const average = convertToNumbersAndCalculateAverage(timeArrayNumbers);

writeToFile(filename, average, timeArrayNumbers);
}

async function main() {
const client = await createClient();

await runBenchMarkAndLogToFile(client, runBenchMark, runPut, 'put.json');
await runBenchMarkAndLogToFile(client, runBenchMark, runGet, 'get.json');

await client.shutdown();
}

main().catch(e => {
console.error(e);
process.exit(1);
});
2 changes: 1 addition & 1 deletion scripts/code-sample-checker.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ exports.main = async (cluster) => {
console.log(`Will run ${JSON.stringify(files)}`);

const numberOfFiles = files.length;
let counter = 0;
let counter = 1;
for (const file of files) {
// start and terminate for each code sample to avoid map name clashes
const member = await RC.startMember(cluster.id);
Expand Down
2 changes: 1 addition & 1 deletion scripts/test-runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ let runTests = true;
let CLASSPATH = `hazelcast-remote-controller-${HAZELCAST_RC_VERSION}.jar${PATH_SEPARATOR}`
+ `hazelcast-${HAZELCAST_TEST_VERSION}-tests.jar${PATH_SEPARATOR}`
+ `hazelcast-sql-${HAZELCAST_VERSION}.jar${PATH_SEPARATOR}`
+ 'test/javaclasses';
+ 'test/integration/resources/compact-test-resources-1.0.jar';

if (HAZELCAST_ENTERPRISE_KEY) {
CLASSPATH = `hazelcast-enterprise-${HAZELCAST_ENTERPRISE_VERSION}.jar${PATH_SEPARATOR}`
Expand Down
43 changes: 26 additions & 17 deletions src/HazelcastClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ import {ClientMessage} from './protocol/ClientMessage';
import {Connection} from './network/Connection';
import {ConnectionRegistryImpl} from './network/ConnectionRegistry';
import {SqlService, SqlServiceImpl} from './sql/SqlService';
import {SchemaService} from './serialization/compact/SchemaService';

/**
* Hazelcast client instance. When you want to use Hazelcast's distributed
Expand Down Expand Up @@ -129,6 +130,8 @@ export class HazelcastClient {
private readonly sqlService: SqlService;
/** @internal */
private shutdownPromise: Promise<void> | undefined;
/** @internal */
private readonly schemaService: SchemaService;

/** @internal */
constructor(config?: ClientConfigImpl, failoverConfig?: ClientFailoverConfigImpl) {
Expand All @@ -140,26 +143,28 @@ export class HazelcastClient {
this.loadBalancer = this.initLoadBalancer();
this.failoverConfig = failoverConfig;
this.errorFactory = new ClientErrorFactory();
this.serializationService = new SerializationServiceV1(this.config.serialization);
this.instanceName = this.config.instanceName || 'hz.client_' + this.id;
this.loggingService = new LoggingService(this.config.customLogger,
this.config.properties['hazelcast.logging.level'] as string);
const logger = this.loggingService.getLogger();
this.schemaService = new SchemaService(() => this.invocationService, logger);
this.serializationService = new SerializationServiceV1(this.config.serialization, this.schemaService);
this.instanceName = this.config.instanceName || 'hz.client_' + this.id;
this.nearCacheManager = new NearCacheManager(
this.config,
this.serializationService
);
this.partitionService = new PartitionServiceImpl(
this.loggingService.getLogger(),
logger,
this.serializationService
);
this.lifecycleService = new LifecycleServiceImpl(
this.config.lifecycleListeners,
this.loggingService.getLogger()
logger
);
this.clusterFailoverService = this.initClusterFailoverService();
this.clusterService = new ClusterService(
this.config,
this.loggingService.getLogger(),
logger,
this.clusterFailoverService
);
this.connectionRegistry = new ConnectionRegistryImpl(
Expand All @@ -171,17 +176,19 @@ export class HazelcastClient {
);
this.invocationService = new InvocationService(
this.config,
this.loggingService.getLogger(),
logger,
this.partitionService as PartitionServiceImpl,
this.errorFactory,
this.lifecycleService,
this.connectionRegistry
this.connectionRegistry,
this.schemaService,
this.serializationService
);
this.connectionManager = new ConnectionManager(
this,
this.instanceName,
this.config,
this.loggingService.getLogger(),
logger,
this.partitionService,
this.serializationService,
this.lifecycleService,
Expand All @@ -192,15 +199,15 @@ export class HazelcastClient {
this.connectionRegistry
);
this.listenerService = new ListenerService(
this.loggingService.getLogger(),
logger,
this.config.network.smartRouting,
this.connectionManager,
this.invocationService
);
this.lockReferenceIdGenerator = new LockReferenceIdGenerator();
this.proxyManager = new ProxyManager(
this.config,
this.loggingService.getLogger(),
logger,
this.invocationService,
this.listenerService,
this.partitionService,
Expand All @@ -209,7 +216,8 @@ export class HazelcastClient {
() => this.getRepairingTask(),
this.clusterService,
this.lockReferenceIdGenerator,
this.connectionRegistry
this.connectionRegistry,
this.schemaService
);
this.statistics = new Statistics(
this.loggingService.getLogger(),
Expand All @@ -220,14 +228,14 @@ export class HazelcastClient {
this.connectionManager
);
this.clusterViewListenerService = new ClusterViewListenerService(
this.loggingService.getLogger(),
logger,
this.connectionManager,
this.partitionService as PartitionServiceImpl,
this.clusterService,
this.invocationService
);
this.cpSubsystem = new CPSubsystemImpl(
this.loggingService.getLogger(),
logger,
this.instanceName,
this.invocationService,
this.serializationService
Expand Down Expand Up @@ -304,12 +312,11 @@ export class HazelcastClient {
const clientMessage = ClientGetDistributedObjectsCodec.encodeRequest();
let localDistributedObjects: Set<string>;
let responseMessage: ClientMessage;
return this.invocationService.invokeOnRandomTarget(clientMessage)
return this.invocationService.invokeOnRandomTarget(clientMessage, x => x)
.then((resp) => {
responseMessage = resp;
return this.proxyManager.getDistributedObjects();
})
.then((distributedObjects) => {
}).then((distributedObjects) => {
localDistributedObjects = new Set<string>();
distributedObjects.forEach((obj) => {
localDistributedObjects.add(obj.getServiceName() + NAMESPACE_SEPARATOR + obj.getName());
Expand Down Expand Up @@ -562,7 +569,9 @@ export class HazelcastClient {

/** @internal */
sendStateToCluster(): Promise<void> {
return this.proxyManager.createDistributedObjectsOnCluster();
return this.schemaService.sendAllSchemas().then(() => {
return this.proxyManager.createDistributedObjectsOnCluster();
});
}

/** @internal */
Expand Down
3 changes: 2 additions & 1 deletion src/PartitionService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export interface PartitionService {
* @param key
* @returns the partition id.
* @throws {@link ClientOfflineError} if the partition table has not arrived yet.
* @throws {@link HazelcastSerializationError} if key cannot be serialized
*/
getPartitionId(key: any): number;

Expand Down Expand Up @@ -106,7 +107,7 @@ export class PartitionServiceImpl implements PartitionService {
if (typeof key === 'object' && 'getPartitionHash' in key) {
partitionHash = key.getPartitionHash();
} else {
partitionHash = this.serializationService.toData(key).getPartitionHash();
zpqrtbnk marked this conversation as resolved.
Show resolved Hide resolved
partitionHash = this.serializationService.toData(key, undefined, false).getPartitionHash();
}
return Math.abs(partitionHash) % this.partitionCount;
}
Expand Down
55 changes: 55 additions & 0 deletions src/codec/ClientFetchSchemaCodec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* Copyright (c) 2008-2021, Hazelcast, Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/* eslint-disable max-len */
import {BitsUtil} from '../util/BitsUtil';
import {FixSizedTypesCodec} from './builtin/FixSizedTypesCodec';
import {ClientMessage, Frame, PARTITION_ID_OFFSET} from '../protocol/ClientMessage';
import * as Long from 'long';
import {Schema} from '../serialization/compact/Schema';
import {SchemaCodec} from './custom/SchemaCodec';
import {CodecUtil} from './builtin/CodecUtil';

// hex: 0x001400
const REQUEST_MESSAGE_TYPE = 5120;
// hex: 0x001401
// RESPONSE_MESSAGE_TYPE = 5121

const REQUEST_SCHEMA_ID_OFFSET = PARTITION_ID_OFFSET + BitsUtil.INT_SIZE_IN_BYTES;
const REQUEST_INITIAL_FRAME_SIZE = REQUEST_SCHEMA_ID_OFFSET + BitsUtil.LONG_SIZE_IN_BYTES;

/** @internal */
export class ClientFetchSchemaCodec {
static encodeRequest(schemaId: Long): ClientMessage {
const clientMessage = ClientMessage.createForEncode();
clientMessage.setRetryable(true);

const initialFrame = Frame.createInitialFrame(REQUEST_INITIAL_FRAME_SIZE);
FixSizedTypesCodec.encodeLong(initialFrame.content, REQUEST_SCHEMA_ID_OFFSET, schemaId);
clientMessage.addFrame(initialFrame);
clientMessage.setMessageType(REQUEST_MESSAGE_TYPE);
clientMessage.setPartitionId(-1);

return clientMessage;
}

static decodeResponse(clientMessage: ClientMessage): Schema {
// empty initial frame
clientMessage.nextFrame();

return CodecUtil.decodeNullable(clientMessage, SchemaCodec.decode);
}
}
Loading