Code Monkey home page Code Monkey logo

Comments (4)

buriy avatar buriy commented on August 28, 2024 1

would like to have batching support in the client.

from tarantool-python.

bofm avatar bofm commented on August 28, 2024 1

A dirty workaround might help for now. Here is a batch insert variant.

from itertools import islice

def load_tarantool(t, items, space_name):
    space_sid = t.schema.get_space(space_name).sid
    items = iter(items)
    chunk_size = 1000
    chunk = tuple(islice(items, chunk_size))
    n = 0
    while chunk:
        payload = b''.join(bytes(RequestInsert(t, space_sid, item)) for item in chunk)
        t._socket.sendall(payload)
        try:
            assert all(Response(t, t._read_response()) for _ in chunk)
        except SchemaReloadException as e:
            t.update_schema(e.schema_version)
            continue
        n += len(chunk)
        chunk = tuple(islice(items, chunk_size))
    print(f'inserted {n} items') 

from tarantool-python.

 avatar commented on August 28, 2024

Yes, something to reduce round-trips from client to database would certainly be a great feature.

from tarantool-python.

DifferentialOrange avatar DifferentialOrange commented on August 28, 2024

There is no any native support for batching in basic IPROTO requests. Just sending a sequence of inserts isn't nice since some of them may fail in the middle and we won't have any possibility to handle it properly.

On the other hand, crud module has *_many methods which is essentially a batch insert/replace/upsert for sharded systems. These handles will be supported as part of the #205 issue. So I'm closing this one in favor of #205

from tarantool-python.

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.