DataRecord.java 2.2 KB
Newer Older
K
KomachiSion 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

18
package org.apache.shardingsphere.scaling.core.execute.executor.record;
A
avalon566 已提交
19

20
import org.apache.shardingsphere.scaling.core.job.position.Position;
21 22

import lombok.EqualsAndHashCode;
23 24
import lombok.Getter;
import lombok.Setter;
A
avalon566 已提交
25 26

import java.util.ArrayList;
27
import java.util.LinkedList;
A
avalon566 已提交
28 29 30
import java.util.List;

/**
A
avalon566 已提交
31
 * Data record.
A
avalon566 已提交
32
 */
33 34
@Setter
@Getter
35
@EqualsAndHashCode(of = {"tableName", "primaryKeyValue"}, callSuper = false)
36
public final class DataRecord extends Record {
37 38 39 40 41
    
    private final List<Column> columns;
    
    private final List<Object> primaryKeyValue = new LinkedList<>();
    
A
avalon566 已提交
42
    private String type;
43
    
A
avalon566 已提交
44
    private String tableName;
45
    
46 47
    public DataRecord(final Position position, final int columnCount) {
        super(position);
A
avalon566 已提交
48
        columns = new ArrayList<>(columnCount);
A
avalon566 已提交
49
    }
50
    
A
avalon566 已提交
51 52
    /**
     * Add a column to record.
K
KomachiSion 已提交
53
     *
A
avalon566 已提交
54 55 56
     * @param data column
     */
    public void addColumn(final Column data) {
A
avalon566 已提交
57
        columns.add(data);
58 59 60
        if (data.isPrimaryKey()) {
            primaryKeyValue.add(data.getValue());
        }
A
avalon566 已提交
61
    }
62
    
A
avalon566 已提交
63 64
    /**
     * Return column count.
K
KomachiSion 已提交
65
     *
A
avalon566 已提交
66 67
     * @return count
     */
A
avalon566 已提交
68 69 70
    public int getColumnCount() {
        return columns.size();
    }
71
    
A
avalon566 已提交
72 73
    /**
     * Get column by index.
K
KomachiSion 已提交
74
     *
A
avalon566 已提交
75 76 77 78
     * @param index of column
     * @return column
     */
    public Column getColumn(final int index) {
A
avalon566 已提交
79 80
        return columns.get(index);
    }
A
avalon566 已提交
81
}