All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.alibaba.fluss.protogen.tests.ORD Maven / Gradle / Ivy

The newest version!
/*
 * Copyright (c) 2024 Alibaba Group Holding Ltd.
 *
 * 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.
 */

// THIS CODE IS AUTOMATICALLY GENERATED. DO NOT EDIT.

package com.alibaba.fluss.protogen.tests;

import com.alibaba.fluss.rpc.messages.ApiMessage;
import com.alibaba.fluss.record.bytesview.ByteBufBytesView;
import com.alibaba.fluss.record.send.ByteBufWritableOutput;
import com.alibaba.fluss.record.bytesview.BytesView;
import com.alibaba.fluss.rpc.messages.ErrorMessage;
import com.alibaba.fluss.record.bytesview.FileRegionBytesView;
import com.alibaba.fluss.record.bytesview.MemorySegmentBytesView;
import com.alibaba.fluss.utils.ProtoCodecUtils;
import com.alibaba.fluss.record.send.WritableOutput;
import com.alibaba.fluss.shaded.netty4.io.netty.buffer.ByteBuf;
import com.alibaba.fluss.shaded.netty4.io.netty.buffer.Unpooled;

public final class ORD implements ApiMessage {
	private RD rd;
	private static final int _RD_FIELD_NUMBER = 1;
	private static final int _RD_TAG = (_RD_FIELD_NUMBER << ProtoCodecUtils.TAG_TYPE_BITS)
			| ProtoCodecUtils.WIRETYPE_LENGTH_DELIMITED;
	private static final int _RD_TAG_SIZE = ProtoCodecUtils.computeVarIntSize(_RD_TAG);
	private static final int _RD_MASK = 1 << (0 % 32);

	public boolean hasRd() {
		return (_bitField0 & _RD_MASK) != 0;
	}

	public RD getRd() {
		if (!hasRd()) {
			throw new IllegalStateException("Field 'rd' is not set");
		}
		return rd;
	}

	public RD setRd() {
		if (rd == null) {
			rd = new RD();
		}
		_bitField0 |= _RD_MASK;
		_cachedSize = -1;
		return rd;
	}
	public ORD setRd(RD rd) {
		this.rd = rd;
		_bitField0 |= _RD_MASK;
		_cachedSize = -1;
		return this;
	}

	public ORD clearRd() {
		_bitField0 &= ~_RD_MASK;
		if (hasRd()) {
			rd.clear();
		}
		return this;
	}

	private int _bitField0;
	private static final int _REQUIRED_FIELDS_MASK0 = 0;

	@Override
	public int writeTo(ByteBuf _b) {
		int _writeIdx = _b.writerIndex();
		ByteBufWritableOutput _w = new ByteBufWritableOutput(_b);
		this.writeTo(_w);
		return (_b.writerIndex() - _writeIdx);
	}

	@Override
	public void writeTo(WritableOutput _w) {
		if (hasRd()) {
			_w.writeVarInt(_RD_TAG);
			_w.writeVarInt(rd.totalSize());
			rd.writeTo(_w);
		}
	}

	@Override
	public int totalSize() {
		if (_cachedSize > -1) {
			return _cachedSize;
		}

		int _size = 0;
		if (hasRd()) {
			_size += ProtoCodecUtils.computeVarIntSize(_RD_TAG);
			int MsgsizeRd = rd.totalSize();
			_size += ProtoCodecUtils.computeVarIntSize(MsgsizeRd) + MsgsizeRd;
		}
		_cachedSize = _size;
		return _size;
	}

	@Override
	public int zeroCopySize() {
		int _size = 0;
		if (hasRd()) {
			_size += rd.zeroCopySize();
		}
		return _size;
	}

	@Override
	public void parseFrom(ByteBuf _buffer, int _size) {
		clear();
		int _endIdx = _buffer.readerIndex() + _size;
		while (_buffer.readerIndex() < _endIdx) {
			int _tag = ProtoCodecUtils.readVarInt(_buffer);
			switch (_tag) {
				case _RD_TAG :
					_bitField0 |= _RD_MASK;
					int rdSize = ProtoCodecUtils.readVarInt(_buffer);
					setRd().parseFrom(_buffer, rdSize);
					break;
				default :
					ProtoCodecUtils.skipUnknownField(_tag, _buffer);
			}
		}
		_parsedBuffer = _buffer;
	}

	@Override
	public boolean isLazilyParsed() {
		return true;
	}

	public ORD clear() {
		if (hasRd()) {
			rd.clear();
		}
		_parsedBuffer = null;
		_cachedSize = -1;
		_bitField0 = 0;
		return this;
	}

	public ORD copyFrom(ORD _other) {
		_cachedSize = -1;
		if (_other.hasRd()) {
			setRd().copyFrom(_other.rd);
		}
		return this;
	}

	@Override
	public byte[] toByteArray() {
		byte[] a = new byte[this.totalSize()];
		ByteBuf b = Unpooled.wrappedBuffer(a).writerIndex(0);
		this.writeTo(b);
		return a;
	}

	@Override
	public void parseFrom(byte[] a) {
		ByteBuf b = Unpooled.wrappedBuffer(a);
		this.parseFrom(b, b.readableBytes());
	}
	private int _cachedSize = -1;

	private ByteBuf _parsedBuffer;

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy