All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.aliyun.tair.tairts.factory.TsBuilderFactory Maven / Gradle / Ivy

package com.aliyun.tair.tairts.factory;

import com.aliyun.tair.tairts.results.*;
import redis.clients.jedis.Builder;

import java.util.ArrayList;
import java.util.List;

public class TsBuilderFactory {

    public static final Builder EXTSGET_RESULT_STRING = new Builder() {
        @Override
        public ExtsDataPointResult build(Object data) {
            if (data == null) {
                return null;
            }
            List l = (List) data;
            return new ExtsDataPointResult(((Number) l.get(0)).longValue(),new String((byte[]) l.get(1)));
        }

        @Override
        public String toString() {
            return "ExTsGetResult";
        }
    };

    public static final Builder EXTSRANGE_RESULT_STRING = new Builder() {
        @Override
        public ExtsSkeyResult build(Object data) {
            if (data == null) {
                return null;
            }
            List l = (List) data;
            List dataPointsList = (List) l.get(0);
            return new ExtsSkeyResult(null, new ArrayList(), dataPointsList, ((long) l.get(1)));
        }

        @Override
        public String toString() {
            return "ExTsRangeResult";
        }
    };

    public static final Builder> EXTSMRANGE_RESULT_STRING = new Builder>() {
        @Override
        public List build(Object data) {
            if (data == null) {
                return null;
            }
            List l = (List) data;
            final ArrayList results = new ArrayList();
            int num = l.size();
            for (int i = 0; i < num; i++) {
                if (l.get(i) == null) {
                    return results;
                }
                List subl = (List) l.get(i);
                List labelsList = (List) subl.get(1);
                List dataPointsList = (List) subl.get(2);
                results.add(new ExtsSkeyResult(new String((byte[]) subl.get(0)), labelsList, dataPointsList, ((long) subl.get(3))));
            }
            return results;
        }

        @Override
        public String toString() {
            return "ExTsMrangeResult";
        }
    };

    public static final Builder EXTSSTRING_GET_RESULT_STRING = new Builder() {
        @Override
        public ExtsStringDataPointResult build(Object data) {
            if (data == null) {
                return null;
            }
            List l = (List) data;
            return new ExtsStringDataPointResult(((Number) l.get(0)).longValue(),new String((byte[]) l.get(1)));
        }

        @Override
        public String toString() {
            return "ExTsStringGetResult";
        }
    };

    public static final Builder EXTSSTRING_RANGE_RESULT_STRING = new Builder() {
        @Override
        public ExtsStringSkeyResult build(Object data) {
            if (data == null) {
                return null;
            }
            List l = (List) data;

            List dataPointsList = (List) l.get(0);
            return new ExtsStringSkeyResult(null, new ArrayList(), dataPointsList, ((long) l.get(1)));
        }

        @Override
        public String toString() {
            return "ExTsStringRangeResult";
        }
    };

    public static final Builder> EXTSSTRING_MRANGE_RESULT_STRING = new Builder>() {
        @Override
        public List build(Object data) {
            if (data == null) {
                return null;
            }
            List l = (List) data;
            final ArrayList results = new ArrayList();
            int num = l.size();
            for (int i = 0; i < num; i++) {
                List subl = (List) l.get(i);
                List labelsList = (List) subl.get(1);
                List dataPointsList = (List) subl.get(2);
                results.add(new ExtsStringSkeyResult(new String((byte[]) subl.get(0)), labelsList, dataPointsList, ((long) subl.get(3))));
            }
            return results;
        }

        @Override
        public String toString() {
            return "ExTsStringMrangeResult";
        }
    };
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy