Hi Christian,
There are two differences between the server protocol and my implementation. 1 I use "Execute" instead of "Command" as in the command protocol (When I started with this project I thought of it as "Executing" a Command. It is still possible to change Execute to Command if you prefer that). 2 I introduced a little bit of scripting. The last byte of the response indicates success or failure. When the 'intercept' that I introduced is set to TRUE, the success indicator can be used in a R-script to avoid abortion (a very basic form of exception handling and scripting)
Apart from that I have followed the server protocol to the letter. ALL commands from the command - and the query protocol are implemented and follow this pattern: exec <- c(as.raw(0x09), addVoid(path), addVoid(input_to_raw(input))) response <- private$sock$handShake(exec) %>% split_Response()
All input-parameters are converted to a raw vector and each parameter has a 00 appended. Together with the preceding byte, this is sent to the server. The server returns a raw vector. This vector is splitted on 00. The last byte of the response indicates success.
R6, the R object orientation system I used does not know polymorphism but copying the Java source to R6 was not very difficult.
I am now really using the package. And it is now that I sometimes see bugs but this is the first bug I don't understand. According to the protocol and the general BaseX documentation, there are two ways to create a database. 1) you can send a specific "Create" command (preceding byte is \08 or 2) you can execute a "Create db" command (no preceding byte).
These variables are used in the examples: DB_Name <- "Parl_Test" XML_Files <- system.file("extdata", "xml_files", package="RBaseX") Single_File <- paste(XML_Files, "h-tk-20202021-102-12.xml", sep="/")
Session$Execute(paste("Create db", DB_Name, Single_File)) # => success Session$Execute(paste("Create db", DB_Name, XML_Files)) # => success
Session$Create(DB_Name) # => success
Session$Create(DB_Name, Single_File) # => error Session$Create(DB_Name, XML_Files) # => error
The server protocol does not specify the format that is to be used for input. It only says that input may be empty. Do I use the wrong format?
Gruesse, Ben
Op 22-02-2022 om 14:07 schreef Christian GrĂ¼n:
Hi Ben,
I guess this could be caused by a little error in your implementation of the R client. Did you already have a look at the documentation of the server protocol [1] and an alternative implementation [2]?
Cheers, Christian
[1] https://docs.basex.org/wiki/Server_Protocol [2] https://github.com/BaseXdb/basex/blob/master/basex-examples/src/main/java/or...
On Mon, Feb 21, 2022 at 1:03 PM Ben Engbers Ben.Engbers@be-logical.nl wrote:
Hi,
I have a directory with 12 testfiles. In the BaseX-GUI, the command: CREATE DB Parl_Test /home/bengbers/R/x86_64-redhat-linux-gnu-library/4.1/RBaseX/extdata/xml_files/ Creates database "Parl_Test" and loads the xml-files.
In my R-client, Session$Create("Parl_Test") creates database "Parl_test"=> OK
I want to create the same database with my client.
I initialize the variable "XML_Files" with "/home/bengbers/R/x86_64-redhat-linux-gnu-library/4.1/RBaseX/extdata/xml_files".
The client translates the command: Session$Create("Parl_Test", XML_Files) into a raw vector: '\bParl_Test\0/home/bengbers/R/x86_64-redhat-linux-gnu-library/4.1/RBaseX/extdata/xml_files' which is sent to the server. But the server responds with: ""Parl_Test.xml" (Regel 1): Content is not allowed in prolog."
I didn't touch the xml-files. Where is the content inserted?
Ben Engbers