@@ -24,6 +24,7 @@ public class OriginCountJobSession extends BaseJobSession{
24
24
protected String filterColName ;
25
25
protected String filterColType ;
26
26
protected Integer filterColIndex ;
27
+ protected Integer fieldGuardraillimitMB ;
27
28
protected List <MigrateDataType > checkTableforColSizeTypes = new ArrayList <MigrateDataType >();
28
29
public static OriginCountJobSession getInstance (CqlSession sourceSession , SparkConf sparkConf ) {
29
30
if (originCountJobSession == null ) {
@@ -57,6 +58,7 @@ protected OriginCountJobSession(CqlSession sourceSession, SparkConf sparkConf) {
57
58
filterColName = sparkConf .get ("spark.origin.FilterColumn" );
58
59
filterColType = sparkConf .get ("spark.origin.FilterColumnType" );
59
60
filterColIndex = Integer .parseInt (sparkConf .get ("spark.origin.FilterColumnIndex" , "0" ));
61
+ fieldGuardraillimitMB = Integer .parseInt (sparkConf .get ("spark.fieldGuardraillimitMB" , "0" ));
60
62
61
63
String partionKey = sparkConf .get ("spark.query.cols.partitionKey" );
62
64
idColTypes = getTypes (sparkConf .get ("spark.query.cols.id.types" ));
@@ -92,7 +94,7 @@ public void getData(BigInteger min, BigInteger max) {
92
94
if (checkTableforColSize ) {
93
95
int rowColcnt = GetRowColumnLength (sourceRow , filterColType , filterColIndex );
94
96
String result = "" ;
95
- if (rowColcnt > 1024 * 1024 * 10 ) {
97
+ if (rowColcnt > fieldGuardraillimitMB ) {
96
98
for (int index = 0 ; index < checkTableforColSizeTypes .size (); index ++) {
97
99
MigrateDataType dataType = checkTableforColSizeTypes .get (index );
98
100
Object colData = getData (dataType , index , sourceRow );
@@ -114,7 +116,7 @@ public void getData(BigInteger min, BigInteger max) {
114
116
if (checkTableforColSize ) {
115
117
int rowColcnt = GetRowColumnLength (sourceRow , filterColType , filterColIndex );
116
118
String result = "" ;
117
- if (rowColcnt > 1024 * 1024 * 10 ) {
119
+ if (rowColcnt > fieldGuardraillimitMB ) {
118
120
for (int index = 0 ; index < checkTableforColSizeTypes .size (); index ++) {
119
121
MigrateDataType dataType = checkTableforColSizeTypes .get (index );
120
122
Object colData = getData (dataType , index , sourceRow );
@@ -145,13 +147,13 @@ public void getData(BigInteger min, BigInteger max) {
145
147
}
146
148
147
149
private int GetRowColumnLength (Row sourceRow , String filterColType , Integer filterColIndex ) {
148
- int i = 0 ;
150
+ int sizeInMB = 0 ;
149
151
Object colData = getData (new MigrateDataType (filterColType ), filterColIndex , sourceRow );
150
152
byte [] colBytes = SerializationUtils .serialize ((Serializable ) colData );
151
- i = colBytes .length ;
152
- if (i > 1024 * 1024 * 10 )
153
- return i ;
154
- return i ;
153
+ sizeInMB = colBytes .length ;
154
+ if (sizeInMB > fieldGuardraillimitMB )
155
+ return sizeInMB ;
156
+ return sizeInMB ;
155
157
}
156
158
157
159
}
0 commit comments