Return-Path: X-Original-To: apmail-incubator-jena-dev-archive@minotaur.apache.org Delivered-To: apmail-incubator-jena-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 17A8E7C3E for ; Wed, 3 Aug 2011 07:48:05 +0000 (UTC) Received: (qmail 70178 invoked by uid 500); 3 Aug 2011 07:48:04 -0000 Delivered-To: apmail-incubator-jena-dev-archive@incubator.apache.org Received: (qmail 70040 invoked by uid 500); 3 Aug 2011 07:47:59 -0000 Mailing-List: contact jena-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: jena-dev@incubator.apache.org Delivered-To: mailing list jena-dev@incubator.apache.org Received: (qmail 70013 invoked by uid 99); 3 Aug 2011 07:47:50 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 Aug 2011 07:47:50 +0000 X-ASF-Spam-Status: No, hits=-2000.7 required=5.0 tests=ALL_TRUSTED,RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.116] (HELO hel.zones.apache.org) (140.211.11.116) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 Aug 2011 07:47:47 +0000 Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116]) by hel.zones.apache.org (Postfix) with ESMTP id 28F0EA66FA for ; Wed, 3 Aug 2011 07:47:27 +0000 (UTC) Date: Wed, 3 Aug 2011 07:47:27 +0000 (UTC) From: "Paolo Castagna (JIRA)" To: jena-dev@incubator.apache.org Message-ID: <2128077087.4045.1312357647164.JavaMail.tomcat@hel.zones.apache.org> In-Reply-To: <1377138058.4044.1312357647136.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] [Updated] (JENA-85) Common bindings I/O MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/JENA-85?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Paolo Castagna updated JENA-85: ------------------------------- Description: ( from: http://markmail.org/thread/ljjrsiun3oxtrchw ) There are a number of activities that require being about to serialize, and read back, bindings. They use different serializations. A shared "bindings I/O" would mean all activities could use one, tuned, set of serialization and I/O classes. JENA-44 (External sort) encodes a binding as a length-denoted byte array. The byte arry uses lengh-denoted byte arrays within the bindings. I/O is done using Data(In|Out)putStream, specifically. putInt/getInt() and put/get(byte[]) and ByteBuffer putInt/getInt() and put/get(byte[]) for the per-row serialization as (var,Turtle string form) pairs. It uses a null for no such value. JENA-45 (Spill to disk SPARQL Update) uses a more textual representation based on a binding endcoded as (var, Turtle term). End of row is denoted by a DOT. It uses modified RIOT for input reading. There is also use of TSV I/O for writing and reading result sets. In this form, the variables are written once at the start, and not in each line. == Proposed mini-language This proposal takes those separate designs, and adds high-level compression. A sequence of bindings is written assuming there is a list of variables in force. Position in the row determines which variable is bound to which variable (=> compression of variable names). Turtle-style prefixes can be used (=> compression for IRIs) and the value of a slot in a row can "same as the row before" (=> compression for repeated terms) or undefined. Rows end in a DOT - this is not stricly necessary but adds a robustness against truncated data and bugs. Every row is the length, in number of terms, as the list variables in force. Directives are lines starting with a keyword. End on DOT. The directives are: PREFIX : . Like Turtles, except keyword based to fit with being a keyword-driven mini-language. VARS ?x ?y . Set the variables in force for subsequent rows, until the next VARS directive. We need VARS because it's not always possible to determine all the possible variables before starting to write out bindings. A binding row is a sequence of terms, encoded like Turtle, including prefixed names and short forms for numbers (more compression). In addition STAR ("*") means "same term as the row before" and DASH ("-") means undef. Don't use * for - from previous row. Rows end in DOT. Preferred style is one space after each term. This makes writing safe. Terms can be written without intermediate copies (except local name processing) or buffers. The OutputLangUtils does not do this currently but it should. For presentation reasons only, blank lines are allowed (this would all get lost in the lexing/tokenization anyway). Example: ------------- VARS ?x ?y . PREFIX : . :local1 . * - . * 123 . ------------- == Discussion The format is text - but we're writing strings anyway so a binary form, rather than a delimited text form, is unlikely to give much advantage but can't reuse the standard bytes<->chars stuff without intermediate copies This would all be hidden behind interface anyway. A binary tokenizer and binary OutputLangUtils would enable binary output. Dynamic choosing of prefixes can be done. was: (Text taken from: http://markmail.org/thread/ljjrsiun3oxtrchw) There are a number of activities that require being about to serialize, and read back, bindings. They use different serializations. A shared "bindings I/O" would mean all activities could use one, tuned, set of serialization and I/O classes. JENA-44 (External sort) encodes a binding as a length-denoted byte array. The byte arry uses lengh-denoted byte arrays within the bindings. I/O is done using Data(In|Out)putStream, specifically. putInt/getInt() and put/get(byte[]) and ByteBuffer putInt/getInt() and put/get(byte[]) for the per-row serialization as (var,Turtle string form) pairs. It uses a null for no such value. JENA-45 (Spill to disk SPARQL Update) uses a more textual representation based on a binding endcoded as (var, Turtle term). End of row is denoted by a DOT. It uses modified RIOT for input reading. There is also use of TSV I/O for writing and reading result sets. In this form, the variables are written once at the start, and not in each line. == Proposed mini-language This proposal takes those separate designs, and adds high-level compression. A sequence of bindings is written assuming there is a list of variables in force. Position in the row determines which variable is bound to which variable (=> compression of variable names). Turtle-style prefixes can be used (=> compression for IRIs) and the value of a slot in a row can "same as the row before" (=> compression for repeated terms) or undefined. Rows end in a DOT - this is not stricly necessary but adds a robustness against truncated data and bugs. Every row is the length, in number of terms, as the list variables in force. Directives are lines starting with a keyword. End on DOT. The directives are: PREFIX : . Like Turtles, except keyword based to fit with being a keyword-driven mini-language. VARS ?x ?y . Set the variables in force for subsequent rows, until the next VARS directive. We need VARS because it's not always possible to determine all the possible variables before starting to write out bindings. A binding row is a sequence of terms, encoded like Turtle, including prefixed names and short forms for numbers (more compression). In addition STAR ("*") means "same term as the row before" and DASH ("-") means undef. Don't use * for - from previous row. Rows end in DOT. Preferred style is one space after each term. This makes writing safe. Terms can be written without intermediate copies (except local name processing) or buffers. The OutputLangUtils does not do this currently but it should. For presentation reasons only, blank lines are allowed (this would all get lost in the lexing/tokenization anyway). Example: ------------- VARS ?x ?y . PREFIX : . :local1 . * - . * 123 . ------------- == Discussion The format is text - but we're writing strings anyway so a binary form, rather than a delimited text form, is unlikely to give much advantage but can't reuse the standard bytes<->chars stuff without intermediate copies This would all be hidden behind interface anyway. A binary tokenizer and binary OutputLangUtils would enable binary output. Dynamic choosing of prefixes can be done. > Common bindings I/O > ------------------- > > Key: JENA-85 > URL: https://issues.apache.org/jira/browse/JENA-85 > Project: Jena > Issue Type: New Feature > Components: ARQ > Reporter: Paolo Castagna > > ( from: http://markmail.org/thread/ljjrsiun3oxtrchw ) > There are a number of activities that require being about to serialize, and read back, bindings. They use different serializations. A shared "bindings I/O" would mean all activities could use one, tuned, set of serialization and I/O classes. > JENA-44 (External sort) encodes a binding as a length-denoted byte array. The byte arry uses lengh-denoted byte arrays within the bindings. I/O is done using Data(In|Out)putStream, specifically. putInt/getInt() and put/get(byte[]) and ByteBuffer putInt/getInt() and put/get(byte[]) for the per-row serialization as (var,Turtle string form) pairs. It uses a null for no such value. > JENA-45 (Spill to disk SPARQL Update) uses a more textual representation based on a binding endcoded as (var, Turtle term). End of row is denoted by a DOT. It uses modified RIOT for input reading. > There is also use of TSV I/O for writing and reading result sets. In this form, the variables are written once at the start, and not in each line. > == Proposed mini-language > This proposal takes those separate designs, and adds high-level compression. > A sequence of bindings is written assuming there is a list of variables in force. Position in the row determines which variable is bound to which variable (=> compression of variable names). Turtle-style prefixes can be used (=> compression for IRIs) and the value of a slot in a row can "same as the row before" (=> compression for repeated terms) or undefined. > Rows end in a DOT - this is not stricly necessary but adds a robustness against truncated data and bugs. > Every row is the length, in number of terms, as the list variables in force. > Directives are lines starting with a keyword. End on DOT. > The directives are: > PREFIX : . > Like Turtles, except keyword based to fit with being a keyword-driven mini-language. > VARS ?x ?y . > Set the variables in force for subsequent rows, > until the next VARS directive. > We need VARS because it's not always possible to determine all > the possible variables before starting to write out bindings. > A binding row is a sequence of terms, encoded like Turtle, including prefixed names and short forms for numbers (more compression). In addition STAR ("*") means "same term as the row before" and DASH ("-") means undef. Don't use * for - from previous row. > Rows end in DOT. Preferred style is one space after each term. This makes writing safe. > Terms can be written without intermediate copies (except local name processing) or buffers. The OutputLangUtils does not do this currently but it should. > For presentation reasons only, blank lines are allowed (this would all get lost in the lexing/tokenization anyway). > Example: > ------------- > VARS ?x ?y . > PREFIX : . > :local1 . > * - . > * 123 . > ------------- > == Discussion > The format is text - but we're writing strings anyway so a binary form, rather than a delimited text form, is unlikely to give much advantage but can't reuse the standard bytes<->chars stuff without intermediate copies > This would all be hidden behind interface anyway. A binary tokenizer and binary OutputLangUtils would enable binary output. > Dynamic choosing of prefixes can be done. -- This message is automatically generated by JIRA. For more information on JIRA, see: http://www.atlassian.com/software/jira