SegmentDataDefine.java 2.7 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
/*
 * Copyright 2017, OpenSkywalking Organization All rights reserved.
 *
 * Licensed 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.
 *
 * Project repository: https://github.com/OpenSkywalking/skywalking
 */

P
pengys5 已提交
19
package org.skywalking.apm.collector.storage.define.segment;
P
pengys5 已提交
20

P
pengys5 已提交
21 22 23 24
import org.skywalking.apm.collector.core.stream.Data;
import org.skywalking.apm.collector.core.stream.Transform;
import org.skywalking.apm.collector.core.stream.operate.CoverOperation;
import org.skywalking.apm.collector.core.stream.operate.NonOperation;
25 26 27 28
import org.skywalking.apm.collector.remote.grpc.proto.RemoteData;
import org.skywalking.apm.collector.storage.define.Attribute;
import org.skywalking.apm.collector.storage.define.AttributeType;
import org.skywalking.apm.collector.storage.define.DataDefine;
P
pengys5 已提交
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44

/**
 * @author pengys5
 */
public class SegmentDataDefine extends DataDefine {

    @Override protected int initialCapacity() {
        return 2;
    }

    @Override protected void attributeDefine() {
        addAttribute(0, new Attribute(SegmentTable.COLUMN_ID, AttributeType.STRING, new NonOperation()));
        addAttribute(1, new Attribute(SegmentTable.COLUMN_DATA_BINARY, AttributeType.BYTE, new CoverOperation()));
    }

    @Override public Object deserialize(RemoteData remoteData) {
45
        return null;
P
pengys5 已提交
46 47 48
    }

    @Override public RemoteData serialize(Object object) {
49
        return null;
P
pengys5 已提交
50 51
    }

52
    public static class Segment implements Transform {
P
pengys5 已提交
53 54 55 56 57 58
        private String id;
        private byte[] dataBinary;

        public Segment() {
        }

59
        @Override public Data toData() {
P
pengys5 已提交
60 61 62 63 64 65 66
            SegmentDataDefine define = new SegmentDataDefine();
            Data data = define.build(id);
            data.setDataString(0, this.id);
            data.setDataBytes(0, this.dataBinary);
            return data;
        }

67 68 69 70
        @Override public Object toSelf(Data data) {
            return null;
        }

P
pengys5 已提交
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
        public String getId() {
            return id;
        }

        public void setId(String id) {
            this.id = id;
        }

        public byte[] getDataBinary() {
            return dataBinary;
        }

        public void setDataBinary(byte[] dataBinary) {
            this.dataBinary = dataBinary;
        }
    }
}