@@ -78,6 +78,34 @@ public BinaryColumn(int positionCount, Optional<boolean[]> valueIsNull, Binary[]
78
78
retainedSizeInBytes = INSTANCE_SIZE + sizeOfBooleanArray (positionCount ) + sizeOf (values );
79
79
}
80
80
81
+ // called by getRegion which already knows the underlying retainedSizeInBytes
82
+ private BinaryColumn (
83
+ int arrayOffset ,
84
+ int positionCount ,
85
+ boolean [] valueIsNull ,
86
+ Binary [] values ,
87
+ long retainedSizeInBytes ) {
88
+ if (arrayOffset < 0 ) {
89
+ throw new IllegalArgumentException ("arrayOffset is negative" );
90
+ }
91
+ this .arrayOffset = arrayOffset ;
92
+ if (positionCount < 0 ) {
93
+ throw new IllegalArgumentException ("positionCount is negative" );
94
+ }
95
+ this .positionCount = positionCount ;
96
+
97
+ if (values .length - arrayOffset < positionCount ) {
98
+ throw new IllegalArgumentException ("values length is less than positionCount" );
99
+ }
100
+ this .values = values ;
101
+
102
+ if (valueIsNull != null && valueIsNull .length - arrayOffset < positionCount ) {
103
+ throw new IllegalArgumentException ("isNull length is less than positionCount" );
104
+ }
105
+ this .valueIsNull = valueIsNull ;
106
+ this .retainedSizeInBytes = retainedSizeInBytes ;
107
+ }
108
+
81
109
@ Override
82
110
public TSDataType getDataType () {
83
111
return TSDataType .TEXT ;
@@ -141,7 +169,8 @@ public long getRetainedSizeInBytes() {
141
169
@ Override
142
170
public Column getRegion (int positionOffset , int length ) {
143
171
checkValidRegion (getPositionCount (), positionOffset , length );
144
- return new BinaryColumn (positionOffset + arrayOffset , length , valueIsNull , values );
172
+ return new BinaryColumn (
173
+ positionOffset + arrayOffset , length , valueIsNull , values , getRetainedSizeInBytes ());
145
174
}
146
175
147
176
@ Override
0 commit comments