Github user huor commented on a diff in the pull request:

    https://github.com/apache/incubator-hawq/pull/1384#discussion_r208433762
  
    --- Diff: contrib/exthdfs/exthdfs.c ---
    @@ -0,0 +1,472 @@
    +/*
    + * 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 "common.h"
    +#include "access/extprotocol.h"
    +#include "cdb/cdbdatalocality.h"
    +#include "storage/fd.h"
    +#include "storage/filesystem.h"
    +#include "utils/uri.h"
    +
    +
    +
    +
    +PG_MODULE_MAGIC;
    +
    +PG_FUNCTION_INFO_V1(hdfsprotocol_blocklocation);
    +PG_FUNCTION_INFO_V1(hdfsprotocol_validate);
    +
    +Datum hdfsprotocol_blocklocation(PG_FUNCTION_ARGS);
    +Datum hdfsprotocol_validate(PG_FUNCTION_ARGS);
    +
    +Datum hdfsprotocol_blocklocation(PG_FUNCTION_ARGS)
    +{
    +
    +   // Build the result instance
    +   int nsize = 0;
    +   int numOfBlock = 0;
    +   ExtProtocolBlockLocationData *bldata =
    +           palloc0(sizeof(ExtProtocolBlockLocationData));
    +   if (bldata == NULL)
    +   {
    +           elog(ERROR, "hdfsprotocol_blocklocation : "
    +                    "cannot allocate due to no memory");
    +   }
    +   bldata->type = T_ExtProtocolBlockLocationData;
    +   fcinfo->resultinfo = bldata;
    +
    +   ExtProtocolValidatorData *pvalidator_data = (ExtProtocolValidatorData *)
    +                                                                           
                (fcinfo->context);
    +
    +
    +    // Parse URI of the first location, we expect all locations uses the 
same
    +    // name node server. This is checked in validation function.
    +
    +   char *first_uri_str =
    +           (char *)strVal(lfirst(list_head(pvalidator_data->url_list)));
    +   Uri *uri = ParseExternalTableUri(first_uri_str);
    +
    +   elog(DEBUG3, "hdfsprotocol_blocklocation : "
    +                            "extracted HDFS name node address %s:%d",
    --- End diff --
    
    Indent should follow the convention as previous code


---

Reply via email to