日本熟妇hd丰满老熟妇,中文字幕一区二区三区在线不卡 ,亚洲成片在线观看,免费女同在线一区二区

數(shù)據(jù)推送 Demo

主要是在程序中動態(tài)將對應(yīng)的文檔數(shù)據(jù)封裝到Map對象中,再將這些Map對象通過add方法添加到緩存中,最后調(diào)用pushDocuments方法,批量提交這些Map對象文檔數(shù)據(jù)。

代碼示例

package main

import (
    "fmt"
    util "github.com/alibabacloud-go/tea-utils/service"
    "github.com/alibabacloud-go/tea/tea"
    ha3engine "github.com/aliyun/alibabacloud-ha3-go-sdk/client"
)

func main() {
    
    //創(chuàng)建請求用客戶端實例
    //Endpoint 為 要訪問服務(wù)的區(qū)域?qū)嵗蛎?
    //AccessUserName AccessPassWord 用于構(gòu)造鑒權(quán)信息.
    
    config := &ha3engine.Config{
        Endpoint:       tea.String("<Endpoint>"),
        InstanceId:     tea.String("<InstanceId>"),
        AccessUserName: tea.String("<AccessUserName>"),
        AccessPassWord: tea.String("<AccessPassWord>"),
    }
    
    // New  一個client, 用以發(fā)送請求.
    client, _clientErr := ha3engine.NewClient(config)
    
    // 如果 NewClient 過程中出現(xiàn)異常. 則 返回 _clientErr 且輸出 錯誤信息.
    if _clientErr != nil {
        fmt.Println(_clientErr)
        return
    }
    runtime := &util.RuntimeOptions{
        ConnectTimeout: tea.Int(5000),
        ReadTimeout:    tea.Int(10000),
        Autoretry:      tea.Bool(false),
        IgnoreSSL:      tea.Bool(false),
        MaxIdleConns:   tea.Int(50),
        HttpProxy:      tea.String("http://116.*.*.187:8088"),
    }
    docPush(client)
    docPushWithOptions(client, runtime)
}

func docPush(client *ha3engine.Client) {
    pushDocumentsRequestModel := &ha3engine.PushDocumentsRequestModel{}
    // # dataSourceName文檔推送的數(shù)據(jù)源配置名稱,可在實例管理>配置中心>數(shù)據(jù)源配置 查看.
    dataSourceName := "<數(shù)據(jù)源名稱>"
    keyField := "id"
    
    a := [1000]int{}
    b := [10]int{}
    for x := range a {
        array := []map[string]interface{}{
        }
        for j := range b {
            filed := map[string]interface{}{
                "fields": map[string]interface{}{
                    "id":          tea.ToString(x*100) + tea.ToString(j),
                    "fb_boolean":  tea.BoolValue(nil),
                    "fb_datetime": "2167747200000",
                    "fb_string":   "409a6b18-a10b-409e-af91-07121c45d899",
                },
                "cmd": tea.String("add"),
            }
            array = append(array, filed)
        }
        
        pushDocumentsRequestModel.SetBody(array)
        
        // 發(fā)送請求的方法調(diào)用.
        response1, _requestErr1 := client.PushDocuments(tea.String(dataSourceName), tea.String(keyField), pushDocumentsRequestModel)
        
        // 如果 發(fā)送請求 過程中出現(xiàn)異常. 則 返回 _requestErr 且輸出 錯誤信息.
        if _requestErr1 != nil {
            fmt.Println(_requestErr1)
            return
        }
        
        // 輸出正常返回的 response 內(nèi)容.
        fmt.Println(response1)
        
    }
    
}

func docPushWithOptions(client *ha3engine.Client, runtime *util.RuntimeOptions) {
    
    pushDocumentsRequestModel := &ha3engine.PushDocumentsRequestModel{}
    dataSourceName := "{InstanceId}_odps"
    keyField := "id"
    
    a := [1000]int{}
    b := [10]int{}
    for x := range a {
        array := []map[string]interface{}{
        }
        for j := range b {
            filed := map[string]interface{}{
                "fields": map[string]interface{}{
                    "id":          tea.ToString(x*100) + tea.ToString(j),
                    "fb_boolean":  tea.BoolValue(nil),
                    "fb_datetime": "2167747200000",
                    "fb_string":   "409a6b18-a10b-409e-af91-07121c45d899",
                },
                "cmd": tea.String("add"),
            }
            array = append(array, filed)
        }
        
        pushDocumentsRequestModel.SetBody(array)
        
        // 發(fā)送請求的方法調(diào)用.
        response1, _requestErr1 := client.PushDocumentsWithOptions(tea.String(dataSourceName), tea.String(keyField), pushDocumentsRequestModel, runtime)
        
        // 如果 發(fā)送請求 過程中出現(xiàn)異常. 則 返回 _requestErr 且輸出 錯誤信息.
        if _requestErr1 != nil {
            fmt.Println(_requestErr1)
            return
        }
        
        // 輸出正常返回的 response 內(nèi)容.
        fmt.Println(response1)
        
    }
}