jacquayj / GoRODS

Golang binding for iRODS C API: An iRODS client library written in Golang + C
https://godoc.org/github.com/jjacquay712/GoRODS
BSD 3-Clause "New" or "Revised" License
17 stars 5 forks source link

Investigate grabbing multiple resources like "ils -L" #3

Closed jjacquay712 closed 8 years ago

jjacquay712 commented 8 years ago

Data objects can be contained within multiple resources, figure out how to get that information. Currently we save a single "resource" string when reading a collection, maybe it's comma delimited?

jjacquay712 commented 8 years ago

Did a quick check on a replicated resource and it seems to only show a single resource for a given data object. If a resource is replicated then ‘ils -L’ will show the data object twice and the second entry has the other storage resource. If I view the same collection in GoRods its only showing the first data object, not the replicated one. If I delete the original data object then it will show the replica in the other storage resource.

jjacquay712 commented 8 years ago

@simont It appears that the code in "ils" calls different functions to read the collections depending on the parameters that are passed. GoRods exclusively uses rcReadCollection, whereas ils uses that, as well as a combination of generic database queries:

https://github.com/irods/irods/blob/a1db0f5defa9a34f72be3be1e4f8ae24965f9187/iRODS/lib/core/src/lsUtil.cpp#L129 https://github.com/irods/irods/blob/a1db0f5defa9a34f72be3be1e4f8ae24965f9187/iRODS/lib/core/src/lsUtil.cpp#L369

Need to refactor C.gorods_read_collection to query database rather than call higher level rcReadCollection() function.

jacquayj commented 8 years ago

It turns out all I needed was a NO_TRIM_REPL_FG flag set when opening the collection. The rcGenQuery calls in ils are used to get additional info about a particular data obj or bundle, so I don't have to implement that for this issue. rcReadCollection will work fine.

The next step is implementing a parameter in GoRods to set this flag if functionality is needed. Will refactor Connection.Collection to accept option struct that contains TrimRepls bool field (along with path, recursive, etc...).

jacquayj commented 8 years ago

Example for using new Connection.Collection function:

myCollection, colErr := irods.Collection(gorods.CollectionOptions{
    Path:       "/tempZone/home/rods/source-code",
    Recursive:  true,
    TrimRepls:  false, // When this is set to false (by default) it will return all replicas of a data object
})