Skip to content

Commit

Permalink
Add MultiRange protocol v2 support
Browse files Browse the repository at this point in the history
  • Loading branch information
scotttrinh committed Oct 27, 2023
1 parent 46b30a3 commit 051603b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
4 changes: 3 additions & 1 deletion packages/driver/src/codecs/range.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 121,12 @@ export class RangeCodec extends Codec implements ICodec {

export class MultiRangeCodec extends Codec implements ICodec {
private subCodec: ICodec;
public typeName: string | null;

constructor(tid: uuid, subCodec: ICodec) {
constructor(tid: uuid, typeName: string | null, subCodec: ICodec) {
super(tid);
this.subCodec = subCodec;
this.typeName = typeName;
}

encode(buf: WriteBuffer, obj: any): void {
Expand Down
14 changes: 13 additions & 1 deletion packages/driver/src/codecs/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -605,14 605,26 @@ export class CodecsRegistry {
}

case CTYPE_MULTIRANGE: {
let typeName: string | null = null;
if (isProtoV2) {
typeName = frb.readString();
// @ts-expect-error: reserved for future use
const isSchemaDefined = frb.readBoolean();
const ancestorCount = frb.readUInt16();
for (let i = 0; i < ancestorCount; i ) {
const ancestorPos = frb.readUInt16();
// @ts-expect-error: reserved for future use
const ancestorCodec = cl[ancestorPos];
}
}
const pos = frb.readUInt16();
const subCodec = cl[pos];
if (subCodec == null) {
throw new ProtocolError(
"could not build range codec: missing subcodec"
);
}
res = new MultiRangeCodec(tid, subCodec);
res = new MultiRangeCodec(tid, typeName, subCodec);
break;
}
}
Expand Down

0 comments on commit 051603b

Please sign in to comment.