Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Partial draft of Programming in Go for initial review #141

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

ksbhaskar
Copy link
Member

Utility function wrapper descriptions yet to be added. This is a request for an initial review, not a review before merging.

<https://golang.org/cmd/cgo/>`_ to provide the Go programmer with a
YottaDB package. YottaDB C functions are wrapped by Go methods where a
method can meaningfully be associated with a Go structure, and Go
functions otherwise.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

".... and otherwise associated with a Go function"?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to “and by Go functions otherwise” to tie the phrase to “wrapped”.

method can meaningfully be associated with a Go structure, and Go
functions otherwise.

As the Go language has important differences from C (for example it
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comma after "for example"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

lacks macros, but has methods), below are Go-specific sections of the
`Quick Start`_, `Concepts`_, `Symbolic Constants`_, `Data Structures &
Type Definitions`_ and `Simple API`_ sections above. The sections
below specific to Go are intended to supplement their general (C)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"The sections specific to Go below" or "The sections below that are specific to Go"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

3. Put your GO program in the :code:`$ydb_dir` directory, XYZ
(instructions to include headers). As a sample program,
you can download the `wordfreq.go
<https://raw.githubusercontent.com/YottaDB/YottaDBtest/master/simpleapi/inref/wordfreq.c>`_
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This link points to the C code.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True. The Go code doesn't exist yet because the Go wrapper doesn't exist yet. We're drafting the user documentation to specify the API.

- Empty string subscripts precede all numeric subscripts. By
default, YottaDB prohibits empty string subscripts for global
variables but permits them for local variables (see `Local and
Global Variables`_). *Note: YottaDB recommends against
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps should recommend against the practice of using null vars in applications instead of recommending against applications?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Programming YottaDB in the `Go language <https://golang.org/>`_ is
accomplished through a wrapper that uses `cgo
<https://golang.org/cmd/cgo/>`_ to provide the Go programmer with a
YottaDB package. YottaDB C functions are wrapped by Go methods where a
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is the name of the actual package, the package name should be all lowercase. Otherwise it should be clear that it is a package 'to support the use of YottaDB'.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rephrased as: to provide a “yottadb” package for access to YottaDB from Go application code.

below specific to Go are intended to supplement their general (C)
counterparts, rather than stand-alone sections.

Application programs should not directly use the YottaDB C API
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This cannot be overstated enough. Direct calls to the YottaDB C routines (both SimpleAPI and especially the utility routines), are NOT supported as they bypass some very important controls.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rephrased as: Application programs must not directly use the YottaDB C API structures and functions (those prefixed by :code:C.) as such usage bypasses important controls, but should instead use the structures, methods and functions exposed by the YottaDB Go wrapper

(Installing YottaDB), install the Go wrapper:

