Skip to content

Commit a566e46

Browse files
committed
prepare version 0.48.6-public
1 parent 5b9bb57 commit a566e46

File tree

57 files changed

+1668
-376
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+1668
-376
lines changed

odps-sdk-impl/odps-common-local/src/main/java/com/aliyun/odps/local/common/AnyTypeInfo.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import com.aliyun.odps.type.TypeInfo;
55

66
public class AnyTypeInfo implements TypeInfo {
7+
private static final long serialVersionUID = 1L;
78

89
@Override
910
public String getTypeName() {

odps-sdk/odps-sdk-commons/src/main/java/com/aliyun/odps/Column.java

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@
1919

2020
package com.aliyun.odps;
2121

22+
import java.io.Serializable;
2223
import java.util.ArrayList;
2324
import java.util.List;
25+
import java.util.Objects;
2426

2527
import com.aliyun.odps.type.ArrayTypeInfo;
2628
import com.aliyun.odps.type.MapTypeInfo;
@@ -30,8 +32,8 @@
3032
/**
3133
* Column表示ODPS中表的列定义
3234
*/
33-
public final class Column {
34-
35+
public final class Column implements Serializable {
36+
private static final long serialVersionUID = 1L;
3537
private String name;
3638
private OdpsType type;
3739
private TypeInfo typeInfo;
@@ -41,7 +43,6 @@ public final class Column {
4143
private String defaultValue = null;
4244
private boolean isNullable = true;
4345
private boolean hasDefaultValue = false;
44-
private boolean primaryKey = false;
4546

4647
private List<OdpsType> genericOdpsTypeList;
4748
private List<String> extendedLabels;
@@ -114,7 +115,6 @@ public Column(ColumnBuilder columnBuilder) {
114115
this(columnBuilder.name, columnBuilder.typeInfo, columnBuilder.comment, columnBuilder.label,
115116
columnBuilder.extendedLabels);
116117
this.isNullable = !columnBuilder.notNull;
117-
this.primaryKey = columnBuilder.primaryKey;
118118
}
119119

120120
/**
@@ -380,8 +380,30 @@ public boolean hasDefaultValue()
380380
return hasDefaultValue;
381381
}
382382

383-
public boolean isPrimaryKey() {
384-
return primaryKey;
383+
384+
@Override
385+
public boolean equals(Object o) {
386+
if (this == o) {
387+
return true;
388+
}
389+
if (o == null || getClass() != o.getClass()) {
390+
return false;
391+
}
392+
Column column = (Column) o;
393+
return isNullable == column.isNullable && hasDefaultValue == column.hasDefaultValue
394+
&& Objects.equals(name, column.name)
395+
&& type == column.type && Objects.equals(typeInfo, column.typeInfo)
396+
&& Objects.equals(comment, column.comment) && Objects.equals(label,
397+
column.label)
398+
&& Objects.equals(defaultValue, column.defaultValue) && Objects.equals(
399+
genericOdpsTypeList, column.genericOdpsTypeList) && Objects.equals(extendedLabels,
400+
column.extendedLabels);
401+
}
402+
403+
@Override
404+
public int hashCode() {
405+
return Objects.hash(name, type, typeInfo, comment, label, defaultValue, isNullable,
406+
hasDefaultValue, genericOdpsTypeList, extendedLabels);
385407
}
386408

387409
public static class ColumnBuilder {
@@ -392,7 +414,6 @@ public static class ColumnBuilder {
392414
private String label;
393415
private List<String> extendedLabels;
394416
private boolean notNull = false;
395-
private boolean primaryKey = false;
396417

397418
private ColumnBuilder(String name, TypeInfo typeInfo) {
398419
this.name = name;
@@ -419,12 +440,6 @@ public ColumnBuilder notNull() {
419440
return this;
420441
}
421442

422-
public ColumnBuilder primaryKey() {
423-
this.primaryKey = true;
424-
this.notNull = true;
425-
return this;
426-
}
427-
428443
public Column build() {
429444
return new Column(this);
430445
}

odps-sdk/odps-sdk-commons/src/main/java/com/aliyun/odps/OdpsType.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,13 @@
1919

2020
package com.aliyun.odps;
2121

22+
import java.io.Serializable;
2223
import java.util.List;
2324

2425
/**
2526
* ODPS表支持的字段类型
2627
*/
27-
public enum OdpsType {
28+
public enum OdpsType implements Serializable {
2829
/**
2930
* 8字节有符号整型
3031
*/

odps-sdk/odps-sdk-commons/src/main/java/com/aliyun/odps/TableSchema.java

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,19 @@
1919

2020
package com.aliyun.odps;
2121

22+
import java.io.Serializable;
2223
import java.util.ArrayList;
2324
import java.util.HashMap;
2425
import java.util.List;
26+
import java.util.Objects;
2527

2628
import com.aliyun.odps.type.TypeInfoFactory;
2729

2830
/**
2931
* TableSchema表示ODPS中表的定义
3032
*/
31-
public class TableSchema {
32-
33+
public class TableSchema implements Serializable {
34+
private static final long serialVersionUID = 1L;
3335
private ArrayList<Column> columns = new ArrayList<Column>();
3436
private ArrayList<Column> partitionColumns = new ArrayList<Column>();
3537

@@ -271,6 +273,25 @@ public boolean basicallyEquals(Object o) {
271273
return true;
272274
}
273275

276+
@Override
277+
public boolean equals(Object o) {
278+
if (this == o) {
279+
return true;
280+
}
281+
if (o == null || getClass() != o.getClass()) {
282+
return false;
283+
}
284+
TableSchema that = (TableSchema) o;
285+
return Objects.equals(columns, that.columns) && Objects.equals(
286+
partitionColumns, that.partitionColumns) && Objects.equals(nameMap, that.nameMap)
287+
&& Objects.equals(partitionNameMap, that.partitionNameMap);
288+
}
289+
290+
@Override
291+
public int hashCode() {
292+
return Objects.hash(columns, partitionColumns, nameMap, partitionNameMap);
293+
}
294+
274295
public static class Builder {
275296

276297
private final TableSchema schema;

odps-sdk/odps-sdk-commons/src/main/java/com/aliyun/odps/data/AbstractChar.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package com.aliyun.odps.data;
22

3-
public abstract class AbstractChar<T extends AbstractChar> {
3+
import java.io.Serializable;
4+
5+
public abstract class AbstractChar<T extends AbstractChar> implements Serializable {
46
protected String value;
57

68
AbstractChar(String value) {

odps-sdk/odps-sdk-commons/src/main/java/com/aliyun/odps/data/ArrayRecord.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import static com.aliyun.odps.data.OdpsTypeTransformer.getCompatibleType;
2323
import static com.aliyun.odps.data.OdpsTypeTransformer.transformAndValidate;
2424

25+
import java.io.Serializable;
2526
import java.io.UnsupportedEncodingException;
2627
import java.math.BigDecimal;
2728
import java.sql.Timestamp;
@@ -47,7 +48,8 @@
4748
*
4849
* @see Record
4950
*/
50-
public class ArrayRecord implements Record {
51+
public class ArrayRecord implements Record, Serializable {
52+
private static final long serialVersionUID = 1L;
5153
private static final Long DEFAULT_FIELD_MAX_SIZE = 8 * 1024 * 1024L;
5254
private static final String DEFAULT_CHARSET = "utf-8";
5355

@@ -58,7 +60,7 @@ public class ArrayRecord implements Record {
5860
.build();
5961

6062
private Column[] columns;
61-
private final Object[] values;
63+
private final Serializable[] values;
6264
private HashMap<String, Integer> nameMap = new HashMap<>();
6365

6466
/**
@@ -90,7 +92,7 @@ public ArrayRecord(Column[] columns, boolean strictTypeValidation, Long fieldMax
9092
this.fieldMaxSize = fieldMaxSize;
9193
}
9294

93-
values = new Object[columns.length];
95+
values = new Serializable[columns.length];
9496

9597
for (int i = 0; i < columns.length; i++) {
9698
nameMap.put(columns[i].getName(), i);
@@ -1139,7 +1141,7 @@ protected <T> T getInternal(int idx) {
11391141
* set record column value directly without type validation
11401142
* unsafe: caller must ensure correct type and do validation check externally when necessary
11411143
*/
1142-
public void setWithoutValidation(int idx, Object o){
1144+
public void setWithoutValidation(int idx, Serializable o){
11431145
this.values[idx] = o;
11441146
}
11451147

odps-sdk/odps-sdk-commons/src/main/java/com/aliyun/odps/data/Binary.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.aliyun.odps.data;
22

3+
import java.io.Serializable;
34
import java.util.Arrays;
45

56
import com.aliyun.odps.utils.StringUtils;
@@ -9,7 +10,7 @@
910
*
1011
* Created by zhenhong.gzh on 16/12/12.
1112
*/
12-
public class Binary implements Comparable<Binary> {
13+
public class Binary implements Comparable<Binary>, Serializable {
1314
protected byte[] data;
1415

1516
public Binary(byte[] data) {

odps-sdk/odps-sdk-commons/src/main/java/com/aliyun/odps/data/IntervalDayTime.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.aliyun.odps.data;
22

3+
import java.io.Serializable;
34
import java.util.concurrent.TimeUnit;
45

56

@@ -8,7 +9,7 @@
89
*
910
* Created by zhenhong.gzh on 16/12/12.
1011
*/
11-
public class IntervalDayTime implements Comparable<IntervalDayTime> {
12+
public class IntervalDayTime implements Comparable<IntervalDayTime>, Serializable {
1213
private final static int NANOS_PER_SECOND = 1000000000;
1314

1415
protected long totalSeconds;

odps-sdk/odps-sdk-commons/src/main/java/com/aliyun/odps/data/IntervalYearMonth.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
package com.aliyun.odps.data;
22

3+
import java.io.Serializable;
4+
35
/**
46
* Interval Year Month 类型对应的数据类
57
*
68
* Created by zhenhong.gzh on 16/12/12.
79
*/
810

9-
public class IntervalYearMonth implements Comparable<IntervalYearMonth> {
11+
public class IntervalYearMonth implements Comparable<IntervalYearMonth>, Serializable {
1012
private final static int MONTHS_PER_YEAR = 12;
1113
private final static int MAX_YEARS = 9999;
1214

odps-sdk/odps-sdk-commons/src/main/java/com/aliyun/odps/data/OdpsTypeTransformer.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,14 @@ private static void validateString(String value, long limit) {
103103
}
104104
}
105105

106+
private static void validateJson(Object value) {
107+
// maybe we should validate string type here
108+
if (value instanceof JsonValue) {
109+
// trigger lazy load
110+
((JsonValue) value).isJsonObject();
111+
}
112+
}
113+
106114
private static void validateChar(Char value, CharTypeInfo typeInfo) {
107115
if (value.length() > typeInfo.getLength()) {
108116
throw new IllegalArgumentException(String.format(
@@ -235,6 +243,7 @@ static <T> T transform(Object value,
235243
if (setData) {
236244
if (strict) {
237245
validateString(transformedResult.toString(), fieldMaxSize);
246+
validateJson(transformedResult);
238247
}
239248
return (T) transformedResult;
240249
}

0 commit comments

Comments
 (0)