GithubHelp home page GithubHelp logo

rajeshpillai / frunk-column Goto Github PK

View Code? Open in Web Editor NEW

This project forked from paulkernfeld/frunk-column

0.0 0.0 0.0 2 KB

A prototype of columnar data storage using frunk HLists

Rust 100.00%

frunk-column's Introduction

frunk-column

A prototype of columnar data storage using frunk HLists

#[macro_use]
extern crate frunk;
extern crate frunk_core;
use frunk::indices::Here;
use frunk::prelude::*;
use frunk::Generic;
use frunk_column::*;
use std::iter::FromIterator;

fn main() {
    #[derive(Clone, Copy, Debug, Generic, PartialEq)]
    struct Planet {
        mass_kg: f64,
        radius_m: f64,
        habitable: bool,
    }

    let earth = Planet {
        mass_kg: 5.976e+24,
        radius_m: 6.37814e6,
        habitable: true,
    };
    let mars = Planet {
        mass_kg: 6.421e+23,
        radius_m: 3.3972e6,
        habitable: false,
    };

    let mut planets = <Planet as Generic>::Repr::new_frame();
    planets.push(frunk::into_generic(earth));
    planets.push(frunk::into_generic(mars));

    let hlist_pat![_mass_kg, radius_m, ...] = &planets;
    assert_eq!(radius_m, &[6.37814e6, 3.3972e6]);

    assert_eq!(planets.row(1), Some(frunk::into_generic(mars)));

    assert_eq!(
        Vec::from_iter(planets.into_iter().map::<Planet, _>(frunk::from_generic)),
        vec![earth, mars]
    );
}

License: MIT/Apache-2.0

frunk-column's People

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.