Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion embedded/compact not overwriting file

Received: by 10.101.73.17 with SMTP id a17mr4276928anl.18.1279643888495;
        Tue, 20 Jul 2010 09:38:08 -0700 (PDT)
X-BeenThere: fleetdb@googlegroups.com
Received: by 10.101.156.10 with SMTP id i10ls1313655ano.3.p; Tue, 20 Jul 2010 
	09:38:08 -0700 (PDT)
Received: by 10.100.142.14 with SMTP id p14mr4609297and.3.1279643887989;
        Tue, 20 Jul 2010 09:38:07 -0700 (PDT)
Received: by 10.100.142.14 with SMTP id p14mr4609295and.3.1279643887929;
        Tue, 20 Jul 2010 09:38:07 -0700 (PDT)
Return-Path: <mmcgr...@gmail.com>
Received: from mail-gx0-f177.google.com (mail-gx0-f177.google.com [209.85.161.177])
        by gmr-mx.google.com with ESMTP id z14si8328788anl.1.2010.07.20.09.38.06;
        Tue, 20 Jul 2010 09:38:06 -0700 (PDT)
Received-SPF: pass (google.com: domain of mmcgr...@gmail.com designates 209.85.161.177 as permitted sender) client-ip=209.85.161.177;
Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of mmcgr...@gmail.com designates 209.85.161.177 as permitted sender) smtp.mail=mmcgr...@gmail.com; dkim=pass (test mode) header...@gmail.com
Received: by mail-gx0-f177.google.com with SMTP id 27so2985380gxk.22
        for <fleetdb@googlegroups.com>; Tue, 20 Jul 2010 09:38:06 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=gamma;
        h=domainkey-signature:received:mime-version:received:in-reply-to
         :references:from:date:message-id:subject:to:content-type
         :content-transfer-encoding;
        bh=BrHVk64IEJHEXqm+B6mTRJQ8Dv+6jb7QHfDvE5Nl1s4=;
        b=M9RtrtD7prkpA1SyijvYtJYBYYdvPe1E7RknDNllZNqKsHpOwdxPCEigMmfgubljQd
         pEogbKwn6P6/vrLk2aUnH/qnAsPDmfVZD57Xb5wA3re9vYxB/n13ko3qycCZ2A+nkKg+
         x/3LKWaQP+VJ78Uw3V0ItwFVbIBgyXrsTUrhw=
DomainKey-Signature: a=rsa-sha1; c=nofws;
        d=gmail.com; s=gamma;
        h=mime-version:in-reply-to:references:from:date:message-id:subject:to
         :content-type:content-transfer-encoding;
        b=H0/80Udvqe+H4DxtyP0p/tsfacFEgaw9KHLlyAt+rPiAjuvCI68CI2pPL31go163PP
         YxRyvYmiiPKFM6PvU47E9ZpxeOW38jzp6zzd7abxY2NPTDAcHD/bF7RoQZKwuMhutQi4
         H41JMhdvMT+j0E4jHp7iAG5/KsQJvN3c0Llrc=
Received: by 10.100.198.19 with SMTP id v19mr5033229anf.233.1279643886483; 
	Tue, 20 Jul 2010 09:38:06 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.100.95.5 with HTTP; Tue, 20 Jul 2010 09:37:46 -0700 (PDT)
In-Reply-To: <839eecd2-fe13-42fa-9bff-19d4e93ac...@k8g2000prh.googlegroups.com>
References: <82a63d00-6bce-47c2-a518-444288a85...@v35g2000prn.googlegroups.com> 
	<AANLkTinR-8TW_GTPRy0WJaZfCK4BonlgqBPtoRIFm...@mail.gmail.com> 
	<839eecd2-fe13-42fa-9bff-19d4e93ac...@k8g2000prh.googlegroups.com>
From: Mark McGranaghan <mmcgr...@gmail.com>
Date: Tue, 20 Jul 2010 09:37:46 -0700
Message-ID: <AANLkTiksEvzQI29W39ELMAmg_wNHIA5AjBNcbmeFr...@mail.gmail.com>
Subject: Re: embedded/compact not overwriting file
To: fleetdb@googlegroups.com
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Hi Tim,

A few things:

You rightly pointed out that I hadn't pushed either 0.2.0-RC2 or 0.2.0
to Clojars - I've now done that.

