From dev-return-166334-archive-asf-public=cust-asf.ponee.io@commons.apache.org Tue Feb 13 02:11:10 2018 Return-Path: X-Original-To: archive-asf-public@eu.ponee.io Delivered-To: archive-asf-public@eu.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by mx-eu-01.ponee.io (Postfix) with ESMTP id 6EE1E180652 for ; Tue, 13 Feb 2018 02:11:10 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 5EF10160C61; Tue, 13 Feb 2018 01:11:10 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id A4460160C3F for ; Tue, 13 Feb 2018 02:11:09 +0100 (CET) Received: (qmail 29692 invoked by uid 500); 13 Feb 2018 01:11:08 -0000 Mailing-List: contact dev-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Commons Developers List" Delivered-To: mailing list dev@commons.apache.org Received: (qmail 29673 invoked by uid 99); 13 Feb 2018 01:11:07 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 13 Feb 2018 01:11:07 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id 4CF0CC00D3 for ; Tue, 13 Feb 2018 01:11:07 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.879 X-Spam-Level: * X-Spam-Status: No, score=1.879 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HTML_MESSAGE=2, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd4-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id 9Db-bTpZ1wzn for ; Tue, 13 Feb 2018 01:11:04 +0000 (UTC) Received: from mail-oi0-f42.google.com (mail-oi0-f42.google.com [209.85.218.42]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTPS id 0C8C65F4DC for ; Tue, 13 Feb 2018 01:11:04 +0000 (UTC) Received: by mail-oi0-f42.google.com with SMTP id 4so12638074ois.10 for ; Mon, 12 Feb 2018 17:11:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=fFtPrUFXwV5zf/Iqcric3/SJVsTfGmmwRF3JJR8eTAk=; b=Mme3oVoxGX5QgZoV5iyGEk3HN6jbdLak4vOcuJSxwsYkWuWtQoQzHHcEq0iWdBs+fQ aqEYui/8TbYXs+TXkC4UW17voPWNdu/ARZImPAQDgMSWIJQHwWX7mDW7J5d89h5c2ORX YUjeyNU56MWhAbodBJymLJxhrmaiu0luGUBP2KX7jeDL8jcxpERKOYCS4B2Ewz+pxT60 GHxm972gtj0dYnysEhbEbW7HXYq51zEGDKShcLO3Caoo4f74DRiL0BiFqqI/TQ5t8e6B V2XTHBU/gBgTugep2TjI7yaS9SqDhkcD9dmkqQ12KjGdJxa3iIqr84aNjiGL6CgLmiND sk4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=fFtPrUFXwV5zf/Iqcric3/SJVsTfGmmwRF3JJR8eTAk=; b=MoGN2MgRwpSAuxLvBh6Lzk/LQ+NS6MEM/s9CAmsEMLvtMZvpfgktijwRYdG3FfdVje d6JEUCk6hqg74Z0YAOH9ekMFxxHegXrzuULUP0b1e71GJS2p/qE+hJIyNXfU6xVVmWhE DQIHp+E9QGxgT36E068RACgmdvsO9DdH58bZ7VgOmt5Mz03FNYgAuQe36r4dftJ9txH8 d8Vpzk2ePaQMK6lNvhMzG1EG0mmPo8lf1XsDVrRIK7Q2CY+qOu1Hy5FwXju1wSWlxGuw 2iYIuWbcwbWyd/PCexWM/wIgIF/dRB+/vM3Hq4pBChu2cKmRsZ7fnSUJqFdLcgaE77lP gVkg== X-Gm-Message-State: APf1xPAr05DO5jo806Kf3BEp+r3hBVMzWU0ymGv/A+k/Umk4f1yo47K2 LHqMsm97B+IgTi/k/1j5liUz4HVqx8d1RcO3veTYbg8= X-Google-Smtp-Source: AH8x225ltBrhja8Iurqjdu6EANqvE6pW4ajao3uQ7BnZY8dU6Z7uaP3HPpXweLcH8iQfFeVQPv/66gfmEGGPvZeOqnQ= X-Received: by 10.202.232.21 with SMTP id f21mr8618825oih.29.1518484256532; Mon, 12 Feb 2018 17:10:56 -0800 (PST) MIME-Version: 1.0 Received: by 10.157.16.109 with HTTP; Mon, 12 Feb 2018 17:10:56 -0800 (PST) In-Reply-To: <20180209170522.GB31005@biggie> References: <20180209170522.GB31005@biggie> From: Gary Gregory Date: Mon, 12 Feb 2018 18:10:56 -0700 Message-ID: Subject: Re: [CSV][POLL] How to provide mutable records To: Commons Developers List Content-Type: multipart/alternative; boundary="001a11403e3ab5305a05650daa3c" --001a11403e3ab5305a05650daa3c Content-Type: text/plain; charset="UTF-8" On Fri, Feb 9, 2018 at 10:05 AM, Stian Soiland-Reyes wrote: > On Fri, 25 Aug 2017 19:19:58 +0100, Stian Soiland-Reyes > wrote: > > This came up also for commons rdf where we also have everything > immutable, > > which I think is a good principle to keep for modern Java 8 programming. > > > > So you need a mutator function like in (4) that either returns a new > > immutable (but changed) CSVRecord; or alternatively a different > > MutableCSVRecord that can then be built/frozen to a CSVRecord. (These can > > then share a common accessor interface for the passive functions) > > Picking up this thread to consider this for CSV 1.6. > > Not quite as elegant as above, but I made > some mutator functions withValue() in > https://github.com/apache/commons-csv/pull/25 > > > for (CSVRecord r : csvparser) { > CSVRecord rSoup = r.withValue(4, "soup") > .withValue(5, "fish"); > // original r is untouched and can be used again > CSVRecord rBeans = r.withValue(3, "beans"); > > List list; > // Each now different > someList.add(r); > someList.add(rSoup); > someList.add(rBeans); > > // worried someone might touch your beans? > consumeCSVRecord(rBeans.immutable()) > } > > It's not clever enough (yet!) to resize the underlying array if you try to > go > outside the existing columns. The existing parser seems to detect column > number > (and hence record array size) per line so this might be weird for some > inconsistent CSV files. > > > > Comments and changes on CSV-216 branch welcome. > Hi Stian, I've not had time to review this yet but I hope to get to it sometimes this week. Gary > > -- > Stian Soiland-Reyes > The University of Manchester > http://www.esciencelab.org.uk/ > http://orcid.org/0000-0001-9842-9718 > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org > For additional commands, e-mail: dev-help@commons.apache.org > > --001a11403e3ab5305a05650daa3c--