@@ -34,9 +34,9 @@ import (
3434 "runtime"
3535 "strings"
3636 "time"
37- )
3837
39- type unsetColumn struct {}
38+ "github.com/gocql/gocql/internal"
39+ )
4040
4141// UnsetValue represents a value used in a query binding that will be ignored by Cassandra.
4242//
@@ -45,7 +45,7 @@ type unsetColumn struct{}
4545// want to update some fields, where before you needed to make another prepared statement.
4646//
4747// UnsetValue is only available when using the version 4 of the protocol.
48- var UnsetValue = unsetColumn {}
48+ var UnsetValue = internal. UnsetColumn {}
4949
5050type namedValue struct {
5151 name string
@@ -331,10 +331,6 @@ var (
331331
332332const maxFrameHeaderSize = 9
333333
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-
338334type frameHeader struct {
339335 version protoVersion
340336 flags byte
@@ -474,15 +470,15 @@ func readHeader(r io.Reader, p []byte) (head frameHeader, err error) {
474470
475471 head .stream = int (int16 (p [2 ])<< 8 | int16 (p [3 ]))
476472 head .op = frameOp (p [4 ])
477- head .length = int (readInt (p [5 :]))
473+ head .length = int (internal . ReadInt (p [5 :]))
478474 } else {
479475 if len (p ) != 8 {
480476 return frameHeader {}, fmt .Errorf ("not enough bytes to read header require 8 got: %d" , len (p ))
481477 }
482478
483479 head .stream = int (int8 (p [2 ]))
484480 head .op = frameOp (p [3 ])
485- head .length = int (readInt (p [4 :]))
481+ head .length = int (internal . ReadInt (p [4 :]))
486482 }
487483
488484 return head , nil
@@ -647,7 +643,7 @@ func (f *framer) parseErrorFrame() frame {
647643 stmtId := f .readShortBytes ()
648644 return & RequestErrUnprepared {
649645 errorFrame : errD ,
650- StatementId : copyBytes (stmtId ), // defensively copy
646+ StatementId : internal . CopyBytes (stmtId ), // defensively copy
651647 }
652648 case ErrCodeReadFailure :
653649 res := & RequestErrReadFailure {
@@ -969,7 +965,7 @@ func (f *framer) parsePreparedMetadata() preparedMetadata {
969965 }
970966
971967 if meta .flags & flagHasMorePages == flagHasMorePages {
972- meta .pagingState = copyBytes (f .readBytes ())
968+ meta .pagingState = internal . CopyBytes (f .readBytes ())
973969 }
974970
975971 if meta .flags & flagNoMetaData == flagNoMetaData {
@@ -1057,7 +1053,7 @@ func (f *framer) parseResultMetadata() resultMetadata {
10571053 meta .actualColCount = meta .colCount
10581054
10591055 if meta .flags & flagHasMorePages == flagHasMorePages {
1060- meta .pagingState = copyBytes (f .readBytes ())
1056+ meta .pagingState = internal . CopyBytes (f .readBytes ())
10611057 }
10621058
10631059 if meta .flags & flagNoMetaData == flagNoMetaData {
@@ -1940,49 +1936,6 @@ func (f *framer) writeByte(b byte) {
19401936 f .buf = append (f .buf , b )
19411937}
19421938
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-
19861939func (f * framer ) writeCustomPayload (customPayload * map [string ][]byte ) {
19871940 if len (* customPayload ) > 0 {
19881941 if f .proto < protoVersion4 {
@@ -1994,19 +1947,19 @@ func (f *framer) writeCustomPayload(customPayload *map[string][]byte) {
19941947
19951948// these are protocol level binary types
19961949func (f * framer ) writeInt (n int32 ) {
1997- f .buf = appendInt (f .buf , n )
1950+ f .buf = internal . AppendInt (f .buf , n )
19981951}
19991952
20001953func (f * framer ) writeUint (n uint32 ) {
2001- f .buf = appendUint (f .buf , n )
1954+ f .buf = internal . AppendUint (f .buf , n )
20021955}
20031956
20041957func (f * framer ) writeShort (n uint16 ) {
2005- f .buf = appendShort (f .buf , n )
1958+ f .buf = internal . AppendShort (f .buf , n )
20061959}
20071960
20081961func (f * framer ) writeLong (n int64 ) {
2009- f .buf = appendLong (f .buf , n )
1962+ f .buf = internal . AppendLong (f .buf , n )
20101963}
20111964
20121965func (f * framer ) writeString (s string ) {
0 commit comments