Your problem brings up the issue of Clojure 1.2 compatibility. I
didn't have Clojure 1.2 compatibility as a goal for the 0.2 series. At
the source level 0.2 may be Clojure 1.2 compatible, but unfortunately
the jars have Clojure 1.1 compiled code that does not seem to be
accepted by Clojure 1.2 runtimes. The issue of compiled Clojure code
in jars is a significant one that I'll need to return to later.

That said, if you are just using FleetDB 0.2.0-RC2 or 0.2.0 from
source at least the following example should work fine:

$ cat embedded.clj
(require '[fleetdb.embedded :as emb])

(let [dba (emb/init-persistent "demo.fdb")]
  (emb/query dba ["insert" "data" {"id" 1}])
  (emb/query dba ["insert" "data" {"id" 2}])
  (emb/compact dba)
  (Thread/sleep 100)
  (emb/close dba))

$ clj embedded.clj
$ cat data.fdb
["insert","data",[{"id":2},{"id":1}]]

This works for me locally, even with Clojure 1.2; do you see something
different?

- Mark

On Mon, Jul 19, 2010 at 6:38 PM, Tim Robinson <tim.blacks...@gmail.com> wro=
te:
> I use len:
>
> :dependencies
> =A0 =A0[[org.clojure/clojure "1.2.0-beta1"]
> =A0 =A0 [org.clojure/clojure-contrib "1.2.0-beta1"]
> =A0 =A0 [clj-stacktrace "0.1.2"]
> =A0 =A0 [net.sf.jopt-simple/jopt-simple "3.2"]
> =A0 =A0 [clj-json "0.2.0"]
> =A0 =A0 [ring/ring-core "0.2.5"]
> =A0 =A0 [ring/ring-jetty-adapter "0.2.5"]]
> =A0:dev-dependencies [[org.clojars.mmcgrana/lein-clojars "0.5.0"]
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 [org.clojars.mmcgrana/lein-javac =
"0.1.0"]
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 [clj-unit "0.1.0"]]
>
> + I am using FleetDB 0.2.0-RC2
> =A0 =A0* I have FleetDB in /src. =A0(Clojars had not been updated so I
> configured locally - everything else works fine - so I don't think
> this is a problem??)
> =A0 =A0* I didn't do the last update from RC2 - it appeared there was no
> diff when I looked.
>
> Machine System Version: Mac OS X 10.6.4 (10F569)
>
> I guess that's a lot of variables.
>
> Tim
>
> Clojure 1.2.0-beta1 seems pretty stable. Your latest change log
> indicates you had made changes to be 1.20 friendly.
>
>
> On Jul 19, 6:51=A0pm, Mark McGranaghan <mmcgr...@gmail.com> wrote:
>> Hi Tim,
>>
>> Compaction works for me (see below); what FleetDB version are you
>> using and on what platform?
>>
>> $ fleetdb-server -f data.fdb &
>> $ echo '["insert", "data", {"id": 1}]' | nc localhost 3400
>> $ echo '["insert", "data", {"id": 2}]' | nc localhost 3400
>> $ cat data.fdb
>> ["insert","data",{"id":1}]
>> ["insert","data",{"id":2}]
>> $ echo '["compact"]' | nc localhost 3400
>> $ cat data.fdb
>> ["insert","data",[{"id":2},{"id":1}]]
>> $ ls
>> data.fdb
>>
>> - Mark
>>
>>
>>
>> On Mon, Jul 19, 2010 at 5:28 PM, Tim Robinson <tim.blacks...@gmail.com> =
wrote:
>> > As a FYI, =A0for whatever reason whenever I run compact, it creates
>> > the .tmp file, but does not move it, leaving the .tmp open
>> > (continually appending to it).
>>
>> > It's probably because the writer is still open. Not sure if anyone
>> > else can verify the problem.
>>
>> > At any rate, I thought I'd also mention for others, there's an easy
>> > work around which seem to do the trick for me:
>>
>> > =A0(let [db-file =A0"data/demo.dbf"
>> > =A0 =A0 =A0 =A0 db-atom (embedded/load-persistent db-file)]
>> > =A0 =A0(embedded/compact db-atom)
>> > =A0 =A0(file/mv (str db-file ".tmp") db-file) ; just put mv operation
>> > outside the compact function.
>> > =A0 =A0(embedded/close db-atom)))
>>
>> > You could also remove the mv operation from the embedded/compact
>> > source since it seems not to work.
>>
>> > Regards,
>> > Tim