hawq-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wengyanqing <...@git.apache.org>
Subject [GitHub] incubator-hawq pull request #1347: HAWQ-1591 Common tuple batch structure fo...
Date Fri, 16 Mar 2018 13:13:16 GMT
Github user wengyanqing commented on a diff in the pull request:

    https://github.com/apache/incubator-hawq/pull/1347#discussion_r175084597
  
    --- Diff: contrib/vexecutor/tuplebatch.c ---
    @@ -0,0 +1,188 @@
    +/*
    + * 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.
    + */
    +#include "postgres.h"
    +#include "tuplebatch.h"
    +
    +static size_t vtypeSize(vheader *vh);
    +static size_t tbSerializationSize(TupleBatch tb);
    +
    +#define TBGETVALUEPTR(tb,type,colid,rowid) (&(((type *)tb->datagroup[colid])->data[rowid]))
    +#define TBGETISNULLPTR(tb,colid,rowid) (&((tb->datagroup[colid])->isnull[rowid]))
    +
    +TupleBatch tbGenerate(int colnum,int batchsize)
    +{
    +    Assert(colnum > 0 && batchsize > 0);
    +    TupleBatch tb = palloc0(sizeof(TupleBatchData));
    +    if(!tb)
    +    {
    +        elog(FATAL,"TupleBatch Allocation failed");
    +        return NULL;
    +    }
    +
    +    tb->ncols = colnum;
    +    tb->batchsize = batchsize;
    +
    +    tb->skip = palloc0(sizeof(bool) * tb->batchsize);
    +    tb->datagroup = palloc0(sizeof(struct vtypeheader*) * tb->ncols);
    +
    --- End diff --
    
    It's better to init all the struct variable members (nrow, iter) in tbGenerate or call
tbReset before return.


---

Mime
View raw message