kou commented on code in PR #1152: URL: https://github.com/apache/arrow-adbc/pull/1152#discussion_r1363213864
########## glib/example/README.md: ########## @@ -0,0 +1,32 @@ +<!--- + 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. +--> + +# GADBC GLib example Review Comment: ```suggestion # ADBC GLib example ``` ########## glib/example/sqlite.c: ########## @@ -0,0 +1,159 @@ +/* + * 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 <stdlib.h> + +#include <adbc-glib/adbc-glib.h> +#include <arrow-glib/arrow-glib.h> + +int main(int argc, char** argv) { + GADBCDatabase* database; + GADBCConnection* conn; + GError* error = NULL; + + database = gadbc_database_new(&error); + + if (error != NULL) { Review Comment: Could you use `(error)` instead of `(error != NULL)`? We use this style in our existing code. ```suggestion if (error) { ``` ########## glib/example/sqlite.c: ########## @@ -0,0 +1,159 @@ +/* + * 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 <stdlib.h> + +#include <adbc-glib/adbc-glib.h> +#include <arrow-glib/arrow-glib.h> + +int main(int argc, char** argv) { + GADBCDatabase* database; + GADBCConnection* conn; + GError* error = NULL; + + database = gadbc_database_new(&error); + Review Comment: Could you remove an empty line between `gadbc_*()` call and `if (error != NULL)`? They are related codes. So I don't want to split them by an empty line. ########## glib/example/sqlite.c: ########## @@ -0,0 +1,159 @@ +/* + * 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 <stdlib.h> + +#include <adbc-glib/adbc-glib.h> +#include <arrow-glib/arrow-glib.h> + +int main(int argc, char** argv) { + GADBCDatabase* database; + GADBCConnection* conn; + GError* error = NULL; + + database = gadbc_database_new(&error); + + if (error != NULL) { + g_print("Error creating a Database: %s", error->message); + g_object_unref(database); Review Comment: ```suggestion g_error_free(error); g_object_unref(database); ``` ########## glib/example/sqlite.c: ########## @@ -0,0 +1,159 @@ +/* + * 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 <stdlib.h> + +#include <adbc-glib/adbc-glib.h> +#include <arrow-glib/arrow-glib.h> + +int main(int argc, char** argv) { + GADBCDatabase* database; + GADBCConnection* conn; + GError* error = NULL; + + database = gadbc_database_new(&error); + + if (error != NULL) { + g_print("Error creating a Database: %s", error->message); + g_object_unref(database); + return EXIT_FAILURE; + } + + gadbc_database_set_option(database, "driver", "adbc_driver_sqlite", &error); + + if (error != NULL) { Review Comment: Could you check a return value instead? ```suggestion if (!gadbc_database_set_option(database, "driver", "adbc_driver_sqlite", &error)) { ``` ########## glib/example/vala/README.md: ########## @@ -0,0 +1,36 @@ +<!--- + 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. +--> + +# ADBC GLib Vala example + +There are Vala example codes in this directory. + +## How to build + +Here is a command line to build an example in this directory: + +```console +$ valac --pkg adbc-glib --pkg posix XXX.vala Review Comment: Do we need `arrow-glib` too? ```suggestion $ valac --pkg adbc-glib --pkg arrow-glib --pkg posix XXX.vala ``` ########## glib/example/sqlite.c: ########## @@ -0,0 +1,159 @@ +/* + * 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 <stdlib.h> + +#include <adbc-glib/adbc-glib.h> +#include <arrow-glib/arrow-glib.h> + +int main(int argc, char** argv) { + GADBCDatabase* database; + GADBCConnection* conn; + GError* error = NULL; + + database = gadbc_database_new(&error); + + if (error != NULL) { Review Comment: For this case, could you check `database` instead of `error`? We want users to check `database`. ```suggestion if (!database) { ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
