Description Usage Arguments Value Examples
View source: R/get_block_attributes.R
Gets the following attributes of a block: type, length, size, flags and hash64 as an R list.
1 | get_block_attributes(source, block_key, host = .host.)
|
source |
The Jazz source. Jazz persistence is organized in sources. All sources except 'sys' and 'www' are user defined. Sources are 15 char long alphanumeric or underscore. |
block_key |
The key identifying the block. Keys are 15 alphanumeric or underscore characters. They can be user defined or created by new_key(). Also, meshes use block keys internally. |
host |
(Optional) the name of the jazz server host (including the port). Usually set just once via set_jazz_host(). |
An R list with the attributes: type, length, size, flags and hash64 or raises an error on failure.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | ## Not run:
create_source('demo_types')
# Write a text file as a block.
txt <- c('Hi all,', '', 'This is a file.', '', 'bye,', 'me')
str <- paste(txt, collapse = '\n')
cat(str)
put_raw_block('demo_types', 'blk_1', str)
# The block is raw (not interpreted as data by the server) and can be converted to any raw type.
set_compatible_data_type('demo_types', 'blk_1', type_const[['BLOCKTYPE_RAW_MIME_TXT']])
# curl 127.0.0.1:8888//demo_types.blk_1 (or open in a in a browser)
get_block_attributes('demo_types', 'blk_1')
# The attribute flags is writable by the user.
put_block_flags('demo_types', 'blk_1', 123000444)
get_block_attributes('demo_types', 'blk_1')
# Unlike the previous block, this block is a data block.
put_R_block('demo_types', 'blk_2', 3:6)
# This trivial block can also be created by the server as..
create_block_seq('demo_types', 'blk_2', 3L, 6)
get_block_attributes('demo_types', 'blk_2')
# The block is interpreted as data by the server, it is an integer and can be converted to
any integer type.
set_compatible_data_type('demo_types', 'blk_2', type_const[['BLOCKTYPE_C_R_GRADE']])
get_block_attributes('demo_types', 'blk_2')
# This returns all the rows in a single string
get_block_as_string('demo_types', 'blk_2', '
# With some help of R functions, the result of get_block_as_string() can be made integer again.
any(3:6 != as.integer(strsplit(get_block_as_string('demo_types', 'blk_2', '
rs <- c('1', '2.7', '3.14')
# Creating strings into numeric data. (The parse(.., collapse = '\n') is automatic.)
put_strings_as_block('demo_types', 'blk_3', rs, type_const[['BLOCKTYPE_C_R_REAL']])
get_block_attributes('demo_types', 'blk_3')
any(as.numeric(rs) != get_R_block('demo_types', 'blk_3'))
delete_source('demo_types')
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.