public static Row createSingleStringRow(String value, int protocolVersion) { ColumnDefinitions definitions = new ColumnDefinitions(new Definition[] {new Definition("keyspace", "table", "column", DataType.ascii())}, CodecRegistry.DEFAULT_INSTANCE); ByteBuffer data = ByteBuffer.wrap(value.getBytes(UTF_8)); return ArrayBackedRow.fromData(definitions, null, ProtocolVersion.fromInt(protocolVersion), ImmutableList.of(data)); } }
builder = builder.withProtocolVersion(ProtocolVersion.fromInt(protoVer));
private PagingState(byte[] complete) { // Check the sizes in the beginning of the buffer, otherwise we cannot build the paging state // object ByteBuffer pagingStateBB = ByteBuffer.wrap(complete); int pagingSize = pagingStateBB.getShort(); int hashSize = pagingStateBB.getShort(); if (pagingSize + hashSize != pagingStateBB.remaining() && pagingSize + hashSize + 2 != pagingStateBB.remaining()) { throw new PagingStateException( "Cannot deserialize paging state, invalid format. " + "The serialized form was corrupted, or not initially generated from a PagingState object."); } this.pagingState = new byte[pagingSize]; pagingStateBB.get(this.pagingState); this.hash = new byte[hashSize]; pagingStateBB.get(this.hash); this.protocolVersion = (pagingStateBB.remaining() > 0) ? ProtocolVersion.fromInt(pagingStateBB.getShort()) : ProtocolVersion.V2; }
private static Frame create(ByteBuf fullFrame) { assert fullFrame.readableBytes() >= 1 : String.format("Frame too short (%d bytes)", fullFrame.readableBytes()); int versionBytes = fullFrame.readByte(); // version first byte is the "direction" of the frame (request or response) ProtocolVersion version = ProtocolVersion.fromInt(versionBytes & 0x7F); int hdrLen = Header.lengthFor(version); assert fullFrame.readableBytes() >= (hdrLen - 1) : String.format("Frame too short (%d bytes)", fullFrame.readableBytes()); int flags = fullFrame.readByte(); int streamId = readStreamid(fullFrame, version); int opcode = fullFrame.readByte(); int length = fullFrame.readInt(); assert length == fullFrame.readableBytes(); Header header = new Header(version, flags, streamId, opcode); return new Frame(header, fullFrame); }
private PagingState(byte[] complete) { // Check the sizes in the beginning of the buffer, otherwise we cannot build the paging state object ByteBuffer pagingStateBB = ByteBuffer.wrap(complete); int pagingSize = pagingStateBB.getShort(); int hashSize = pagingStateBB.getShort(); if (pagingSize + hashSize != pagingStateBB.remaining() && pagingSize + hashSize + 2 != pagingStateBB.remaining()) { throw new PagingStateException("Cannot deserialize paging state, invalid format. " + "The serialized form was corrupted, or not initially generated from a PagingState object."); } this.pagingState = new byte[pagingSize]; pagingStateBB.get(this.pagingState); this.hash = new byte[hashSize]; pagingStateBB.get(this.hash); this.protocolVersion = (pagingStateBB.remaining() > 0) ? ProtocolVersion.fromInt(pagingStateBB.getShort()) : ProtocolVersion.V2; }
private PagingState(byte[] complete) { // Check the sizes in the beginning of the buffer, otherwise we cannot build the paging state object ByteBuffer pagingStateBB = ByteBuffer.wrap(complete); int pagingSize = pagingStateBB.getShort(); int hashSize = pagingStateBB.getShort(); if (pagingSize + hashSize != pagingStateBB.remaining() && pagingSize + hashSize + 2 != pagingStateBB.remaining()) { throw new PagingStateException("Cannot deserialize paging state, invalid format. " + "The serialized form was corrupted, or not initially generated from a PagingState object."); } this.pagingState = new byte[pagingSize]; pagingStateBB.get(this.pagingState); this.hash = new byte[hashSize]; pagingStateBB.get(this.hash); this.protocolVersion = (pagingStateBB.remaining() > 0) ? ProtocolVersion.fromInt(pagingStateBB.getShort()) : ProtocolVersion.V2; }
private PagingState(byte[] complete) { // Check the sizes in the beginning of the buffer, otherwise we cannot build the paging state object ByteBuffer pagingStateBB = ByteBuffer.wrap(complete); int pagingSize = pagingStateBB.getShort(); int hashSize = pagingStateBB.getShort(); if (pagingSize + hashSize != pagingStateBB.remaining() && pagingSize + hashSize + 2 != pagingStateBB.remaining()) { throw new PagingStateException("Cannot deserialize paging state, invalid format. " + "The serialized form was corrupted, or not initially generated from a PagingState object."); } this.pagingState = new byte[pagingSize]; pagingStateBB.get(this.pagingState); this.hash = new byte[hashSize]; pagingStateBB.get(this.hash); this.protocolVersion = (pagingStateBB.remaining() > 0) ? ProtocolVersion.fromInt(pagingStateBB.getShort()) : ProtocolVersion.V2; }
private static Frame create(ByteBuf fullFrame) { assert fullFrame.readableBytes() >= 1 : String.format("Frame too short (%d bytes)", fullFrame.readableBytes()); int versionBytes = fullFrame.readByte(); // version first byte is the "direction" of the frame (request or response) ProtocolVersion version = ProtocolVersion.fromInt(versionBytes & 0x7F); int hdrLen = Header.lengthFor(version); assert fullFrame.readableBytes() >= (hdrLen - 1) : String.format("Frame too short (%d bytes)", fullFrame.readableBytes()); int flags = fullFrame.readByte(); int streamId = readStreamid(fullFrame, version); int opcode = fullFrame.readByte(); int length = fullFrame.readInt(); assert length == fullFrame.readableBytes(); Header header = new Header(version, flags, streamId, opcode); return new Frame(header, fullFrame); }
private static Frame create(ByteBuf fullFrame) { assert fullFrame.readableBytes() >= 1 : String.format("Frame too short (%d bytes)", fullFrame.readableBytes()); int versionBytes = fullFrame.readByte(); // version first byte is the "direction" of the frame (request or response) ProtocolVersion version = ProtocolVersion.fromInt(versionBytes & 0x7F); int hdrLen = Header.lengthFor(version); assert fullFrame.readableBytes() >= (hdrLen - 1) : String.format("Frame too short (%d bytes)", fullFrame.readableBytes()); int flags = fullFrame.readByte(); int streamId = readStreamid(fullFrame, version); int opcode = fullFrame.readByte(); int length = fullFrame.readInt(); assert length == fullFrame.readableBytes(); Header header = new Header(version, flags, streamId, opcode); return new Frame(header, fullFrame); }
private static Frame create(ByteBuf fullFrame) { assert fullFrame.readableBytes() >= 1 : String.format("Frame too short (%d bytes)", fullFrame.readableBytes()); int versionBytes = fullFrame.readByte(); // version first byte is the "direction" of the frame (request or response) ProtocolVersion version = ProtocolVersion.fromInt(versionBytes & 0x7F); int hdrLen = Header.lengthFor(version); assert fullFrame.readableBytes() >= (hdrLen - 1) : String.format("Frame too short (%d bytes)", fullFrame.readableBytes()); int flags = fullFrame.readByte(); int streamId = readStreamid(fullFrame, version); int opcode = fullFrame.readByte(); int length = fullFrame.readInt(); assert length == fullFrame.readableBytes(); Header header = new Header(version, flags, streamId, opcode); return new Frame(header, fullFrame); }
public static Object deserialize(TypeCodec<?> codec, ProtocolVersion protocolVersion, ByteBuffer value) { return codec.deserialize(value, com.datastax.driver.core.ProtocolVersion.fromInt(protocolVersion.asInt())); }
public static DataType driverTypeFromAbstractType(String abstractTypeDef) { try { return (DataType) methodParseOne.invoke(abstractTypeDef, com.datastax.driver.core.ProtocolVersion.fromInt(ProtocolVersion.CURRENT.asInt()), codecRegistry); } catch (RuntimeException | Error e) { // immediately rethrow these... throw e; } catch (Throwable e) { throw new RuntimeException("cannot parse driver type " + abstractTypeDef, e); } }
public static Object deserialize(TypeCodec<?> codec, ProtocolVersion protocolVersion, ByteBuffer value) { return codec.deserialize(value, com.datastax.driver.core.ProtocolVersion.fromInt(protocolVersion.asInt())); }
public static Object deserialize(TypeCodec<?> codec, ProtocolVersion protocolVersion, ByteBuffer value) { return codec.deserialize(value, com.datastax.driver.core.ProtocolVersion.fromInt(protocolVersion.asInt())); }
public static DataType driverTypeFromAbstractType(String abstractTypeDef) { try { return (DataType) methodParseOne.invoke(abstractTypeDef, com.datastax.driver.core.ProtocolVersion.fromInt(ProtocolVersion.CURRENT.asInt()), codecRegistry); } catch (RuntimeException | Error e) { // immediately rethrow these... throw e; } catch (Throwable e) { throw new RuntimeException("cannot parse driver type " + abstractTypeDef, e); } }
public static ByteBuffer serialize(TypeCodec<?> codec, ProtocolVersion protocolVersion, Object value) { if (!codec.getJavaType().getRawType().isAssignableFrom(value.getClass())) throw new InvalidTypeException("Invalid value for CQL type " + codec.getCqlType().getName().toString()); return ((TypeCodec)codec).serialize(value, com.datastax.driver.core.ProtocolVersion.fromInt(protocolVersion.asInt())); }
public static ByteBuffer serialize(TypeCodec<?> codec, ProtocolVersion protocolVersion, Object value) { if (!codec.getJavaType().getRawType().isAssignableFrom(value.getClass())) throw new InvalidTypeException("Invalid value for CQL type " + codec.getCqlType().getName().toString()); return ((TypeCodec)codec).serialize(value, com.datastax.driver.core.ProtocolVersion.fromInt(protocolVersion.asInt())); }
public static ByteBuffer serialize(TypeCodec<?> codec, ProtocolVersion protocolVersion, Object value) { if (!codec.getJavaType().getRawType().isAssignableFrom(value.getClass())) throw new InvalidTypeException("Invalid value for CQL type " + codec.getCqlType().getName().toString()); return ((TypeCodec)codec).serialize(value, com.datastax.driver.core.ProtocolVersion.fromInt(protocolVersion.asInt())); }
public static Row createSingleStringRow(String value, int protocolVersion) { ColumnDefinitions definitions = new ColumnDefinitions(new Definition[] {new Definition("keyspace", "table", "column", DataType.ascii())}, CodecRegistry.DEFAULT_INSTANCE); ByteBuffer data = ByteBuffer.wrap(value.getBytes(UTF_8)); return ArrayBackedRow.fromData(definitions, null, ProtocolVersion.fromInt(protocolVersion), ImmutableList.of(data)); } }
public static Row createSingleStringRow(String value, int protocolVersion) { ColumnDefinitions definitions = new ColumnDefinitions(new Definition[] {new Definition("keyspace", "table", "column", DataType.ascii())}, CodecRegistry.DEFAULT_INSTANCE); ByteBuffer data = ByteBuffer.wrap(value.getBytes(UTF_8)); return ArrayBackedRow.fromData(definitions, null, ProtocolVersion.fromInt(protocolVersion), ImmutableList.of(data)); } }