Download the Go wrapper from XYZ [provide URL when released]. Unpack
the contents in its own directory (e.g, $HOME/go/src/yottadb, and
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing close paren before comma

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added

Go Concepts
===========

XYZ - Add anything special that a Go programmer should know before
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Likely need to add something here about changing yottadb.go since it has direct references to where YDB is installed. These cannot currently be environment variables so stuck with fixing up the cgo comment lines that define the macro include and link parameters (-I, -l -L). The cgo information says use of a tool called "pkg-config" (available in ubuntu repository) can get around the hard-coded filerefs where things are not present in the build directory. I have not used pkg-config so have no idea how to use it but it would keep us from having to suggest source modifications before building.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, will add when you provide suitable draft text.


.. code-block:: go

DeleteS(deltype int) int
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In order to allow use of the C.YDB_DEL_NODE/DEL_TREE constants to be used in this method, the type of 'deltype' should probably be C.int.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this change was undone which is good since we discovered C #define values can be treated as ints instead of requiring them to be C.int.


IncrS(incr, retval *BufferT) int

The :code:`IncrS()` method wraps `ydb_incr_s()`_ to atomically
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If incr is either unallocated or is nil, it takes on the default value of 1.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added: If :code:incr is unallocated or the :code:len_usedfield is zero, the default increment is 1.


.. code-block:: go

LockS( timeoutNsec uint64, ... *KeyT) int
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Space before timeoutNsec. Also should be parm name prior to '...' like "locklist" or some such.

Might want to note maximum here of ((#locks * 3) + 1) must be <= 36.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. Also noted that the number of locks ≤11 (easier to parse than the formula).

====================

The Go Comprehensive API is a project for the future, to follow the C
`Comprehensive API`_
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"follow the C Comprehensive API" -> "follow the C SimpleAPI" ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A Go Comprehensive API would have to follow a C Comprehensive API.

-----------------------

GetSubBufAlloc(n)
GetSubBufUsed(n)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not understanding why these are "Utility Methods" instead of structure methods.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You read past where I had material to review. This is an area where I made notes to myself. The next round of reviews will have something here worth reviewing.

Copy link
Member Author

@ksbhaskar ksbhaskar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Responses to collected comments by Steve Estes.

- Empty string subscripts precede all numeric subscripts. By
default, YottaDB prohibits empty string subscripts for global
variables but permits them for local variables (see `Local and
Global Variables`_). *Note: YottaDB recommends against
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Programming YottaDB in the `Go language <https://golang.org/>`_ is
accomplished through a wrapper that uses `cgo
<https://golang.org/cmd/cgo/>`_ to provide the Go programmer with a
YottaDB package. YottaDB C functions are wrapped by Go methods where a
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rephrased as: to provide a “yottadb” package for access to YottaDB from Go application code.

below specific to Go are intended to supplement their general (C)
counterparts, rather than stand-alone sections.

Application programs should not directly use the YottaDB C API
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rephrased as: Application programs must not directly use the YottaDB C API structures and functions (those prefixed by :code:C.) as such usage bypasses important controls, but should instead use the structures, methods and functions exposed by the YottaDB Go wrapper

(Installing YottaDB), install the Go wrapper:

Download the Go wrapper from XYZ [provide URL when released]. Unpack
the contents in its own directory (e.g, $HOME/go/src/yottadb, and
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added

Go Concepts
===========

XYZ - Add anything special that a Go programmer should know before
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, will add when you provide suitable draft text.


.. code-block:: go

DeleteS(deltype int) int
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


IncrS(incr, retval *BufferT) int

The :code:`IncrS()` method wraps `ydb_incr_s()`_ to atomically
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added: If :code:incr is unallocated or the :code:len_usedfield is zero, the default increment is 1.


.. code-block:: go

LockS( timeoutNsec uint64, ... *KeyT) int
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. Also noted that the number of locks ≤11 (easier to parse than the formula).

====================

The Go Comprehensive API is a project for the future, to follow the C
`Comprehensive API`_
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A Go Comprehensive API would have to follow a C Comprehensive API.

-----------------------

GetSubBufAlloc(n)
GetSubBufUsed(n)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You read past where I had material to review. This is an area where I made notes to myself. The next round of reviews will have something here worth reviewing.

Methods for each structure are classified as either `Go Access
Methods`_ or `Go Simple API`_ methods. `Go Access Methods`_ are
methods implemented in the Go wrapper for managing the structures for
data interchange or `Go Access Methods`_ that wrap functionality
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this second mention of "Go Access Methods" supposed to be "Go SimpleAPI Methods" ? Also looks like "methods" when speaking of "Go Simple API methods" is not part of the hilighted/quoted string like Methods is with "Go Access Methods" which looks odd.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the second one should be Go Simple API methods. Also, “methods” is not part of the hyperlink because the section header is “Go Simple API” which has methods and functions. Yes, it's a trifle inconsistent/awkward…

referencing the buffer.

Set :code:`cbuft` in the :code:`BufferT`
structure to reference the :code:`C.ydb_buffer_t` structure.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reference -> anchor?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reference seems to be right, because cbuft is in Go memory but stores a pointer to a ydb_buffer_t structure in the YottaDB heap. So going from cbuft to the ydb_buffer_t would involve dereferencing a pointer.


Set:

- In each :code:`C.ydb_buffer_t` structure:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this reference be to a BufferT structure since the next one references the BufferTArray struct?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

len_alloc and len_used are fields in a C.ydb_buffer_t structure, whereas cbuftary, elemsAlloc, and elemsUsed are fields in a BufferTArray structure. So the existing language seems correct to me.

:code:`C.YDB_ERR_INVZWRITECHAR`.
- Otherwise, set the buffer referenced by :code:`buf_addr` to the
unencoded string, set :code:`len_used` to the length, and return
with a return code of :code:`C.YDB_OK`.

Note that the length of a string in `zwrite format`_ is always less
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this backwards? The original string is less than or equal to the zwrite format. The zwrite format can be much larger than the unencoded format.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it is. Fixed.

routine, in turn be passed to the Go function called by the glue
routine. As :code:`tpfnparm` is passed from Go to YottaDB and back to
Go, the memory it references should be allocated using
`yottadb.malloc()`_ to protect it from the Go garbage collector.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"malloc" needs to be capitalized.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have since changed the reference to the section header, which is "Go Malloc()".


If there is an error, :code:`SubNextS()` has an `error return code`_
prefixed with :code:`C.`.
:code:`SubPrevtS()` wraps `ydb_subscript_previous_s()`_ to facilitate
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SubPrevtS -> SubPrevS

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed


The function wraps `ydb_lock_s()`. It releases all `Locks`_ held by
The function wraps `ydb_lock_s()`_. It releases all `Locks`_ held by
the process, and acquires the locks whose resource names are specified
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps this should spawn a Programming Consideration note - the effect of LockS() releasing existing locks is process wide, not thread wide or goroutine wide but process wide.

-----------------------
Go KeyT Utility Methods
-----------------------
------------
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought we were getting rid of all the YDB prefixes on these routines? This was because the routine name is actually for example yottadb.YDBExit().

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We did. You were commenting on a line that was there in the previous version and removed in the commit!

Refer to the description of `ydb_stdout_stderr_adjust()`_, which this
function wraps. The return code is :code:`C.YDB_OK`.

Applications that do not mix M and non-M code do not need this
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this true? I thought it was if stdout and stderr were being used by various components that one might want to use this routine. Use of this routine from Golang is currently an unknown. We don't know how Golang sets up its IO stuff. Would be interesting to see if using this in Golang then forking off a process caused any issues.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At least in the C world, it is true that applications which do not mix M and non-M code do not need this function. Only if simpleAPI code does a call-in is this function needed in C. As for GoLang, I expect it to be similar. If at all, this is needed, it would be when call-ins are done from GoLang. Are we planning on supporting that?


The function wraps `ydb_timer_start()`_ to start a timer. Unless
canceled, after the timer expires, YottaDB invokes the handler
function referenced by
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incomplete sentence.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's because you were reviewing functions before I finished drafting the functions content. I had said to stop after Methods!

it wraps. The YottaDB `Go ForkExec()`_ ensures that the child process
is safely disconnected from YottaDB interprocess communication
resources and database files.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not at all sure that allowing users to specify ProcAttr is a good idea as our version of ForkExec() has a need to set it for YottaDB purposes too which may conflict with the the user. We would end up re-copying the array to add our element to it at best. Also don't like the ability it gives the user by bypass closing all the db files.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it will be acceptable to users to disable it, because ProcAttr includes SysProcAttr some of which are likely to be important to users. Besides, programs can always explicitly set environment variables using sys.Setenv(). So, I think we should just reserve environment variables with a “ydb_” prefix for our use, and document it (if it is not already).

That said, I wonder whether we should wrap syscall.StartProcess(), even though it just wraps syscall.ForkExec() since syscall.StartProcess() may be the os independent way of starting processes.

its logic in a single goroutine.

In order to avoid restricting Go applications from calling the YottaDB
API from a single gorutine (which would be unnatural to a Go
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gorutine -> goroutine

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

API from a single gorutine (which would be unnatural to a Go
programmer), the YottaDB Go wrapper includes logic that coerces the
execution of the YottaDB runtime system to a single goroutine. Calling
YottaDB C API functions bypasses this protection, and may result in
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"directly" bypasses?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK


Free()

The inverse of the :code:`Alloc()` method: release the bufer in
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bufer -> buffer

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

return value (zero if the structure has not yet been allocated, i.e.,
:code:`cbuft` is :code:`nil`).

If the :code:`len_used` field field of the :code:`C.ydb_buffer_t`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

field field -> field

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

:code:`cbuft` is :code:`nil`).

If the :code:`len_used` field field of the :code:`C.ydb_buffer_t`
structure is greater than the :code:`len_alloc` field (owing to a
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

owing to a -> for example, owing to a

Otherwise, the sentence makes it sound like even though len_used is greater than len_alloc, as long as a C.YDB_ERR_INVSTRLEN error was not issued, the return value from GetLenUsed() will not be C.YDB_ERR_INVSTRLEN.

I notice the "owing to a" usage is in various places so they might also need the above change. That said, I am fine if you decide not to incorporate this comment.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed, these are left as is.


.. code-block:: go

GetValBAry() *[]byte, int
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the *[]byte syntax imply a Go slice (as opposed to an array)? If so, the Ary suffix in the function name might not be accurate. If not, I need to get up to speed on Go so never mind.

Also BAry stands for a Byte Array right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, BAry is Byte Array. @estess, please respond to the slice vs. array question. If it is a slice, the method name should be *BSlice presumably.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the address of a byte array. The wrapper will create the byte array from the C buffer and return the byte array's address.

If the :code:`len_used` field of the :code:`C.ydb_buffer_t` structure
referenced by :code:`cbuft` is greater than its :code:`len_alloc`
field (owing to a prior :code:`C.YDB_ERR_INVSTRLEN` error), return
:code:`len_alloc` bytes of the buffer referenced by the
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Too many "referenced by" usages in this and the next line. Can we avoid one.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We discussed this, and describing a chain of pointers in English is what leads to the multiple usages. Improved language doesn't suggest itself to me at present.


The inverse of the :code:`Alloc()` method: release the :code:`numSubs`
buffers and the :code:`C.ydb_buffer_t` array. Set :code:`cbuftary` to
:code:`nil`.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will elemsAlloc and elemsUsed also be set to 0?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically not necessary, because if cbuftary is nil, elemsAlloc and elemsUsed are not meaningful. But I added zeroing them to the specification since that is good defensive programming.


.. code-block:: go

SetVarStr(val *string) int
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are we calling it? SetValStr() or SetVarStr() ?? I think all the others are SetValStr() though thinking about it I have to wonder if Var() wouldn't have been a better choice.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to me that for BufferT and BufferTArray, val is preferable to var because we are setting and getting values from a buffer. var would be preferable for KeyT methods, except that we leave it blank there.


.. code-block:: go

SetUsed(newidx uint) int
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking on it, the newidx parm is misnamed. We aren't storing an index here. It is a count of active elements in the array. So perhaps 'newcnt' is a better name.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to newUsed

Use this method to set the current number of valid strings (subscripts
or variable names) in the :code:`BufferTArray`.

- If :code:`idx` is greater than :code:`elemsAlloc`, make no
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should reference 'newidx' (now 'newcnt') instead of 'idx'.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed from newidx to newUsed – should make it even clearer.

- Otherwise, set :code:`elemsUsed` to :code:`newidx` and return with a
return code of :code:`C.YDB_OK`.

Note that even if :code:`idx` is not greater than the value of
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another idx to change along with the newidx references.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected to newUsed


.. code-block:: go

DeleteS(deltype int) int
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this change was undone which is good since we discovered C #define values can be treated as ints instead of requiring them to be C.int.

The function wraps `ydb_init()`_ to initialize the YottaDB runtime
system. This call is normally not required as YottaDB initializes
itself on its first call, the exception being when an application
wishes to set its own signal handlers (see
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't read the Signals chapter in awhile (on my list) but I'm not entire sure the need to call ydb_init() during signal setup is true anymore. The plan is to modify signal setup in YottaDB so that if a handler is defined, it is recorded. Then if that signal occurs, once we are done with YottaDB's processing of the signal, we will call the handler that was previously setup (Golang's handler). If handlers are replaced after YottaDB is initialized, yottadb won't know about it (except for SIGALRM which it specifically checks). I don't know if Golang plays well with others in terms of signals so best would be to have all the handlers setup before YottaDB is initialized. Note this handling is not Golang specific and would apply to an non-M main routine.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nars1, I'll go with whatever you and @estess agree is right for the document.

// #include <errno.h>
// #include <string.h>
// #include "libyottadb.h"
// #cgo LDFLAGS: -L/usr/lib/yottadb/r122 -lyottadb -Wl,-rpath,/usr/lib/yottadb/r122
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably should remove all the includes in this group except libyottadb.h as they have no relevance to what needs to be added. That was just what I had in my main routine for the POC. I removed them all and it still built.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

Finished draft of Simple API methods and LockS() function. Need to draft description of wrapped utility functions.

Edits in response to e-mail comments from Steve Estes June 21, 2018, 5:43pm EDT.

Incorporated comments from Ranjani & Steve E. Reworked Programming in Go section through Methods for clarity & consistency. Yet to do: rework functions and draft programming considerations.

Completed first draft of Programming in Go section.

I believe I have updated the document with responses to all comments to date. With the possible exception of potential changes to yottadb.ForkExec(), the draft is complete and ready for another review pass.

Restore inadvertently deleted .gitignore file and fix typo in MLPG.

Fix .gitignore

Fix a typo, and add KeyT access methods that invoke the corresponding access methods on members of the KeyT structure.

Fix typo

Includes responses to Narayanan's reviews through this time.

Added yottadb.Release(), KeyT methods. Removed StdoutStdErrAdjust(). Responded to comments and fixed typos.

Edits to remove typos and improve readability.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants