-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
API-553 Compact serialization and Generic Records (#1172)
- Loading branch information
Showing
111 changed files
with
13,372 additions
and
1,040 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* Copyright (c) 2008-2022, 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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright (c) 2008-2022, 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 {ClientMessage, Frame, PARTITION_ID_OFFSET} from '../protocol/ClientMessage'; | ||
import {Schema} from '../serialization/compact/Schema'; | ||
import {SchemaCodec} from './custom/SchemaCodec'; | ||
import {ListMultiFrameCodec} from './builtin/ListMultiFrameCodec'; | ||
|
||
// hex: 0x001500 | ||
const REQUEST_MESSAGE_TYPE = 5376; | ||
// hex: 0x001501 | ||
// RESPONSE_MESSAGE_TYPE = 5377 | ||
|
||
const REQUEST_INITIAL_FRAME_SIZE = PARTITION_ID_OFFSET + BitsUtil.INT_SIZE_IN_BYTES; | ||
|
||
/** @internal */ | ||
export class ClientSendAllSchemasCodec { | ||
static encodeRequest(schemas: Schema[]): ClientMessage { | ||
const clientMessage = ClientMessage.createForEncode(); | ||
clientMessage.setRetryable(true); | ||
|
||
const initialFrame = Frame.createInitialFrame(REQUEST_INITIAL_FRAME_SIZE); | ||
clientMessage.addFrame(initialFrame); | ||
clientMessage.setMessageType(REQUEST_MESSAGE_TYPE); | ||
clientMessage.setPartitionId(-1); | ||
|
||
ListMultiFrameCodec.encode(clientMessage, schemas, SchemaCodec.encode); | ||
return clientMessage; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright (c) 2008-2022, 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 {ClientMessage, Frame, PARTITION_ID_OFFSET} from '../protocol/ClientMessage'; | ||
import {Schema} from '../serialization/compact/Schema'; | ||
import {SchemaCodec} from './custom/SchemaCodec'; | ||
|
||
// hex: 0x001300 | ||
const REQUEST_MESSAGE_TYPE = 4864; | ||
// hex: 0x001301 | ||
// RESPONSE_MESSAGE_TYPE = 4865 | ||
|
||
const REQUEST_INITIAL_FRAME_SIZE = PARTITION_ID_OFFSET + BitsUtil.INT_SIZE_IN_BYTES; | ||
|
||
/** @internal */ | ||
export class ClientSendSchemaCodec { | ||
static encodeRequest(schema: Schema): ClientMessage { | ||
const clientMessage = ClientMessage.createForEncode(); | ||
clientMessage.setRetryable(true); | ||
|
||
const initialFrame = Frame.createInitialFrame(REQUEST_INITIAL_FRAME_SIZE); | ||
clientMessage.addFrame(initialFrame); | ||
clientMessage.setMessageType(REQUEST_MESSAGE_TYPE); | ||
clientMessage.setPartitionId(-1); | ||
|
||
SchemaCodec.encode(clientMessage, schema); | ||
return clientMessage; | ||
} | ||
} |
Oops, something went wrong.