@@ -45,48 +45,49 @@ public class OriginCountJobSession extends BaseJobSession {
45
45
// protected Integer fieldGuardraillimitMB;
46
46
// protected List<MigrateDataType> checkTableforColSizeTypes = new ArrayList<MigrateDataType>();
47
47
//
48
- protected OriginCountJobSession (CqlSession sourceSession , SparkConf sc ) {
48
+ protected OriginCountJobSession (CqlSession originSession , SparkConf sc ) {
49
49
super (sc );
50
- // this.sourceSession = sourceSession ;
51
- // batchSize = new Integer(sc.get("spark.batchSize" , "1"));
52
- // printStatsAfter = new Integer(sc.get("spark.printStatsAfter" , "100000"));
50
+ // this.originSessionSession = originSession ;
51
+ // batchSize = new Integer(sc.get(KnownProperties.SPARK_BATCH_SIZE , "1"));
52
+ // printStatsAfter = new Integer(sc.get(KnownProperties.SPARK_STATS_AFTER , "100000"));
53
53
// if (printStatsAfter < 1) {
54
54
// printStatsAfter = 100000;
55
55
// }
56
56
//
57
- // readLimiter = RateLimiter.create(new Integer(sc.get("spark.readRateLimit" , "20000")));
58
- // sourceKeyspaceTable = sc.get("spark.origin.keyspaceTable" );
57
+ // readLimiter = RateLimiter.create(new Integer(sc.get(KnownProperties.SPARK_LIMIT_READ , "20000")));
58
+ // originKeyspaceTable = sc.get(KnownProperties.ORIGIN_KEYSPACE_TABLE );
59
59
//
60
- // hasRandomPartitioner = Boolean.parseBoolean(sc.get("spark.origin.hasRandomPartitioner" , "false"));
61
- // isCounterTable = Boolean.parseBoolean(sc.get("spark.counterTable" , "false"));
60
+ // hasRandomPartitioner = Boolean.parseBoolean(sc.get(KnownProperties.ORIGIN_HAS_RANDOM_PARTITIONER , "false"));
61
+ // isCounterTable = Boolean.parseBoolean(sc.get(KnownProperties.ORIGIN_IS_COUNTER , "false"));
62
62
//
63
- // checkTableforColSize = Boolean.parseBoolean(sc.get("spark.origin.checkTableforColSize" , "false"));
64
- // checkTableforselectCols = sc.get("spark.origin.checkTableforColSize.cols" );
65
- // checkTableforColSizeTypes = getTypes(sc.get("spark.origin.checkTableforColSize.cols.types" ));
66
- // filterColName = propertyHelper.getString( KnownProperties.ORIGIN_FILTER_COLUMN_NAME);
67
- // filterColType = propertyHelper.getString( KnownProperties.ORIGIN_FILTER_COLUMN_TYPE); // TODO: this is a string, but should be MigrationDataType?
68
- // filterColIndex = Integer.parseInt(sc.get("spark.origin.FilterColumnIndex" , "0"));
69
- // fieldGuardraillimitMB = Integer.parseInt(sc.get("spark.fieldGuardraillimitMB" , "0"));
63
+ // checkTableforColSize = Boolean.parseBoolean(sc.get(KnownProperties.ORIGIN_CHECK_COLSIZE_ENABLED , "false"));
64
+ // checkTableforselectCols = sc.get(KnownProperties.ORIGIN_CHECK_COLSIZE_COLUMN_NAMES );
65
+ // checkTableforColSizeTypes = getTypes(sc.get(KnownProperties.ORIGIN_CHECK_COLSIZE_COLUMN_TYPES ));
66
+ // filterColName = Util.getSparkPropOrEmpty(sc, KnownProperties.ORIGIN_FILTER_COLUMN_NAME);
67
+ // filterColType = Util.getSparkPropOrEmpty(sc, KnownProperties.ORIGIN_FILTER_COLUMN_TYPE);
68
+ // filterColIndex = Integer.parseInt(sc.get(KnownProperties.ORIGIN_FILTER_COLUMN_INDEX , "0"));
69
+ // fieldGuardraillimitMB = Integer.parseInt(sc.get(KnownProperties.FIELD_GUARDRAIL_MB , "0"));
70
70
//
71
- // String partionKey = sc.get("spark.query.cols.partitionKey" );
72
- // idColTypes = getTypes(sc.get("spark.query.cols.id.types" ));
71
+ // String partionKey = sc.get(KnownProperties.ORIGIN_PARTITION_KEY );
72
+ // idColTypes = getTypes(sc.get(KnownProperties.TARGET_PRIMARY_KEY_TYPES ));
73
73
//
74
- // String selectCols = sc.get("spark.query.cols.select" );
75
- // String updateSelectMappingStr = sc.get("spark.counterTable.cql.index" , "0");
74
+ // String selectCols = sc.get(KnownProperties.ORIGIN_COLUMN_NAMES );
75
+ // String updateSelectMappingStr = sc.get(KnownProperties.ORIGIN_COUNTER_INDEXES , "0");
76
76
// for (String updateSelectIndex : updateSelectMappingStr.split(",")) {
77
77
// updateSelectMapping.add(Integer.parseInt(updateSelectIndex));
78
78
// }
79
- // String sourceSelectCondition = sc.get("spark.query.cols.select.condition", "");
80
- // sourceSelectStatement = sourceSession.prepare(
81
- // "select " + selectCols + " from " + sourceKeyspaceTable + " where token(" + partionKey.trim()
82
- // + ") >= ? and token(" + partionKey.trim() + ") <= ? " + sourceSelectCondition + " ALLOW FILTERING");
79
+ // String originSelectCondition = sc.get(KnownProperties.ORIGIN_FILTER_CONDITION, "");
80
+ // // TODO: AbstractJobSession has some checks to ensure AND is added to the condition
81
+ // originSelectStatement = originSession.prepare(
82
+ // "select " + selectCols + " from " + originKeyspaceTable + " where token(" + partionKey.trim()
83
+ // + ") >= ? and token(" + partionKey.trim() + ") <= ? " + originSelectCondition + " ALLOW FILTERING");
83
84
}
84
85
//
85
- // public static OriginCountJobSession getInstance(CqlSession sourceSession , SparkConf sparkConf) {
86
+ // public static OriginCountJobSession getInstance(CqlSession originSession , SparkConf sparkConf) {
86
87
// if (originCountJobSession == null) {
87
88
// synchronized (OriginCountJobSession.class) {
88
89
// if (originCountJobSession == null) {
89
- // originCountJobSession = new OriginCountJobSession(sourceSession , sparkConf);
90
+ // originCountJobSession = new OriginCountJobSession(originSession , sparkConf);
90
91
// }
91
92
// }
92
93
// }
@@ -100,7 +101,7 @@ protected OriginCountJobSession(CqlSession sourceSession, SparkConf sc) {
100
101
// int maxAttempts = maxRetries + 1;
101
102
// for (int attempts = 1; attempts <= maxAttempts && !done; attempts++) {
102
103
// try {
103
- // ResultSet resultSet = sourceSession .execute(sourceSelectStatement .bind(hasRandomPartitioner ?
104
+ // ResultSet resultSet = originSessionSession .execute(originSelectStatement .bind(hasRandomPartitioner ?
104
105
// min : min.longValueExact(), hasRandomPartitioner ? max : max.longValueExact())
105
106
// .setConsistencyLevel(readConsistencyLevel).setPageSize(fetchSizeInRows));
106
107
//
@@ -110,16 +111,16 @@ protected OriginCountJobSession(CqlSession sourceSession, SparkConf sc) {
110
111
// // maxWriteTimeStampFilter is less than max long
111
112
// // do not batch for counters as it adds latency & increases chance of discrepancy
112
113
// if (batchSize == 1 || writeTimeStampFilter || isCounterTable) {
113
- // for (Row sourceRow : resultSet) {
114
+ // for (Row originRow : resultSet) {
114
115
// readLimiter.acquire(1);
115
116
//
116
117
// if (checkTableforColSize) {
117
- // int rowColcnt = GetRowColumnLength(sourceRow , filterColType, filterColIndex);
118
+ // int rowColcnt = GetRowColumnLength(originRow , filterColType, filterColIndex);
118
119
// String result = "";
119
120
// if (rowColcnt > fieldGuardraillimitMB * 1048576) {
120
121
// for (int index = 0; index < checkTableforColSizeTypes.size(); index++) {
121
122
// MigrateDataType dataType = checkTableforColSizeTypes.get(index);
122
- // Object colData = getData(dataType, index, sourceRow );
123
+ // Object colData = getData(dataType, index, originRow );
123
124
// String[] colName = checkTableforselectCols.split(",");
124
125
// result = result + " - " + colName[index] + " : " + colData;
125
126
// }
@@ -130,17 +131,17 @@ protected OriginCountJobSession(CqlSession sourceSession, SparkConf sc) {
130
131
// }
131
132
// } else {
132
133
// BatchStatement batchStatement = BatchStatement.newInstance(BatchType.UNLOGGED);
133
- // for (Row sourceRow : resultSet) {
134
+ // for (Row originRow : resultSet) {
134
135
// readLimiter.acquire(1);
135
136
// writeLimiter.acquire(1);
136
137
//
137
138
// if (checkTableforColSize) {
138
- // int rowColcnt = GetRowColumnLength(sourceRow , filterColType, filterColIndex);
139
+ // int rowColcnt = GetRowColumnLength(originRow , filterColType, filterColIndex);
139
140
// String result = "";
140
141
// if (rowColcnt > fieldGuardraillimitMB * 1048576) {
141
142
// for (int index = 0; index < checkTableforColSizeTypes.size(); index++) {
142
143
// MigrateDataType dataType = checkTableforColSizeTypes.get(index);
143
- // Object colData = getData(dataType, index, sourceRow );
144
+ // Object colData = getData(dataType, index, originRow );
144
145
// String[] colName = checkTableforselectCols.split(",");
145
146
// result = result + " - " + colName[index] + " : " + colData;
146
147
// }
@@ -166,9 +167,9 @@ protected OriginCountJobSession(CqlSession sourceSession, SparkConf sc) {
166
167
// }
167
168
// }
168
169
//
169
- // private int GetRowColumnLength(Row sourceRow , String filterColType, Integer filterColIndex) {
170
+ // private int GetRowColumnLength(Row originRow , String filterColType, Integer filterColIndex) {
170
171
// int sizeInMB = 0;
171
- // Object colData = getData(new MigrateDataType(filterColType), filterColIndex, sourceRow );
172
+ // Object colData = getData(new MigrateDataType(filterColType), filterColIndex, originRow );
172
173
// byte[] colBytes = SerializationUtils.serialize((Serializable) colData);
173
174
// sizeInMB = colBytes.length;
174
175
// if (sizeInMB > fieldGuardraillimitMB)
0 commit comments