Giter Club home page Giter Club logo

delta-dotnet's Introduction

Table of Contents generated with DocToc

This package is a C# wrapper around delta-rs.

It uses the tokio-rs runtime to provide asynchronous behavior. This allows the usage of .NET Tasks and async/await to take advantage of the same behavior provided by the underlying rust library. This library also takes advantage of the Apache Arrow C# IPC formats to minimize the amount of copying required to move data between runtimes.

alt text

The bridge library incorporates delta-rs and tokio-rs as shown in the image below. alt text

Quick Start

  1. Install C++ build tools if needed
    • Visual Studio Installer -> Modify -> Check Desktop Development with C++ -> Confirm modification
  2. Install rust: https://www.rust-lang.org/tools/install
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Apache.Arrow;
using Apache.Arrow.Memory;
using Apache.Arrow.Types;
using DeltaLake.Runtime;
using DeltaLake.Table;


public static Runtime CreateRuntime()
{
    return new DeltaRuntime(RuntimeOptions.Default);
}

public static Task<DeltaTable> CreateDeltaTable(
    Runtime runtime,
    string path,
    CancellationToken cancellationToken
)
{
    var builder = new Apache.Arrow.Schema.Builder();
    builder.Field(fb =>
    {
        fb.Name("test");
        fb.DataType(Int32Type.Default);
        fb.Nullable(false);
    });
    var schema = builder.Build();
    return DeltaTable.CreateAsync(
        runtime,
        new TableCreateOptions(uri, schema)
        {
            Configuration = new Dictionary<string, string?>(),
        },
        cancellationToken);
}

public static Task<DeltaTable, Runtime> InsertIntoTable(
    DeltaTable table,
    CancellationToken cancellationToken)
{
    var allocator = new NativeMemoryAllocator();
    var recordBatchBuilder = new RecordBatch.Builder(allocator)
        .Append(
            "test",
            false,
            col => col.Int32(arr => arr.AppendRange(Enumerable.Range(0, length))));
    var options = new InsertOptions
    {
        SaveMode = SaveMode.Append,
    };
    await table.InsertAsync(
        [recordBatchBuilder.Build()],
        schema,
        options,
        cancellationToken);
}

delta-dotnet's People

Contributors

mightyshazam avatar dependabot[bot] avatar dennyglee avatar ejkani avatar

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.