@@ -28,6 +28,7 @@ import (
2828 "context"
2929 "errors"
3030 "fmt"
31+ "github.com/gocql/gocql/internal"
3132 "io"
3233 "io/ioutil"
3334 "net"
@@ -36,16 +37,14 @@ import (
3637 "time"
3738)
3839
39- type unsetColumn struct {}
40-
4140// UnsetValue represents a value used in a query binding that will be ignored by Cassandra.
4241//
4342// By setting a field to the unset value Cassandra will ignore the write completely.
4443// The main advantage is the ability to keep the same prepared statement even when you don't
4544// want to update some fields, where before you needed to make another prepared statement.
4645//
4746// UnsetValue is only available when using the version 4 of the protocol.
48- var UnsetValue = unsetColumn {}
47+ var UnsetValue = internal. UnsetColumn {}
4948
5049type namedValue struct {
5150 name string
@@ -331,10 +330,6 @@ var (
331330
332331const maxFrameHeaderSize = 9
333332
334- func readInt (p []byte ) int32 {
335- return int32 (p [0 ])<< 24 | int32 (p [1 ])<< 16 | int32 (p [2 ])<< 8 | int32 (p [3 ])
336- }
337-
338333type frameHeader struct {
339334 version protoVersion
340335 flags byte
@@ -474,15 +469,15 @@ func readHeader(r io.Reader, p []byte) (head frameHeader, err error) {
474469
475470 head .stream = int (int16 (p [2 ])<< 8 | int16 (p [3 ]))
476471 head .op = frameOp (p [4 ])
477- head .length = int (readInt (p [5 :]))
472+ head .length = int (internal . ReadInt (p [5 :]))
478473 } else {
479474 if len (p ) != 8 {
480475 return frameHeader {}, fmt .Errorf ("not enough bytes to read header require 8 got: %d" , len (p ))
481476 }
482477
483478 head .stream = int (int8 (p [2 ]))
484479 head .op = frameOp (p [3 ])
485- head .length = int (readInt (p [4 :]))
480+ head .length = int (internal . ReadInt (p [4 :]))
486481 }
487482
488483 return head , nil
@@ -647,7 +642,7 @@ func (f *framer) parseErrorFrame() frame {
647642 stmtId := f .readShortBytes ()
648643 return & RequestErrUnprepared {
649644 errorFrame : errD ,
650- StatementId : copyBytes (stmtId ), // defensively copy
645+ StatementId : internal . CopyBytes (stmtId ), // defensively copy
651646 }
652647 case ErrCodeReadFailure :
653648 res := & RequestErrReadFailure {
@@ -969,7 +964,7 @@ func (f *framer) parsePreparedMetadata() preparedMetadata {
969964 }
970965
971966 if meta .flags & flagHasMorePages == flagHasMorePages {
972- meta .pagingState = copyBytes (f .readBytes ())
967+ meta .pagingState = internal . CopyBytes (f .readBytes ())
973968 }
974969
975970 if meta .flags & flagNoMetaData == flagNoMetaData {
@@ -1057,7 +1052,7 @@ func (f *framer) parseResultMetadata() resultMetadata {
10571052 meta .actualColCount = meta .colCount
10581053
10591054 if meta .flags & flagHasMorePages == flagHasMorePages {
1060- meta .pagingState = copyBytes (f .readBytes ())
1055+ meta .pagingState = internal . CopyBytes (f .readBytes ())
10611056 }
10621057
10631058 if meta .flags & flagNoMetaData == flagNoMetaData {
@@ -1940,49 +1935,6 @@ func (f *framer) writeByte(b byte) {
19401935 f .buf = append (f .buf , b )
19411936}
19421937
1943- func appendBytes (p []byte , d []byte ) []byte {
1944- if d == nil {
1945- return appendInt (p , - 1 )
1946- }
1947- p = appendInt (p , int32 (len (d )))
1948- p = append (p , d ... )
1949- return p
1950- }
1951-
1952- func appendShort (p []byte , n uint16 ) []byte {
1953- return append (p ,
1954- byte (n >> 8 ),
1955- byte (n ),
1956- )
1957- }
1958-
1959- func appendInt (p []byte , n int32 ) []byte {
1960- return append (p , byte (n >> 24 ),
1961- byte (n >> 16 ),
1962- byte (n >> 8 ),
1963- byte (n ))
1964- }
1965-
1966- func appendUint (p []byte , n uint32 ) []byte {
1967- return append (p , byte (n >> 24 ),
1968- byte (n >> 16 ),
1969- byte (n >> 8 ),
1970- byte (n ))
1971- }
1972-
1973- func appendLong (p []byte , n int64 ) []byte {
1974- return append (p ,
1975- byte (n >> 56 ),
1976- byte (n >> 48 ),
1977- byte (n >> 40 ),
1978- byte (n >> 32 ),
1979- byte (n >> 24 ),
1980- byte (n >> 16 ),
1981- byte (n >> 8 ),
1982- byte (n ),
1983- )
1984- }
1985-
19861938func (f * framer ) writeCustomPayload (customPayload * map [string ][]byte ) {
19871939 if len (* customPayload ) > 0 {
19881940 if f .proto < protoVersion4 {
@@ -1994,19 +1946,19 @@ func (f *framer) writeCustomPayload(customPayload *map[string][]byte) {
19941946
19951947// these are protocol level binary types
19961948func (f * framer ) writeInt (n int32 ) {
1997- f .buf = appendInt (f .buf , n )
1949+ f .buf = internal . AppendInt (f .buf , n )
19981950}
19991951
20001952func (f * framer ) writeUint (n uint32 ) {
2001- f .buf = appendUint (f .buf , n )
1953+ f .buf = internal . AppendUint (f .buf , n )
20021954}
20031955
20041956func (f * framer ) writeShort (n uint16 ) {
2005- f .buf = appendShort (f .buf , n )
1957+ f .buf = internal . AppendShort (f .buf , n )
20061958}
20071959
20081960func (f * framer ) writeLong (n int64 ) {
2009- f .buf = appendLong (f .buf , n )
1961+ f .buf = internal . AppendLong (f .buf , n )
20101962}
20111963
20121964func (f * framer ) writeString (s string ) {
0 commit comments