-
Notifications
You must be signed in to change notification settings - Fork 6
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
base: master
Are you sure you want to change the base?
Conversation
<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. |
There was a problem hiding this comment.
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"?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comma after "for example"
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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"
There was a problem hiding this comment.
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>`_ |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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'.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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_used
field is zero, the default increment is 1.
|
||
.. code-block:: go | ||
|
||
LockS( timeoutNsec uint64, ... *KeyT) int |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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`_ |
There was a problem hiding this comment.
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" ?
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this 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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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_used
field is zero, the default increment is 1.
|
||
.. code-block:: go | ||
|
||
LockS( timeoutNsec uint64, ... *KeyT) int |
There was a problem hiding this comment.
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`_ |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reference -> anchor?
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SubPrevtS -> SubPrevS
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 | ||
----------------------- | ||
------------ |
There was a problem hiding this comment.
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().
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Incomplete sentence.
There was a problem hiding this comment.
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. | ||
|
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gorutine -> goroutine
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"directly" bypasses?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bufer -> buffer
There was a problem hiding this comment.
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` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
field field -> field
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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`. |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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'.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// #include <errno.h> | ||
// #include <string.h> | ||
// #include "libyottadb.h" | ||
// #cgo LDFLAGS: -L/usr/lib/yottadb/r122 -lyottadb -Wl,-rpath,/usr/lib/yottadb/r122 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
…tion of interface is a to do.
…r interface has a string return.
…l, and related cleanup of language.
Utility function wrapper descriptions yet to be added. This is a request for an initial review, not a review before merging.