GithubHelp home page GithubHelp logo

Comments (9)

kortschak avatar kortschak commented on July 17, 2024

This is trivially implemented, but the design is important. How do you propose to detect compressed input? Easier and more brittle is to go by extensions, more robust is to use magic numbers for bzip2 and gzip

@barakmich, your view?

from cayley.

SergeC avatar SergeC commented on July 17, 2024

Easiest ways is detect compressed input by file extension or add "--format" parameter "./cayley http --dbpath=30kmovies.nt.zip --format=zip".

The reason of doing it is to save space on HDD. Sometimes it's hard to find 300Gb of space especially on rented hardware (VPS, Cloud services).

from cayley.

kortschak avatar kortschak commented on July 17, 2024

I'm not keen on adding a flag for this; it allows a greater opportunity for discordance between data and processing. Per extension is easy:

func extension(file *os.File) (io.Reader, error) {
    switch filepath.Ext(file.Name()) {
    case ".gz", ".gzip":
        return gzip.NewReader(f)
    case ".bz2":
        return bzip2.NewReader(f), nil
    default:
        return f, nil
    }
}

All magic number determination needs is a read of the head of the file to get the file type (gzip[:] == "\x1f\x8b" and b2zip[:3] == "BZh"). This is not difficult:

const (
    gzipMagic  = "\x1f\x8b"
    b2zipMagic = "BZh"
)

type readAtReader interface {
    io.Reader
    io.ReaderAt
}

func magic(r readAtReader) (io.Reader, error) {
    var buf [3]byte
    _, err := r.ReadAt(buf[:], 0)
    if err != nil {
        return nil, err
    }
    switch {
    case bytes.Compare(buf[:2], []byte(gzipMagic)) == 0:
        return gzip.NewReader(r)
    case bytes.Compare(buf[:3], []byte(b2zipMagic)) == 0:
        return bzip2.NewReader(r), nil
    default:
        return r, nil
    }
}

from cayley.

SergeC avatar SergeC commented on July 17, 2024

Sounds very good. Can you please make pull request? I really need to be able to search data in FreeBase compressed database as soon as possible. Thanks.

from cayley.

kortschak avatar kortschak commented on July 17, 2024

I'm waiting on Barak's input. I'd prefer the magic number approach, but I'll defer to his view on this.

from cayley.

SergeC avatar SergeC commented on July 17, 2024

Currently I seeing process of using this database:

  1. Load data into Level DB, MongoDB etc.
  2. Use loaded data in step 1 in Cayley.

My questions are:

  1. Is it possible to use gziped FreeBase data dump in Cayley as backend without loading dump into database? As I can see from examples of using Cayley it's possible to use only unpacked FreeBase data dump but it require a lot of RAM.
  2. If Q1 is not possible. To speed up process and reduce RAM usage. Is it possible to load only into Level DB, MongoDB etc. only need data from gziped FreeBase data dump? For example I need only music domain.

To make Cayley usable I cut needed data with few greps then using Cayley to query it.

from cayley.

kortschak avatar kortschak commented on July 17, 2024

This was fixed by 984ab6f.

from cayley.

SergeC avatar SergeC commented on July 17, 2024

Thanks. I'll test it as soon as new version of binaries will be released for Mac OS X.

from cayley.

barakmich avatar barakmich commented on July 17, 2024

0.3.1 is available (point release, yay)

from cayley.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.