Skip to content

Instantly share code, notes, and snippets.

View asm0dey's full-sized avatar

Pasha Finkelshteyn asm0dey

View GitHub Profile
@asm0dey
asm0dey / Main.kt
Created March 30, 2020 09:47
Reading ORC data not from files, but from input streams
import org.apache.orc.CompressionKind
import org.apache.orc.OrcProto
import org.apache.orc.OrcProto.*
import org.apache.orc.OrcUtils
import org.apache.orc.impl.BufferChunk
import org.apache.orc.impl.InStream
import org.apache.orc.impl.InStream.StreamOptions
import org.apache.orc.impl.OrcCodecPool
import java.io.FileInputStream
import java.io.InputStream
/**
* Returns an expression that can be used to deserialize a Spark SQL representation to an object
* of java bean `T` with a compatible schema. The Spark SQL representation is located at ordinal
* 0 of a row, i.e., `GetColumnByOrdinal(0, _)`. Nested classes will have their fields accessed
* using `UnresolvedExtractValue`.
*/
def deserializerForDataType(beanClass: Class[_], dt: KDataTypeWrapper): Expression = {
val typeToken = TypeToken.of(beanClass)
val walkedTypePath = new WalkedTypePath().recordRoot(beanClass.getCanonicalName)
val (dataType, nullable) = inferDataType(typeToken)
<!DOCTYPE html><html lang="en-US"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width,height=device-height,initial-scale=1.0"><meta name="apple-mobile-web-app-capable" content="yes"><meta http-equiv="X-UA-Compatible" content="ie=edge"><meta property="og:type" content="website"><meta name="twitter:card" content="summary"><style>.bespoke-marp-note,.bespoke-marp-osc,.bespoke-progress-parent{display:none;-webkit-transition:none;transition:none}@media screen{body[data-bespoke-view=""] .bespoke-marp-parent>.bespoke-marp-osc>button,body[data-bespoke-view=next] .bespoke-marp-parent>.bespoke-marp-osc>button,body[data-bespoke-view=presenter] .bespoke-marp-presenter-container .bespoke-marp-presenter-info-container button{-webkit-appearance:none;-moz-appearance:none;appearance:none;background-color:transparent;border:0;color:inherit;cursor:pointer;font-size:inherit;opacity:.8;outline:none;padding:0;-webkit-transition:opacity .2s linear;transition:opacity .2s linear;-webkit-tap-highlight-color:tr
<!DOCTYPE html><html lang="en-US"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width,height=device-height,initial-scale=1.0"><meta name="apple-mobile-web-app-capable" content="yes"><meta http-equiv="X-UA-Compatible" content="ie=edge"><meta property="og:type" content="website"><meta name="twitter:card" content="summary"><style>.bespoke-marp-note,.bespoke-marp-osc,.bespoke-progress-parent{display:none;-webkit-transition:none;transition:none}@media screen{body[data-bespoke-view=""] .bespoke-marp-parent>.bespoke-marp-osc>button,body[data-bespoke-view=next] .bespoke-marp-parent>.bespoke-marp-osc>button,body[data-bespoke-view=presenter] .bespoke-marp-presenter-container .bespoke-marp-presenter-info-container button{-webkit-appearance:none;-moz-appearance:none;appearance:none;background-color:transparent;border:0;color:inherit;cursor:pointer;font-size:inherit;opacity:.8;outline:none;padding:0;-webkit-transition:opacity .2s linear;transition:opacity .2s linear;-webkit-tap-highlight-color:tr
@asm0dey
asm0dey / main.rs
Last active January 4, 2020 18:57
use core::fmt;
use std::fmt::{Error, Formatter};
use std::option::Iter;
use crate::DeltaType::{CHANGE, DELETE, INSERT};
fn main() {
for x in create_patch("abc", "def") {
println!("{}", x.to_string())
}
@asm0dey
asm0dey / DBAuthKTest.kt
Created December 6, 2019 05:18
Tests for Kotlintest demo
package org.ort.school.app.service
import com.winterbe.expekt.should
import io.kotlintest.shouldThrow
import io.kotlintest.specs.ShouldSpec
import io.mockk.every
import io.mockk.mockk
import org.ort.school.app.repo.UserRepo
import org.pac4j.core.credentials.UsernamePasswordCredentials
import org.pac4j.core.exception.CredentialsException
import os
from time import sleep
import skein
from skein.model import ApplicationState
mem_sz_gb = os.environ["LMD_PO_MEM_SIZE_GB"]
cores_number = os.environ["LMD_PO_NUM_CORES"]
spec = skein.ApplicationSpec(
@JvmField
val ENCODERS = mapOf<KClass<out Any>, Encoder<out Any>>(
Boolean::class to Encoders.BOOLEAN(),
Byte::class to Encoders.BYTE(),
Short::class to Encoders.SHORT(),
Int::class to Encoders.INT(),
Long::class to Encoders.LONG(),
Float::class to Encoders.FLOAT(),
Double::class to Encoders.DOUBLE(),
String::class to Encoders.STRING(),
package some;
import java.util.*;
import java.util.stream.Stream;
import static java.lang.Integer.parseInt;
import static java.util.Collections.singletonList;
import static java.util.Locale.ENGLISH;
public class Solver {
@asm0dey
asm0dey / install_peerflix.sh
Last active June 30, 2018 19:55 — forked from abakum/install_peerflix
Use peerflix for kodi@OSMC on raspberry Pi
#!/bin/bash
mkdir -p ~/ins
cd ~/ins
wget http://node-arm.herokuapp.com/node_latest_armhf.deb
sudo dpkg -i node_latest_armhf.deb
sudo npm install -g peerflix