Received: from localhost (maia-2.hub.org [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id 832EC9FB4B5 for ; Wed, 13 Jun 2007 10:26:46 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-maia, port 10024) with ESMTP id 90073-08 for ; Wed, 13 Jun 2007 10:26:37 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.5 Received: from nz-out-0506.google.com (nz-out-0506.google.com [64.233.162.228]) by postgresql.org (Postfix) with ESMTP id 8021C9FB59A for ; Wed, 13 Jun 2007 10:26:41 -0300 (ADT) Received: by nz-out-0506.google.com with SMTP id m22so165847nzf for ; Wed, 13 Jun 2007 06:26:40 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; b=eQsiHZ7Wx4JGMv3I/rfhf+59F7x5H1VwYC60GRTZ3NpKBwlUwMLdATSpQTF50Mx08mP6JXbNy6Em4F6XUJH1VXSg603RK1A7I5N+Wa6HNiJ1zkCO5v7r5WU8+8DxB+uG7AEMjFuN0YbUim5nXA0Uj6EWSYzTvgmNOkVn2KfKg1w= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; b=baDDtiJQyhrwEF6Dt6PGnxXJ2teLBoGg2eNLTJZZLAoh1QKBwsVDpuVosJeWA199Ne3nm+Egs41btVoKd7cuAsHNTsWCkW0uFPzqW4XOXapBB0RDrRt9KQDFa598dx5zh3NXUfjdSuvuhGikvv7Ve6bJfr0yASZpIhe2qjBPpv0= Received: by 10.114.176.1 with SMTP id y1mr613511wae.1181741198394; Wed, 13 Jun 2007 06:26:38 -0700 (PDT) Received: by 10.114.151.9 with HTTP; Wed, 13 Jun 2007 06:26:38 -0700 (PDT) Message-ID: Date: Wed, 13 Jun 2007 16:26:38 +0300 From: "Kalle Hallivuori" To: "Kris Jurka" Subject: Re: FYI: porting Copy API to 8.x Cc: pgsql-jdbc@postgresql.org In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <66D125B2-3C81-467E-BC02-D784ACDD5499@fastcrypt.com> X-Google-Sender-Auth: 49969ac410e2b3d5 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200706/48 X-Sequence-Number: 17110 Hi Kris! Happy to receive feedback. 2007/6/13, Kris Jurka : > This patch doesn't apply cleanly because there's a mix of unix and windows > EOL characters and it seems to have some other application problems. Sorry for that. I'll pay closer attention to the format in future. > The API is not thread safe. If two threads are using the same connection > the synchronization in QueryExecutorImpl prevents them from stepping on > each others toes and writing garbage to the backend. So the call to > QueryExecutor must be an atomic operation and implies that the > QueryExecutorImpl will be the controller and demand/push data from some > kind of copy client instead of the other way around. Yes. (I thought that was alright since I spotted a statement of no support for synchronization somewhere, but that turned out to be at lower level, pgStream.) I'll look into current synchronization and hopefully I'll be able (as in have the time) to do that. > Also I'm not especially fond of the row based API that you've come up > with. It seems like you should either go to an element or stream based > API. Who has a premade row? ... It doesn't matter what kinds of chunks you feed it (I think that was ingenious of the COPY specification writers). With a CSV file you can read it as a whole into a single byte[] and write that at once. Or you can have static size byte buffer and pass it repeatedly to write(). In my application I now succesfully collect a bunch of field values as separate byte[]'s mixed with references to static instances of delimiter byte[]'s into a large, static size byte[][], write when it fills up, repeat until out of data. Cut time spent in import by half. (The other half of import time is spent post-processing the data :)) However, if that isn't intuitive it has to be explained clearly in all documentation or a more intuitive API offered. I think you're right on all accounts. I'll try to find some time to make it synchronized and self-evident. Shouldn't be too much of an effort now. -- Kalle Hallivuori +358-41-5053073 http://korpiq.iki.fi/