text:
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE UnicodeSyntax       #-}

-- From (Sander, 1992, pp. 68-69).

-- Tested with streams 3.2.1.

module SimpleNetwork where

import Data.Stream.Infinite ( Stream )

------------------------------------------------------------------------------

f1 ∷ Stream a → Stream a → Stream a
f1 = undefined

f2 ∷ Stream a → Stream a
f2 = undefined

trans ∷ forall a. Stream a → Stream a
trans is = os
  where
  ys ∷ Stream a
  ys = f1 os is
  os = f2 ys

type Ty a = (Stream a → Stream a → Stream a) → (Stream a → Stream a) →
            Stream a → Stream a

trans', hys ∷ Ty a
trans' g1 g2 is = g2 (hys g1 g2 is)
hys    g1 g2 is = g1 (trans' g1 g2 is) is

------------------------------------------------------------------------------
-- References
--
-- Sander, Herbert P. (1992). A Logic of Functional Programs with an
-- Application to Concurrency. PhD thesis. Department of Computer
-- Sciences: Chalmers University of Technology and University of
-- Gothenburg.

redpajama_set_name: RedPajamaGithub


text:
$output.resource("localization/pages", "login.xml")##
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
<properties>
	<comment>Login</comment>
	<entry key="login_title">Login</entry>
	<entry key="login_header">Login</entry>
	<entry key="login_login">Username</entry>
	<entry key="login_password">Password</entry>
	<entry key="login_rememberme">Remember me on this computer.</entry>
	<entry key="login_submit">Login</entry>
	<entry key="login_error">Invalid login or password</entry>
	<entry key="login_logout">Logout</entry>
	<entry key="session_expired">Your session has expired... please login again.</entry>
	<entry key="login_description"><![CDATA[

			If you used our database schema example or if Celerio could
			not detect in your database schema the table used to store username/password pairs, you
			should use:

admin/admin: can access all data

user/user: can access only home page

	]]></entry>
</properties>


text:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Threading;
using System.Windows.Threading;
using Inbox2.Platform.Framework.Collections;
using Inbox2.Platform.Framework.Locking;
using Inbox2.Platform.Interfaces;

namespace Inbox2.Framework.VirtualMailBox
{
	public class ThreadSafeCollection<T> : AdvancedObservableCollection<T>, ISynchronizedObject
	{
		private readonly Dispatcher _dispatcher;
		private readonly ReaderWriterLockSlim _lock = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion);

		public ThreadSafeCollection()
        {
            _dispatcher = Dispatcher.CurrentDispatcher;
        }

        protected override void ClearItems()
        {
            if (_dispatcher.CheckAccess())
            {
                using (WriterLock)
					base.ClearItems();
            }
            else
            {
                _dispatcher.Invoke(DispatcherPriority.DataBind, (SendOrPostCallback)delegate { Clear(); }, this);
            }
        }

        protected override void InsertItem(int index, T item)
        {
            if (_dispatcher.CheckAccess())
            {
                if (index > this.Count)
                    return;

				using (WriterLock)
					base.InsertItem(index, item);
            }
            else
            {
                object[] e = new object[] { index, item };
                _dispatcher.Invoke(DispatcherPriority.DataBind, (SendOrPostCallback)delegate { InsertItemImpl(e); }, e);
            }
        }

        void InsertItemImpl(object[] e)
        {
            if (_dispatcher.CheckAccess())
            {
                InsertItem((int)e[0], (T)e[1]);
            }
            else
            {
                _dispatcher.Invoke(DispatcherPriority.DataBind, (SendOrPostCallback)delegate { InsertItemImpl(e); });
            }
        }

        protected override void MoveItem(int oldIndex, int newIndex)
        {
            if (_dispatcher.CheckAccess())
            {
                if (oldIndex >= this.Count | newIndex >= this.Count | oldIndex == newIndex)
                    return;

				using (WriterLock)
					base.MoveItem(oldIndex, newIndex);
            }
            else
            {
                object[] e = new object[] { oldIndex, newIndex };
                _dispatcher.Invoke(DispatcherPriority.DataBind, (SendOrPostCallback)delegate { MoveItemImpl(e); },e);
            }
        }

        void MoveItemImpl(object[] e)
        {
            if (_dispatcher.CheckAccess())
            {
                MoveItem((int)e[0], (int)e[1]);
            }
            else
            {
                _dispatcher.Invoke(DispatcherPriority.DataBind, (SendOrPostCallback)delegate { MoveItemImpl(e); });
            }
        }

        protected override void RemoveItem(int index)
        {
            if (_dispatcher.CheckAccess())
            {
                if (index >= this.Count)
                    return;

				using (WriterLock)
					base.RemoveItem(index);
            }
            else
            {
                _dispatcher.Invoke(DispatcherPriority.DataBind, (SendOrPostCallback)delegate { RemoveItem(index); }, index);
            }
        }

        protected override void SetItem(int index, T item)
        {
            if (_dispatcher.CheckAccess())
            {
				using (WriterLock)
					base.SetItem(index, item);
            }
            else
            {
                object[] e = new object[] { index, item };
                _dispatcher.Invoke(DispatcherPriority.DataBind, (SendOrPostCallback)delegate { SetItemImpl(e); },e);
            }
        }

        void SetItemImpl(object[] e)
        {
            if (_dispatcher.CheckAccess())
            {
                SetItem((int)e[0],(T)e[1]);
            }
            else
            {
                _dispatcher.Invoke(DispatcherPriority.DataBind, (SendOrPostCallback)delegate { SetItemImpl(e); });
            }
        }

		#region Locking implementation

		public void AcquireReaderLock()
		{
			_lock.EnterReadLock();
		}

		public void ReleaseReaderLock()
		{
			_lock.ExitReadLock();
		}

		public void AcquireWriterLock()
		{
			_lock.EnterWriteLock();
		}

		public void ReleaseWriterLock()
		{
			_lock.ExitWriteLock();
		}

		public ReaderLock ReaderLock
		{
			get
			{
				return new ReaderLock(this);
			}
		}

		internal WriterLock WriterLock
		{
			get
			{
				return new WriterLock(this);
			}
		}

		#endregion
	}
}


text:
var mows = require('../../index'),
  fs = require('fs');

var clientHandler = function (client) {

  var self = this;

  if (!self.clients) self.clients = {};

  client.on('connect', function (packet) {
    console.log('Connect')
    client.connack({returnCode: 0});
    client.id = packet.clientId;
    self.clients[client.id] = client;
  });

  client.on('publish', function (packet) {
    console.log('Publish')
    for (var k in self.clients) {
      self.clients[k].publish({topic: packet.topic, payload: packet.payload});
    }
  });

  client.on('subscribe', function (packet) {
    var granted = [];
    for (var i = 0; i < packet.subscriptions.length; i++) {
      granted.push(packet.subscriptions[i].qos);
    }

    client.suback({granted: granted, messageId: packet.messageId});
  });

  client.on('pingreq', function (packet) {
    client.pingresp();
  });

  client.on('disconnect', function (packet) {
    console.log('disconnect')
    client.stream.end();
  });

  client.on('close', function (err) {
    delete self.clients[client.id];
  });

  client.on('error', function (err) {
    client.stream.end();
    console.log('error!');
  });
}

var secureOpts =
{
  key: fs.readFileSync('../cert/94456535-localhost.key'),
  cert: fs.readFileSync('../cert/94456535-localhost.cert')
}

// Create an unsecure MQTT websocket server
var unsecureServer = mows.createServer(clientHandler).listen(665);

// Create a secure MQTTT websocket server
var secureServer = mows.createSecureServer(secureOpts, clientHandler).listen(666);

console.log('Listening for MQTT websocket connections on ports 666 (secure) and 665 (unsecure)');


text:
<!DOCTYPE html>

  <meta charset="utf-8">

  <title>Archives | 找鱼之家</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="description">
<meta property="og:type" content="website">
<meta property="og:title" content="找鱼之家">
<meta property="og:url" content="http://jinzhaoyu.github.io/archives/index.html">
<meta property="og:site_name" content="找鱼之家">
<meta property="og:description">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="找鱼之家">
<meta name="twitter:description">

    <link rel="alternative" href="/atom.xml" title="找鱼之家" type="application/atom+xml">

    <link rel="icon" href="/favicon.png">

  <link href="//fonts.googleapis.com/css?family=Source+Code+Pro" rel="stylesheet" type="text/css">
  <link rel="stylesheet" href="/css/style.css" type="text/css">

        找鱼之家

          Hey , I am zhaoyu ~

          Home

          Archives

        <form action="//google.com/search" method="get" accept-charset="UTF-8" class="search-form"><input type="search" name="q" results="0" class="search-form-input" placeholder="Search"><button type="submit" class="search-form-submit"></button><input type="hidden" name="sitesearch" value="http://jinzhaoyu.github.io"></form>

          2015

  <time datetime="2015-11-17T12:27:39.000Z" itemprop="datePublished">Nov 17</time>

      Android - 支持multidex后NoClassDefFoundError的解决办法

  <time datetime="2015-11-17T12:27:10.000Z" itemprop="datePublished">Nov 17</time>

      Android - 琢磨隐藏前台服务的过程-隐藏的!

  <time datetime="2015-11-17T12:25:23.000Z" itemprop="datePublished">Nov 17</time>

      Android - AppCompat-v7包踩坑记:活动菜单

Tags

Android AppCompat 菜单1

Android multidex NoClassDefFoundError1

Android 前台服务 隐藏1

Tag Cloud

      Android AppCompat 菜单 Android multidex NoClassDefFoundError Android 前台服务 隐藏

Archives

November 20153

Recents

            Android - 支持multidex后NoClassDefFoundError的解决办法

            Android - 琢磨隐藏前台服务的过程-隐藏的!

            Android - AppCompat-v7包踩坑记:活动菜单

      © 2015 jinzhaoyu

      Powered by Hexo

    Home

    Archives

  <link rel="stylesheet" href="/fancybox/jquery.fancybox.css" type="text/css">


text:
package array

import (
	"sync/atomic"

	"github.com/apache/arrow/go/arrow"
	"github.com/apache/arrow/go/arrow/internal/bitutil"
	"github.com/apache/arrow/go/arrow/internal/debug"
	"github.com/apache/arrow/go/arrow/memory"
)

type Int64Builder struct {
	builder

	data    *memory.Buffer
	rawData []int64
}

func NewInt64Builder(mem memory.Allocator) *Int64Builder {
	return &Int64Builder{builder: builder{refCount: 1, mem: mem}}
}

// Release decreases the reference count by 1.
// When the reference count goes to zero, the memory is freed.
func (b *Int64Builder) Release() {
	debug.Assert(atomic.LoadInt64(&b.refCount) > 0, "too many releases")

	if atomic.AddInt64(&b.refCount, -1) == 0 {
		if b.nullBitmap != nil {
			b.nullBitmap.Release()
			b.nullBitmap = nil
		}
		if b.data != nil {
			b.data.Release()
			b.data = nil
			b.rawData = nil
		}
	}
}

func (b *Int64Builder) Append(v int64) {
	b.Reserve(1)
	b.UnsafeAppend(v)
}

func (b *Int64Builder) AppendNull() {
	b.Reserve(1)
	b.UnsafeAppendBoolToBitmap(false)
}

func (b *Int64Builder) UnsafeAppend(v int64) {
	bitutil.SetBit(b.nullBitmap.Bytes(), b.length)
	b.rawData[b.length] = v
	b.length++
}

func (b *Int64Builder) UnsafeAppendBoolToBitmap(isValid bool) {
	if isValid {
		bitutil.SetBit(b.nullBitmap.Bytes(), b.length)
	} else {
		b.nulls++
	}
	b.length++
}

// AppendValues will append the values in the v slice. The valid slice determines which values
// in v are valid (not null). The valid slice must either be empty or be equal in length to v. If empty,
// all values in v are appended and considered valid.
func (b *Int64Builder) AppendValues(v []int64, valid []bool) {
	if len(v) != len(valid) && len(valid) != 0 {
		panic("len(v) != len(valid) && len(valid) != 0")
	}

	b.Reserve(len(v))
	if len(v) > 0 {
		arrow.Int64Traits.Copy(b.rawData[b.length:], v)
	}
	b.builder.unsafeAppendBoolsToBitmap(valid, len(v))
}

func (b *Int64Builder) init(capacity int) {
	b.builder.init(capacity)

	b.data = memory.NewResizableBuffer(b.mem)
	bytesN := arrow.Int64Traits.BytesRequired(capacity)
	b.data.Resize(bytesN)
	b.rawData = arrow.Int64Traits.CastFromBytes(b.data.Bytes())
}

// Reserve ensures there is enough space for appending n elements
// by checking the capacity and calling Resize if necessary.
func (b *Int64Builder) Reserve(n int) {
	b.builder.reserve(n, b.Resize)
}

// Resize adjusts the space allocated by b to n elements. If n is greater than b.Cap(),
// additional memory will be allocated. If n is smaller, the allocated memory may reduced.
func (b *Int64Builder) Resize(n int) {
	nBuilder := n
	if n < minBuilderCapacity {
		n = minBuilderCapacity
	}

	if b.capacity == 0 {
		b.init(n)
	} else {
		b.builder.resize(nBuilder, b.init)
		b.data.Resize(arrow.Int64Traits.BytesRequired(n))
		b.rawData = arrow.Int64Traits.CastFromBytes(b.data.Bytes())
	}
}

// NewArray creates a Int64 array from the memory buffers used by the builder and resets the Int64Builder
// so it can be used to build a new array.
func (b *Int64Builder) NewArray() Interface {
	return b.NewInt64Array()
}

// NewInt64Array creates a Int64 array from the memory buffers used by the builder and resets the Int64Builder
// so it can be used to build a new array.
func (b *Int64Builder) NewInt64Array() (a *Int64) {
	data := b.newData()
	a = NewInt64Data(data)
	data.Release()
	return
}

func (b *Int64Builder) newData() (data *Data) {
	bytesRequired := arrow.Int64Traits.BytesRequired(b.length)
	if bytesRequired > 0 && bytesRequired < b.data.Len() {
		// trim buffers
		b.data.Resize(bytesRequired)
	}
	data = NewData(arrow.PrimitiveTypes.Int64, b.length, []*memory.Buffer{b.nullBitmap, b.data}, nil, b.nulls, 0)
	b.reset()

	if b.data != nil {
		b.data.Release()
		b.data = nil
		b.rawData = nil
	}

	return
}

type Uint64Builder struct {
	builder

	data    *memory.Buffer
	rawData []uint64
}

func NewUint64Builder(mem memory.Allocator) *Uint64Builder {
	return &Uint64Builder{builder: builder{refCount: 1, mem: mem}}
}

// Release decreases the reference count by 1.
// When the reference count goes to zero, the memory is freed.
func (b *Uint64Builder) Release() {
	debug.Assert(atomic.LoadInt64(&b.refCount) > 0, "too many releases")

	if atomic.AddInt64(&b.refCount, -1) == 0 {
		if b.nullBitmap != nil {
			b.nullBitmap.Release()
			b.nullBitmap = nil
		}
		if b.data != nil {
			b.data.Release()
			b.data = nil
			b.rawData = nil
		}
	}
}

func (b *Uint64Builder) Append(v uint64) {
	b.Reserve(1)
	b.UnsafeAppend(v)
}

func (b *Uint64Builder) AppendNull() {
	b.Reserve(1)
	b.UnsafeAppendBoolToBitmap(false)
}

func (b *Uint64Builder) UnsafeAppend(v uint64) {
	bitutil.SetBit(b.nullBitmap.Bytes(), b.length)
	b.rawData[b.length] = v
	b.length++
}

func (b *Uint64Builder) UnsafeAppendBoolToBitmap(isValid bool) {
	if isValid {
		bitutil.SetBit(b.nullBitmap.Bytes(), b.length)
	} else {
		b.nulls++
	}
	b.length++
}

// AppendValues will append the values in the v slice. The valid slice determines which values
// in v are valid (not null). The valid slice must either be empty or be equal in length to v. If empty,
// all values in v are appended and considered valid.
func (b *Uint64Builder) AppendValues(v []uint64, valid []bool) {
	if len(v) != len(valid) && len(valid) != 0 {
		panic("len(v) != len(valid) && len(valid) != 0")
	}

	b.Reserve(len(v))
	if len(v) > 0 {
		arrow.Uint64Traits.Copy(b.rawData[b.length:], v)
	}
	b.builder.unsafeAppendBoolsToBitmap(valid, len(v))
}

func (b *Uint64Builder) init(capacity int) {
	b.builder.init(capacity)

	b.data = memory.NewResizableBuffer(b.mem)
	bytesN := arrow.Uint64Traits.BytesRequired(capacity)
	b.data.Resize(bytesN)
	b.rawData = arrow.Uint64Traits.CastFromBytes(b.data.Bytes())
}

// Reserve ensures there is enough space for appending n elements
// by checking the capacity and calling Resize if necessary.
func (b *Uint64Builder) Reserve(n int) {
	b.builder.reserve(n, b.Resize)
}

// Resize adjusts the space allocated by b to n elements. If n is greater than b.Cap(),
// additional memory will be allocated. If n is smaller, the allocated memory may reduced.
func (b *Uint64Builder) Resize(n int) {
	nBuilder := n
	if n < minBuilderCapacity {
		n = minBuilderCapacity
	}

	if b.capacity == 0 {
		b.init(n)
	} else {
		b.builder.resize(nBuilder, b.init)
		b.data.Resize(arrow.Uint64Traits.BytesRequired(n))
		b.rawData = arrow.Uint64Traits.CastFromBytes(b.data.Bytes())
	}
}

// NewArray creates a Uint64 array from the memory buffers used by the builder and resets the Uint64Builder
// so it can be used to build a new array.
func (b *Uint64Builder) NewArray() Interface {
	return b.NewUint64Array()
}

// NewUint64Array creates a Uint64 array from the memory buffers used by the builder and resets the Uint64Builder
// so it can be used to build a new array.
func (b *Uint64Builder) NewUint64Array() (a *Uint64) {
	data := b.newData()
	a = NewUint64Data(data)
	data.Release()
	return
}

func (b *Uint64Builder) newData() (data *Data) {
	bytesRequired := arrow.Uint64Traits.BytesRequired(b.length)
	if bytesRequired > 0 && bytesRequired < b.data.Len() {
		// trim buffers
		b.data.Resize(bytesRequired)
	}
	data = NewData(arrow.PrimitiveTypes.Uint64, b.length, []*memory.Buffer{b.nullBitmap, b.data}, nil, b.nulls, 0)
	b.reset()

	if b.data != nil {
		b.data.Release()
		b.data = nil
		b.rawData = nil
	}

	return
}

type Float64Builder struct {
	builder

	data    *memory.Buffer
	rawData []float64
}

func NewFloat64Builder(mem memory.Allocator) *Float64Builder {
	return &Float64Builder{builder: builder{refCount: 1, mem: mem}}
}

// Release decreases the reference count by 1.
// When the reference count goes to zero, the memory is freed.
func (b *Float64Builder) Release() {
	debug.Assert(atomic.LoadInt64(&b.refCount) > 0, "too many releases")

	if atomic.AddInt64(&b.refCount, -1) == 0 {
		if b.nullBitmap != nil {
			b.nullBitmap.Release()
			b.nullBitmap = nil
		}
		if b.data != nil {
			b.data.Release()
			b.data = nil
			b.rawData = nil
		}
	}
}

func (b *Float64Builder) Append(v float64) {
	b.Reserve(1)
	b.UnsafeAppend(v)
}

func (b *Float64Builder) AppendNull() {
	b.Reserve(1)
	b.UnsafeAppendBoolToBitmap(false)
}

func (b *Float64Builder) UnsafeAppend(v float64) {
	bitutil.SetBit(b.nullBitmap.Bytes(), b.length)
	b.rawData[b.length] = v
	b.length++
}

func (b *Float64Builder) UnsafeAppendBoolToBitmap(isValid bool) {
	if isValid {
		bitutil.SetBit(b.nullBitmap.Bytes(), b.length)
	} else {
		b.nulls++
	}
	b.length++
}

// AppendValues will append the values in the v slice. The valid slice determines which values
// in v are valid (not null). The valid slice must either be empty or be equal in length to v. If empty,
// all values in v are appended and considered valid.
func (b *Float64Builder) AppendValues(v []float64, valid []bool) {
	if len(v) != len(valid) && len(valid) != 0 {
		panic("len(v) != len(valid) && len(valid) != 0")
	}

	b.Reserve(len(v))
	if len(v) > 0 {
		arrow.Float64Traits.Copy(b.rawData[b.length:], v)
	}
	b.builder.unsafeAppendBoolsToBitmap(valid, len(v))
}

func (b *Float64Builder) init(capacity int) {
	b.builder.init(capacity)

	b.data = memory.NewResizableBuffer(b.mem)
	bytesN := arrow.Float64Traits.BytesRequired(capacity)
	b.data.Resize(bytesN)
	b.rawData = arrow.Float64Traits.CastFromBytes(b.data.Bytes())
}

// Reserve ensures there is enough space for appending n elements
// by checking the capacity and calling Resize if necessary.
func (b *Float64Builder) Reserve(n int) {
	b.builder.reserve(n, b.Resize)
}

// Resize adjusts the space allocated by b to n elements. If n is greater than b.Cap(),
// additional memory will be allocated. If n is smaller, the allocated memory may reduced.
func (b *Float64Builder) Resize(n int) {
	nBuilder := n
	if n < minBuilderCapacity {
		n = minBuilderCapacity
	}

	if b.capacity == 0 {
		b.init(n)
	} else {
		b.builder.resize(nBuilder, b.init)
		b.data.Resize(arrow.Float64Traits.BytesRequired(n))
		b.rawData = arrow.Float64Traits.CastFromBytes(b.data.Bytes())
	}
}

// NewArray creates a Float64 array from the memory buffers used by the builder and resets the Float64Builder
// so it can be used to build a new array.
func (b *Float64Builder) NewArray() Interface {
	return b.NewFloat64Array()
}

// NewFloat64Array creates a Float64 array from the memory buffers used by the builder and resets the Float64Builder
// so it can be used to build a new array.
func (b *Float64Builder) NewFloat64Array() (a *Float64) {
	data := b.newData()
	a = NewFloat64Data(data)
	data.Release()
	return
}

func (b *Float64Builder) newData() (data *Data) {
	bytesRequired := arrow.Float64Traits.BytesRequired(b.length)
	if bytesRequired > 0 && bytesRequired < b.data.Len() {
		// trim buffers
		b.data.Resize(bytesRequired)
	}
	data = NewData(arrow.PrimitiveTypes.Float64, b.length, []*memory.Buffer{b.nullBitmap, b.data}, nil, b.nulls, 0)
	b.reset()

	if b.data != nil {
		b.data.Release()
		b.data = nil
		b.rawData = nil
	}

	return
}

type Int32Builder struct {
	builder

	data    *memory.Buffer
	rawData []int32
}

func NewInt32Builder(mem memory.Allocator) *Int32Builder {
	return &Int32Builder{builder: builder{refCount: 1, mem: mem}}
}

// Release decreases the reference count by 1.
// When the reference count goes to zero, the memory is freed.
func (b *Int32Builder) Release() {
	debug.Assert(atomic.LoadInt64(&b.refCount) > 0, "too many releases")

	if atomic.AddInt64(&b.refCount, -1) == 0 {
		if b.nullBitmap != nil {
			b.nullBitmap.Release()
			b.nullBitmap = nil
		}
		if b.data != nil {
			b.data.Release()
			b.data = nil
			b.rawData = nil
		}
	}
}

func (b *Int32Builder) Append(v int32) {
	b.Reserve(1)
	b.UnsafeAppend(v)
}

func (b *Int32Builder) AppendNull() {
	b.Reserve(1)
	b.UnsafeAppendBoolToBitmap(false)
}

func (b *Int32Builder) UnsafeAppend(v int32) {
	bitutil.SetBit(b.nullBitmap.Bytes(), b.length)
	b.rawData[b.length] = v
	b.length++
}

func (b *Int32Builder) UnsafeAppendBoolToBitmap(isValid bool) {
	if isValid {
		bitutil.SetBit(b.nullBitmap.Bytes(), b.length)
	} else {
		b.nulls++
	}
	b.length++
}

// AppendValues will append the values in the v slice. The valid slice determines which values
// in v are valid (not null). The valid slice must either be empty or be equal in length to v. If empty,
// all values in v are appended and considered valid.
func (b *Int32Builder) AppendValues(v []int32, valid []bool) {
	if len(v) != len(valid) && len(valid) != 0 {
		panic("len(v) != len(valid) && len(valid) != 0")
	}

	b.Reserve(len(v))
	if len(v) > 0 {
		arrow.Int32Traits.Copy(b.rawData[b.length:], v)
	}
	b.builder.unsafeAppendBoolsToBitmap(valid, len(v))
}

func (b *Int32Builder) init(capacity int) {
	b.builder.init(capacity)

	b.data = memory.NewResizableBuffer(b.mem)
	bytesN := arrow.Int32Traits.BytesRequired(capacity)
	b.data.Resize(bytesN)
	b.rawData = arrow.Int32Traits.CastFromBytes(b.data.Bytes())
}

// Reserve ensures there is enough space for appending n elements
// by checking the capacity and calling Resize if necessary.
func (b *Int32Builder) Reserve(n int) {
	b.builder.reserve(n, b.Resize)
}

// Resize adjusts the space allocated by b to n elements. If n is greater than b.Cap(),
// additional memory will be allocated. If n is smaller, the allocated memory may reduced.
func (b *Int32Builder) Resize(n int) {
	nBuilder := n
	if n < minBuilderCapacity {
		n = minBuilderCapacity
	}

	if b.capacity == 0 {
		b.init(n)
	} else {
		b.builder.resize(nBuilder, b.init)
		b.data.Resize(arrow.Int32Traits.BytesRequired(n))
		b.rawData = arrow.Int32Traits.CastFromBytes(b.data.Bytes())
	}
}

// NewArray creates a Int32 array from the memory buffers used by the builder and resets the Int32Builder
// so it can be used to build a new array.
func (b *Int32Builder) NewArray() Interface {
	return b.NewInt32Array()
}

// NewInt32Array creates a Int32 array from the memory buffers used by the builder and resets the Int32Builder
// so it can be used to build a new array.
func (b *Int32Builder) NewInt32Array() (a *Int32) {
	data := b.newData()
	a = NewInt32Data(data)
	data.Release()
	return
}

func (b *Int32Builder) newData() (data *Data) {
	bytesRequired := arrow.Int32Traits.BytesRequired(b.length)
	if bytesRequired > 0 && bytesRequired < b.data.Len() {
		// trim buffers
		b.data.Resize(bytesRequired)
	}
	data = NewData(arrow.PrimitiveTypes.Int32, b.length, []*memory.Buffer{b.nullBitmap, b.data}, nil, b.nulls, 0)
	b.reset()

	if b.data != nil {
		b.data.Release()
		b.data = nil
		b.rawData = nil
	}

	return
}

type Uint32Builder struct {
	builder

	data    *memory.Buffer
	rawData []uint32
}

func NewUint32Builder(mem memory.Allocator) *Uint32Builder {
	return &Uint32Builder{builder: builder{refCount: 1, mem: mem}}
}

// Release decreases the reference count by 1.
// When the reference count goes to zero, the memory is freed.
func (b *Uint32Builder) Release() {
	debug.Assert(atomic.LoadInt64(&b.refCount) > 0, "too many releases")

	if atomic.AddInt64(&b.refCount, -1) == 0 {
		if b.nullBitmap != nil {
			b.nullBitmap.Release()
			b.nullBitmap = nil
		}
		if b.data != nil {
			b.data.Release()
			b.data = nil
			b.rawData = nil
		}
	}
}

func (b *Uint32Builder) Append(v uint32) {
	b.Reserve(1)
	b.UnsafeAppend(v)
}

func (b *Uint32Builder) AppendNull() {
	b.Reserve(1)
	b.UnsafeAppendBoolToBitmap(false)
}

func (b *Uint32Builder) UnsafeAppend(v uint32) {
	bitutil.SetBit(b.nullBitmap.Bytes(), b.length)
	b.rawData[b.length] = v
	b.length++
}

func (b *Uint32Builder) UnsafeAppendBoolToBitmap(isValid bool) {
	if isValid {
		bitutil.SetBit(b.nullBitmap.Bytes(), b.length)
	} else {
		b.nulls++
	}
	b.length++
}

// AppendValues will append the values in the v slice. The valid slice determines which values
// in v are valid (not null). The valid slice must either be empty or be equal in length to v. If empty,
// all values in v are appended and considered valid.
func (b *Uint32Builder) AppendValues(v []uint32, valid []bool) {
	if len(v) != len(valid) && len(valid) != 0 {
		panic("len(v) != len(valid) && len(valid) != 0")
	}

	b.Reserve(len(v))
	if len(v) > 0 {
		arrow.Uint32Traits.Copy(b.rawData[b.length:], v)
	}
	b.builder.unsafeAppendBoolsToBitmap(valid, len(v))
}

func (b *Uint32Builder) init(capacity int) {
	b.builder.init(capacity)

	b.data = memory.NewResizableBuffer(b.mem)
	bytesN := arrow.Uint32Traits.BytesRequired(capacity)
	b.data.Resize(bytesN)
	b.rawData = arrow.Uint32Traits.CastFromBytes(b.data.Bytes())
}

// Reserve ensures there is enough space for appending n elements
// by checking the capacity and calling Resize if necessary.
func (b *Uint32Builder) Reserve(n int) {
	b.builder.reserve(n, b.Resize)
}

// Resize adjusts the space allocated by b to n elements. If n is greater than b.Cap(),
// additional memory will be allocated. If n is smaller, the allocated memory may reduced.
func (b *Uint32Builder) Resize(n int) {
	nBuilder := n
	if n < minBuilderCapacity {
		n = minBuilderCapacity
	}

	if b.capacity == 0 {
		b.init(n)
	} else {
		b.builder.resize(nBuilder, b.init)
		b.data.Resize(arrow.Uint32Traits.BytesRequired(n))
		b.rawData = arrow.Uint32Traits.CastFromBytes(b.data.Bytes())
	}
}

// NewArray creates a Uint32 array from the memory buffers used by the builder and resets the Uint32Builder
// so it can be used to build a new array.
func (b *Uint32Builder) NewArray() Interface {
	return b.NewUint32Array()
}

// NewUint32Array creates a Uint32 array from the memory buffers used by the builder and resets the Uint32Builder
// so it can be used to build a new array.
func (b *Uint32Builder) NewUint32Array() (a *Uint32) {
	data := b.newData()
	a = NewUint32Data(data)
	data.Release()
	return
}

func (b *Uint32Builder) newData() (data *Data) {
	bytesRequired := arrow.Uint32Traits.BytesRequired(b.length)
	if bytesRequired > 0 && bytesRequired < b.data.Len() {
		// trim buffers
		b.data.Resize(bytesRequired)
	}
	data = NewData(arrow.PrimitiveTypes.Uint32, b.length, []*memory.Buffer{b.nullBitmap, b.data}, nil, b.nulls, 0)
	b.reset()

	if b.data != nil {
		b.data.Release()
		b.data = nil
		b.rawData = nil
	}

	return
}

type Float32Builder struct {
	builder

	data    *memory.Buffer
	rawData []float32
}

func NewFloat32Builder(mem memory.Allocator) *Float32Builder {
	return &Float32Builder{builder: builder{refCount: 1, mem: mem}}
}

// Release decreases the reference count by 1.
// When the reference count goes to zero, the memory is freed.
func (b *Float32Builder) Release() {
	debug.Assert(atomic.LoadInt64(&b.refCount) > 0, "too many releases")

	if atomic.AddInt64(&b.refCount, -1) == 0 {
		if b.nullBitmap != nil {
			b.nullBitmap.Release()
			b.nullBitmap = nil
		}
		if b.data != nil {
			b.data.Release()
			b.data = nil
			b.rawData = nil
		}
	}
}

func (b *Float32Builder) Append(v float32) {
	b.Reserve(1)
	b.UnsafeAppend(v)
}

func (b *Float32Builder) AppendNull() {
	b.Reserve(1)
	b.UnsafeAppendBoolToBitmap(false)
}

func (b *Float32Builder) UnsafeAppend(v float32) {
	bitutil.SetBit(b.nullBitmap.Bytes(), b.length)
	b.rawData[b.length] = v
	b.length++
}

func (b *Float32Builder) UnsafeAppendBoolToBitmap(isValid bool) {
	if isValid {
		bitutil.SetBit(b.nullBitmap.Bytes(), b.length)
	} else {
		b.nulls++
	}
	b.length++
}

// AppendValues will append the values in the v slice. The valid slice determines which values
// in v are valid (not null). The valid slice must either be empty or be equal in length to v. If empty,
// all values in v are appended and considered valid.
func (b *Float32Builder) AppendValues(v []float32, valid []bool) {
	if len(v) != len(valid) && len(valid) != 0 {
		panic("len(v) != len(valid) && len(valid) != 0")
	}

	b.Reserve(len(v))
	if len(v) > 0 {
		arrow.Float32Traits.Copy(b.rawData[b.length:], v)
	}
	b.builder.unsafeAppendBoolsToBitmap(valid, len(v))
}

func (b *Float32Builder) init(capacity int) {
	b.builder.init(capacity)

	b.data = memory.NewResizableBuffer(b.mem)
	bytesN := arrow.Float32Traits.BytesRequired(capacity)
	b.data.Resize(bytesN)
	b.rawData = arrow.Float32Traits.CastFromBytes(b.data.Bytes())
}

// Reserve ensures there is enough space for appending n elements
// by checking the capacity and calling Resize if necessary.
func (b *Float32Builder) Reserve(n int) {
	b.builder.reserve(n, b.Resize)
}

// Resize adjusts the space allocated by b to n elements. If n is greater than b.Cap(),
// additional memory will be allocated. If n is smaller, the allocated memory may reduced.
func (b *Float32Builder) Resize(n int) {
	nBuilder := n
	if n < minBuilderCapacity {
		n = minBuilderCapacity
	}

	if b.capacity == 0 {
		b.init(n)
	} else {
		b.builder.resize(nBuilder, b.init)
		b.data.Resize(arrow.Float32Traits.BytesRequired(n))
		b.rawData = arrow.Float32Traits.CastFromBytes(b.data.Bytes())
	}
}

// NewArray creates a Float32 array from the memory buffers used by the builder and resets the Float32Builder
// so it can be used to build a new array.
func (b *Float32Builder) NewArray() Interface {
	return b.NewFloat32Array()
}

// NewFloat32Array creates a Float32 array from the memory buffers used by the builder and resets the Float32Builder
// so it can be used to build a new array.
func (b *Float32Builder) NewFloat32Array() (a *Float32) {
	data := b.newData()
	a = NewFloat32Data(data)
	data.Release()
	return
}

func (b *Float32Builder) newData() (data *Data) {
	bytesRequired := arrow.Float32Traits.BytesRequired(b.length)
	if bytesRequired > 0 && bytesRequired < b.data.Len() {
		// trim buffers
		b.data.Resize(bytesRequired)
	}
	data = NewData(arrow.PrimitiveTypes.Float32, b.length, []*memory.Buffer{b.nullBitmap, b.data}, nil, b.nulls, 0)
	b.reset()

	if b.data != nil {
		b.data.Release()
		b.data = nil
		b.rawData = nil
	}

	return
}

type Int16Builder struct {
	builder

	data    *memory.Buffer
	rawData []int16
}

func NewInt16Builder(mem memory.Allocator) *Int16Builder {
	return &Int16Builder{builder: builder{refCount: 1, mem: mem}}
}

// Release decreases the reference count by 1.
// When the reference count goes to zero, the memory is freed.
func (b *Int16Builder) Release() {
	debug.Assert(atomic.LoadInt64(&b.refCount) > 0, "too many releases")

	if atomic.AddInt64(&b.refCount, -1) == 0 {
		if b.nullBitmap != nil {
			b.nullBitmap.Release()
			b.nullBitmap = nil
		}
		if b.data != nil {
			b.data.Release()
			b.data = nil
			b.rawData = nil
		}
	}
}

func (b *Int16Builder) Append(v int16) {
	b.Reserve(1)
	b.UnsafeAppend(v)
}

func (b *Int16Builder) AppendNull() {
	b.Reserve(1)
	b.UnsafeAppendBoolToBitmap(false)
}

func (b *Int16Builder) UnsafeAppend(v int16) {
	bitutil.SetBit(b.nullBitmap.Bytes(), b.length)
	b.rawData[b.length] = v
	b.length++
}

func (b *Int16Builder) UnsafeAppendBoolToBitmap(isValid bool) {
	if isValid {
		bitutil.SetBit(b.nullBitmap.Bytes(), b.length)
	} else {
		b.nulls++
	}
	b.length++
}

// AppendValues will append the values in the v slice. The valid slice determines which values
// in v are valid (not null). The valid slice must either be empty or be equal in length to v. If empty,
// all values in v are appended and considered valid.
func (b *Int16Builder) AppendValues(v []int16, valid []bool) {
	if len(v) != len(valid) && len(valid) != 0 {
		panic("len(v) != len(valid) && len(valid) != 0")
	}

	b.Reserve(len(v))
	if len(v) > 0 {
		arrow.Int16Traits.Copy(b.rawData[b.length:], v)
	}
	b.builder.unsafeAppendBoolsToBitmap(valid, len(v))
}

func (b *Int16Builder) init(capacity int) {
	b.builder.init(capacity)

	b.data = memory.NewResizableBuffer(b.mem)
	bytesN := arrow.Int16Traits.BytesRequired(capacity)
	b.data.Resize(bytesN)
	b.rawData = arrow.Int16Traits.CastFromBytes(b.data.Bytes())
}

// Reserve ensures there is enough space for appending n elements
// by checking the capacity and calling Resize if necessary.
func (b *Int16Builder) Reserve(n int) {
	b.builder.reserve(n, b.Resize)
}

// Resize adjusts the space allocated by b to n elements. If n is greater than b.Cap(),
// additional memory will be allocated. If n is smaller, the allocated memory may reduced.
func (b *Int16Builder) Resize(n int) {
	nBuilder := n
	if n < minBuilderCapacity {
		n = minBuilderCapacity
	}

	if b.capacity == 0 {
		b.init(n)
	} else {
		b.builder.resize(nBuilder, b.init)
		b.data.Resize(arrow.Int16Traits.BytesRequired(n))
		b.rawData = arrow.Int16Traits.CastFromBytes(b.data.Bytes())
	}
}

// NewArray creates a Int16 array from the memory buffers used by the builder and resets the Int16Builder
// so it can be used to build a new array.
func (b *Int16Builder) NewArray() Interface {
	return b.NewInt16Array()
}

// NewInt16Array creates a Int16 array from the memory buffers used by the builder and resets the Int16Builder
// so it can be used to build a new array.
func (b *Int16Builder) NewInt16Array() (a *Int16) {
	data := b.newData()
	a = NewInt16Data(data)
	data.Release()
	return
}

func (b *Int16Builder) newData() (data *Data) {
	bytesRequired := arrow.Int16Traits.BytesRequired(b.length)
	if bytesRequired > 0 && bytesRequired < b.data.Len() {
		// trim buffers
		b.data.Resize(bytesRequired)
	}
	data = NewData(arrow.PrimitiveTypes.Int16, b.length, []*memory.Buffer{b.nullBitmap, b.data}, nil, b.nulls, 0)
	b.reset()

	if b.data != nil {
		b.data.Release()
		b.data = nil
		b.rawData = nil
	}

	return
}

type Uint16Builder struct {
	builder

	data    *memory.Buffer
	rawData []uint16
}

func NewUint16Builder(mem memory.Allocator) *Uint16Builder {
	return &Uint16Builder{builder: builder{refCount: 1, mem: mem}}
}

// Release decreases the reference count by 1.
// When the reference count goes to zero, the memory is freed.
func (b *Uint16Builder) Release() {
	debug.Assert(atomic.LoadInt64(&b.refCount) > 0, "too many releases")

	if atomic.AddInt64(&b.refCount, -1) == 0 {
		if b.nullBitmap != nil {
			b.nullBitmap.Release()
			b.nullBitmap = nil
		}
		if b.data != nil {
			b.data.Release()
			b.data = nil
			b.rawData = nil
		}
	}
}

func (b *Uint16Builder) Append(v uint16) {
	b.Reserve(1)
	b.UnsafeAppend(v)
}

func (b *Uint16Builder) AppendNull() {
	b.Reserve(1)
	b.UnsafeAppendBoolToBitmap(false)
}

func (b *Uint16Builder) UnsafeAppend(v uint16) {
	bitutil.SetBit(b.nullBitmap.Bytes(), b.length)
	b.rawData[b.length] = v
	b.length++
}

func (b *Uint16Builder) UnsafeAppendBoolToBitmap(isValid bool) {
	if isValid {
		bitutil.SetBit(b.nullBitmap.Bytes(), b.length)
	} else {
		b.nulls++
	}
	b.length++
}

// AppendValues will append the values in the v slice. The valid slice determines which values
// in v are valid (not null). The valid slice must either be empty or be equal in length to v. If empty,
// all values in v are appended and considered valid.
func (b *Uint16Builder) AppendValues(v []uint16, valid []bool) {
	if len(v) != len(valid) && len(valid) != 0 {
		panic("len(v) != len(valid) && len(valid) != 0")
	}

	b.Reserve(len(v))
	if len(v) > 0 {
		arrow.Uint16Traits.Copy(b.rawData[b.length:], v)
	}
	b.builder.unsafeAppendBoolsToBitmap(valid, len(v))
}

func (b *Uint16Builder) init(capacity int) {
	b.builder.init(capacity)

	b.data = memory.NewResizableBuffer(b.mem)
	bytesN := arrow.Uint16Traits.BytesRequired(capacity)
	b.data.Resize(bytesN)
	b.rawData = arrow.Uint16Traits.CastFromBytes(b.data.Bytes())
}

// Reserve ensures there is enough space for appending n elements
// by checking the capacity and calling Resize if necessary.
func (b *Uint16Builder) Reserve(n int) {
	b.builder.reserve(n, b.Resize)
}

// Resize adjusts the space allocated by b to n elements. If n is greater than b.Cap(),
// additional memory will be allocated. If n is smaller, the allocated memory may reduced.
func (b *Uint16Builder) Resize(n int) {
	nBuilder := n
	if n < minBuilderCapacity {
		n = minBuilderCapacity
	}

	if b.capacity == 0 {
		b.init(n)
	} else {
		b.builder.resize(nBuilder, b.init)
		b.data.Resize(arrow.Uint16Traits.BytesRequired(n))
		b.rawData = arrow.Uint16Traits.CastFromBytes(b.data.Bytes())
	}
}

// NewArray creates a Uint16 array from the memory buffers used by the builder and resets the Uint16Builder
// so it can be used to build a new array.
func (b *Uint16Builder) NewArray() Interface {
	return b.NewUint16Array()
}

// NewUint16Array creates a Uint16 array from the memory buffers used by the builder and resets the Uint16Builder
// so it can be used to build a new array.
func (b *Uint16Builder) NewUint16Array() (a *Uint16) {
	data := b.newData()
	a = NewUint16Data(data)
	data.Release()
	return
}

func (b *Uint16Builder) newData() (data *Data) {
	bytesRequired := arrow.Uint16Traits.BytesRequired(b.length)
	if bytesRequired > 0 && bytesRequired < b.data.Len() {
		// trim buffers
		b.data.Resize(bytesRequired)
	}
	data = NewData(arrow.PrimitiveTypes.Uint16, b.length, []*memory.Buffer{b.nullBitmap, b.data}, nil, b.nulls, 0)
	b.reset()

	if b.data != nil {
		b.data.Release()
		b.data = nil
		b.rawData = nil
	}

	return
}

type Int8Builder struct {
	builder

	data    *memory.Buffer
	rawData []int8
}

func NewInt8Builder(mem memory.Allocator) *Int8Builder {
	return &Int8Builder{builder: builder{refCount: 1, mem: mem}}
}

// Release decreases the reference count by 1.
// When the reference count goes to zero, the memory is freed.
func (b *Int8Builder) Release() {
	debug.Assert(atomic.LoadInt64(&b.refCount) > 0, "too many releases")

	if atomic.AddInt64(&b.refCount, -1) == 0 {
		if b.nullBitmap != nil {
			b.nullBitmap.Release()
			b.nullBitmap = nil
		}
		if b.data != nil {
			b.data.Release()
			b.data = nil
			b.rawData = nil
		}
	}
}

func (b *Int8Builder) Append(v int8) {
	b.Reserve(1)
	b.UnsafeAppend(v)
}

func (b *Int8Builder) AppendNull() {
	b.Reserve(1)
	b.UnsafeAppendBoolToBitmap(false)
}

func (b *Int8Builder) UnsafeAppend(v int8) {
	bitutil.SetBit(b.nullBitmap.Bytes(), b.length)
	b.rawData[b.length] = v
	b.length++
}

func (b *Int8Builder) UnsafeAppendBoolToBitmap(isValid bool) {
	if isValid {
		bitutil.SetBit(b.nullBitmap.Bytes(), b.length)
	} else {
		b.nulls++
	}
	b.length++
}

// AppendValues will append the values in the v slice. The valid slice determines which values
// in v are valid (not null). The valid slice must either be empty or be equal in length to v. If empty,
// all values in v are appended and considered valid.
func (b *Int8Builder) AppendValues(v []int8, valid []bool) {
	if len(v) != len(valid) && len(valid) != 0 {
		panic("len(v) != len(valid) && len(valid) != 0")
	}

	b.Reserve(len(v))
	if len(v) > 0 {
		arrow.Int8Traits.Copy(b.rawData[b.length:], v)
	}
	b.builder.unsafeAppendBoolsToBitmap(valid, len(v))
}

func (b *Int8Builder) init(capacity int) {
	b.builder.init(capacity)

	b.data = memory.NewResizableBuffer(b.mem)
	bytesN := arrow.Int8Traits.BytesRequired(capacity)
	b.data.Resize(bytesN)
	b.rawData = arrow.Int8Traits.CastFromBytes(b.data.Bytes())
}

// Reserve ensures there is enough space for appending n elements
// by checking the capacity and calling Resize if necessary.
func (b *Int8Builder) Reserve(n int) {
	b.builder.reserve(n, b.Resize)
}

// Resize adjusts the space allocated by b to n elements. If n is greater than b.Cap(),
// additional memory will be allocated. If n is smaller, the allocated memory may reduced.
func (b *Int8Builder) Resize(n int) {
	nBuilder := n
	if n < minBuilderCapacity {
		n = minBuilderCapacity
	}

	if b.capacity == 0 {
		b.init(n)
	} else {
		b.builder.resize(nBuilder, b.init)
		b.data.Resize(arrow.Int8Traits.BytesRequired(n))
		b.rawData = arrow.Int8Traits.CastFromBytes(b.data.Bytes())
	}
}

// NewArray creates a Int8 array from the memory buffers used by the builder and resets the Int8Builder
// so it can be used to build a new array.
func (b *Int8Builder) NewArray() Interface {
	return b.NewInt8Array()
}

// NewInt8Array creates a Int8 array from the memory buffers used by the builder and resets the Int8Builder
// so it can be used to build a new array.
func (b *Int8Builder) NewInt8Array() (a *Int8) {
	data := b.newData()
	a = NewInt8Data(data)
	data.Release()
	return
}

func (b *Int8Builder) newData() (data *Data) {
	bytesRequired := arrow.Int8Traits.BytesRequired(b.length)
	if bytesRequired > 0 && bytesRequired < b.data.Len() {
		// trim buffers
		b.data.Resize(bytesRequired)
	}
	data = NewData(arrow.PrimitiveTypes.Int8, b.length, []*memory.Buffer{b.nullBitmap, b.data}, nil, b.nulls, 0)
	b.reset()

	if b.data != nil {
		b.data.Release()
		b.data = nil
		b.rawData = nil
	}

	return
}

type Uint8Builder struct {
	builder

	data    *memory.Buffer
	rawData []uint8
}

func NewUint8Builder(mem memory.Allocator) *Uint8Builder {
	return &Uint8Builder{builder: builder{refCount: 1, mem: mem}}
}

// Release decreases the reference count by 1.
// When the reference count goes to zero, the memory is freed.
func (b *Uint8Builder) Release() {
	debug.Assert(atomic.LoadInt64(&b.refCount) > 0, "too many releases")

	if atomic.AddInt64(&b.refCount, -1) == 0 {
		if b.nullBitmap != nil {
			b.nullBitmap.Release()
			b.nullBitmap = nil
		}
		if b.data != nil {
			b.data.Release()
			b.data = nil
			b.rawData = nil
		}
	}
}

func (b *Uint8Builder) Append(v uint8) {
	b.Reserve(1)
	b.UnsafeAppend(v)
}

func (b *Uint8Builder) AppendNull() {
	b.Reserve(1)
	b.UnsafeAppendBoolToBitmap(false)
}

func (b *Uint8Builder) UnsafeAppend(v uint8) {
	bitutil.SetBit(b.nullBitmap.Bytes(), b.length)
	b.rawData[b.length] = v
	b.length++
}

func (b *Uint8Builder) UnsafeAppendBoolToBitmap(isValid bool) {
	if isValid {
		bitutil.SetBit(b.nullBitmap.Bytes(), b.length)
	} else {
		b.nulls++
	}
	b.length++
}

// AppendValues will append the values in the v slice. The valid slice determines which values
// in v are valid (not null). The valid slice must either be empty or be equal in length to v. If empty,
// all values in v are appended and considered valid.
func (b *Uint8Builder) AppendValues(v []uint8, valid []bool) {
	if len(v) != len(valid) && len(valid) != 0 {
		panic("len(v) != len(valid) && len(valid) != 0")
	}

	b.Reserve(len(v))
	if len(v) > 0 {
		arrow.Uint8Traits.Copy(b.rawData[b.length:], v)
	}
	b.builder.unsafeAppendBoolsToBitmap(valid, len(v))
}

func (b *Uint8Builder) init(capacity int) {
	b.builder.init(capacity)

	b.data = memory.NewResizableBuffer(b.mem)
	bytesN := arrow.Uint8Traits.BytesRequired(capacity)
	b.data.Resize(bytesN)
	b.rawData = arrow.Uint8Traits.CastFromBytes(b.data.Bytes())
}

// Reserve ensures there is enough space for appending n elements
// by checking the capacity and calling Resize if necessary.
func (b *Uint8Builder) Reserve(n int) {
	b.builder.reserve(n, b.Resize)
}

// Resize adjusts the space allocated by b to n elements. If n is greater than b.Cap(),
// additional memory will be allocated. If n is smaller, the allocated memory may reduced.
func (b *Uint8Builder) Resize(n int) {
	nBuilder := n
	if n < minBuilderCapacity {
		n = minBuilderCapacity
	}

	if b.capacity == 0 {
		b.init(n)
	} else {
		b.builder.resize(nBuilder, b.init)
		b.data.Resize(arrow.Uint8Traits.BytesRequired(n))
		b.rawData = arrow.Uint8Traits.CastFromBytes(b.data.Bytes())
	}
}

// NewArray creates a Uint8 array from the memory buffers used by the builder and resets the Uint8Builder
// so it can be used to build a new array.
func (b *Uint8Builder) NewArray() Interface {
	return b.NewUint8Array()
}

// NewUint8Array creates a Uint8 array from the memory buffers used by the builder and resets the Uint8Builder
// so it can be used to build a new array.
func (b *Uint8Builder) NewUint8Array() (a *Uint8) {
	data := b.newData()
	a = NewUint8Data(data)
	data.Release()
	return
}

func (b *Uint8Builder) newData() (data *Data) {
	bytesRequired := arrow.Uint8Traits.BytesRequired(b.length)
	if bytesRequired > 0 && bytesRequired < b.data.Len() {
		// trim buffers
		b.data.Resize(bytesRequired)
	}
	data = NewData(arrow.PrimitiveTypes.Uint8, b.length, []*memory.Buffer{b.nullBitmap, b.data}, nil, b.nulls, 0)
	b.reset()

	if b.data != nil {
		b.data.Release()
		b.data = nil
		b.rawData = nil
	}

	return
}

type TimestampBuilder struct {
	builder

	dtype   *arrow.TimestampType
	data    *memory.Buffer
	rawData []arrow.Timestamp
}

func NewTimestampBuilder(mem memory.Allocator, dtype *arrow.TimestampType) *TimestampBuilder {
	return &TimestampBuilder{builder: builder{refCount: 1, mem: mem}, dtype: dtype}
}

// Release decreases the reference count by 1.
// When the reference count goes to zero, the memory is freed.
func (b *TimestampBuilder) Release() {
	debug.Assert(atomic.LoadInt64(&b.refCount) > 0, "too many releases")

	if atomic.AddInt64(&b.refCount, -1) == 0 {
		if b.nullBitmap != nil {
			b.nullBitmap.Release()
			b.nullBitmap = nil
		}
		if b.data != nil {
			b.data.Release()
			b.data = nil
			b.rawData = nil
		}
	}
}

func (b *TimestampBuilder) Append(v arrow.Timestamp) {
	b.Reserve(1)
	b.UnsafeAppend(v)
}

func (b *TimestampBuilder) AppendNull() {
	b.Reserve(1)
	b.UnsafeAppendBoolToBitmap(false)
}

func (b *TimestampBuilder) UnsafeAppend(v arrow.Timestamp) {
	bitutil.SetBit(b.nullBitmap.Bytes(), b.length)
	b.rawData[b.length] = v
	b.length++
}

func (b *TimestampBuilder) UnsafeAppendBoolToBitmap(isValid bool) {
	if isValid {
		bitutil.SetBit(b.nullBitmap.Bytes(), b.length)
	} else {
		b.nulls++
	}
	b.length++
}

// AppendValues will append the values in the v slice. The valid slice determines which values
// in v are valid (not null). The valid slice must either be empty or be equal in length to v. If empty,
// all values in v are appended and considered valid.
func (b *TimestampBuilder) AppendValues(v []arrow.Timestamp, valid []bool) {
	if len(v) != len(valid) && len(valid) != 0 {
		panic("len(v) != len(valid) && len(valid) != 0")
	}

	b.Reserve(len(v))
	if len(v) > 0 {
		arrow.TimestampTraits.Copy(b.rawData[b.length:], v)
	}
	b.builder.unsafeAppendBoolsToBitmap(valid, len(v))
}

func (b *TimestampBuilder) init(capacity int) {
	b.builder.init(capacity)

	b.data = memory.NewResizableBuffer(b.mem)
	bytesN := arrow.TimestampTraits.BytesRequired(capacity)
	b.data.Resize(bytesN)
	b.rawData = arrow.TimestampTraits.CastFromBytes(b.data.Bytes())
}

// Reserve ensures there is enough space for appending n elements
// by checking the capacity and calling Resize if necessary.
func (b *TimestampBuilder) Reserve(n int) {
	b.builder.reserve(n, b.Resize)
}

// Resize adjusts the space allocated by b to n elements. If n is greater than b.Cap(),
// additional memory will be allocated. If n is smaller, the allocated memory may reduced.
func (b *TimestampBuilder) Resize(n int) {
	nBuilder := n
	if n < minBuilderCapacity {
		n = minBuilderCapacity
	}

	if b.capacity == 0 {
		b.init(n)
	} else {
		b.builder.resize(nBuilder, b.init)
		b.data.Resize(arrow.TimestampTraits.BytesRequired(n))
		b.rawData = arrow.TimestampTraits.CastFromBytes(b.data.Bytes())
	}
}

// NewArray creates a Timestamp array from the memory buffers used by the builder and resets the TimestampBuilder
// so it can be used to build a new array.
func (b *TimestampBuilder) NewArray() Interface {
	return b.NewTimestampArray()
}

// NewTimestampArray creates a Timestamp array from the memory buffers used by the builder and resets the TimestampBuilder
// so it can be used to build a new array.
func (b *TimestampBuilder) NewTimestampArray() (a *Timestamp) {
	data := b.newData()
	a = NewTimestampData(data)
	data.Release()
	return
}

func (b *TimestampBuilder) newData() (data *Data) {
	bytesRequired := arrow.TimestampTraits.BytesRequired(b.length)
	if bytesRequired > 0 && bytesRequired < b.data.Len() {
		// trim buffers
		b.data.Resize(bytesRequired)
	}
	data = NewData(b.dtype, b.length, []*memory.Buffer{b.nullBitmap, b.data}, nil, b.nulls, 0)
	b.reset()

	if b.data != nil {
		b.data.Release()
		b.data = nil
		b.rawData = nil
	}

	return
}

type Time32Builder struct {
	builder

	dtype   *arrow.Time32Type
	data    *memory.Buffer
	rawData []arrow.Time32
}

func NewTime32Builder(mem memory.Allocator, dtype *arrow.Time32Type) *Time32Builder {
	return &Time32Builder{builder: builder{refCount: 1, mem: mem}, dtype: dtype}
}

// Release decreases the reference count by 1.
// When the reference count goes to zero, the memory is freed.
func (b *Time32Builder) Release() {
	debug.Assert(atomic.LoadInt64(&b.refCount) > 0, "too many releases")

	if atomic.AddInt64(&b.refCount, -1) == 0 {
		if b.nullBitmap != nil {
			b.nullBitmap.Release()
			b.nullBitmap = nil
		}
		if b.data != nil {
			b.data.Release()
			b.data = nil
			b.rawData = nil
		}
	}
}

func (b *Time32Builder) Append(v arrow.Time32) {
	b.Reserve(1)
	b.UnsafeAppend(v)
}

func (b *Time32Builder) AppendNull() {
	b.Reserve(1)
	b.UnsafeAppendBoolToBitmap(false)
}

func (b *Time32Builder) UnsafeAppend(v arrow.Time32) {
	bitutil.SetBit(b.nullBitmap.Bytes(), b.length)
	b.rawData[b.length] = v
	b.length++
}

func (b *Time32Builder) UnsafeAppendBoolToBitmap(isValid bool) {
	if isValid {
		bitutil.SetBit(b.nullBitmap.Bytes(), b.length)
	} else {
		b.nulls++
	}
	b.length++
}

// AppendValues will append the values in the v slice. The valid slice determines which values
// in v are valid (not null). The valid slice must either be empty or be equal in length to v. If empty,
// all values in v are appended and considered valid.
func (b *Time32Builder) AppendValues(v []arrow.Time32, valid []bool) {
	if len(v) != len(valid) && len(valid) != 0 {
		panic("len(v) != len(valid) && len(valid) != 0")
	}

	b.Reserve(len(v))
	if len(v) > 0 {
		arrow.Time32Traits.Copy(b.rawData[b.length:], v)
	}
	b.builder.unsafeAppendBoolsToBitmap(valid, len(v))
}

func (b *Time32Builder) init(capacity int) {
	b.builder.init(capacity)

	b.data = memory.NewResizableBuffer(b.mem)
	bytesN := arrow.Time32Traits.BytesRequired(capacity)
	b.data.Resize(bytesN)
	b.rawData = arrow.Time32Traits.CastFromBytes(b.data.Bytes())
}

// Reserve ensures there is enough space for appending n elements
// by checking the capacity and calling Resize if necessary.
func (b *Time32Builder) Reserve(n int) {
	b.builder.reserve(n, b.Resize)
}

// Resize adjusts the space allocated by b to n elements. If n is greater than b.Cap(),
// additional memory will be allocated. If n is smaller, the allocated memory may reduced.
func (b *Time32Builder) Resize(n int) {
	nBuilder := n
	if n < minBuilderCapacity {
		n = minBuilderCapacity
	}

	if b.capacity == 0 {
		b.init(n)
	} else {
		b.builder.resize(nBuilder, b.init)
		b.data.Resize(arrow.Time32Traits.BytesRequired(n))
		b.rawData = arrow.Time32Traits.CastFromBytes(b.data.Bytes())
	}
}

// NewArray creates a Time32 array from the memory buffers used by the builder and resets the Time32Builder
// so it can be used to build a new array.
func (b *Time32Builder) NewArray() Interface {
	return b.NewTime32Array()
}

// NewTime32Array creates a Time32 array from the memory buffers used by the builder and resets the Time32Builder
// so it can be used to build a new array.
func (b *Time32Builder) NewTime32Array() (a *Time32) {
	data := b.newData()
	a = NewTime32Data(data)
	data.Release()
	return
}

func (b *Time32Builder) newData() (data *Data) {
	bytesRequired := arrow.Time32Traits.BytesRequired(b.length)
	if bytesRequired > 0 && bytesRequired < b.data.Len() {
		// trim buffers
		b.data.Resize(bytesRequired)
	}
	data = NewData(b.dtype, b.length, []*memory.Buffer{b.nullBitmap, b.data}, nil, b.nulls, 0)
	b.reset()

	if b.data != nil {
		b.data.Release()
		b.data = nil
		b.rawData = nil
	}

	return
}

type Time64Builder struct {
	builder

	dtype   *arrow.Time64Type
	data    *memory.Buffer
	rawData []arrow.Time64
}

func NewTime64Builder(mem memory.Allocator, dtype *arrow.Time64Type) *Time64Builder {
	return &Time64Builder{builder: builder{refCount: 1, mem: mem}, dtype: dtype}
}

// Release decreases the reference count by 1.
// When the reference count goes to zero, the memory is freed.
func (b *Time64Builder) Release() {
	debug.Assert(atomic.LoadInt64(&b.refCount) > 0, "too many releases")

	if atomic.AddInt64(&b.refCount, -1) == 0 {
		if b.nullBitmap != nil {
			b.nullBitmap.Release()
			b.nullBitmap = nil
		}
		if b.data != nil {
			b.data.Release()
			b.data = nil
			b.rawData = nil
		}
	}
}

func (b *Time64Builder) Append(v arrow.Time64) {
	b.Reserve(1)
	b.UnsafeAppend(v)
}

func (b *Time64Builder) AppendNull() {
	b.Reserve(1)
	b.UnsafeAppendBoolToBitmap(false)
}

func (b *Time64Builder) UnsafeAppend(v arrow.Time64) {
	bitutil.SetBit(b.nullBitmap.Bytes(), b.length)
	b.rawData[b.length] = v
	b.length++
}

func (b *Time64Builder) UnsafeAppendBoolToBitmap(isValid bool) {
	if isValid {
		bitutil.SetBit(b.nullBitmap.Bytes(), b.length)
	} else {
		b.nulls++
	}
	b.length++
}

// AppendValues will append the values in the v slice. The valid slice determines which values
// in v are valid (not null). The valid slice must either be empty or be equal in length to v. If empty,
// all values in v are appended and considered valid.
func (b *Time64Builder) AppendValues(v []arrow.Time64, valid []bool) {
	if len(v) != len(valid) && len(valid) != 0 {
		panic("len(v) != len(valid) && len(valid) != 0")
	}

	b.Reserve(len(v))
	if len(v) > 0 {
		arrow.Time64Traits.Copy(b.rawData[b.length:], v)
	}
	b.builder.unsafeAppendBoolsToBitmap(valid, len(v))
}

func (b *Time64Builder) init(capacity int) {
	b.builder.init(capacity)

	b.data = memory.NewResizableBuffer(b.mem)
	bytesN := arrow.Time64Traits.BytesRequired(capacity)
	b.data.Resize(bytesN)
	b.rawData = arrow.Time64Traits.CastFromBytes(b.data.Bytes())
}

// Reserve ensures there is enough space for appending n elements
// by checking the capacity and calling Resize if necessary.
func (b *Time64Builder) Reserve(n int) {
	b.builder.reserve(n, b.Resize)
}

// Resize adjusts the space allocated by b to n elements. If n is greater than b.Cap(),
// additional memory will be allocated. If n is smaller, the allocated memory may reduced.
func (b *Time64Builder) Resize(n int) {
	nBuilder := n
	if n < minBuilderCapacity {
		n = minBuilderCapacity
	}

	if b.capacity == 0 {
		b.init(n)
	} else {
		b.builder.resize(nBuilder, b.init)
		b.data.Resize(arrow.Time64Traits.BytesRequired(n))
		b.rawData = arrow.Time64Traits.CastFromBytes(b.data.Bytes())
	}
}

// NewArray creates a Time64 array from the memory buffers used by the builder and resets the Time64Builder
// so it can be used to build a new array.
func (b *Time64Builder) NewArray() Interface {
	return b.NewTime64Array()
}

// NewTime64Array creates a Time64 array from the memory buffers used by the builder and resets the Time64Builder
// so it can be used to build a new array.
func (b *Time64Builder) NewTime64Array() (a *Time64) {
	data := b.newData()
	a = NewTime64Data(data)
	data.Release()
	return
}

func (b *Time64Builder) newData() (data *Data) {
	bytesRequired := arrow.Time64Traits.BytesRequired(b.length)
	if bytesRequired > 0 && bytesRequired < b.data.Len() {
		// trim buffers
		b.data.Resize(bytesRequired)
	}
	data = NewData(b.dtype, b.length, []*memory.Buffer{b.nullBitmap, b.data}, nil, b.nulls, 0)
	b.reset()

	if b.data != nil {
		b.data.Release()
		b.data = nil
		b.rawData = nil
	}

	return
}

type Date32Builder struct {
	builder

	data    *memory.Buffer
	rawData []arrow.Date32
}

func NewDate32Builder(mem memory.Allocator) *Date32Builder {
	return &Date32Builder{builder: builder{refCount: 1, mem: mem}}
}

// Release decreases the reference count by 1.
// When the reference count goes to zero, the memory is freed.
func (b *Date32Builder) Release() {
	debug.Assert(atomic.LoadInt64(&b.refCount) > 0, "too many releases")

	if atomic.AddInt64(&b.refCount, -1) == 0 {
		if b.nullBitmap != nil {
			b.nullBitmap.Release()
			b.nullBitmap = nil
		}
		if b.data != nil {
			b.data.Release()
			b.data = nil
			b.rawData = nil
		}
	}
}

func (b *Date32Builder) Append(v arrow.Date32) {
	b.Reserve(1)
	b.UnsafeAppend(v)
}

func (b *Date32Builder) AppendNull() {
	b.Reserve(1)
	b.UnsafeAppendBoolToBitmap(false)
}

func (b *Date32Builder) UnsafeAppend(v arrow.Date32) {
	bitutil.SetBit(b.nullBitmap.Bytes(), b.length)
	b.rawData[b.length] = v
	b.length++
}

func (b *Date32Builder) UnsafeAppendBoolToBitmap(isValid bool) {
	if isValid {
		bitutil.SetBit(b.nullBitmap.Bytes(), b.length)
	} else {
		b.nulls++
	}
	b.length++
}

// AppendValues will append the values in the v slice. The valid slice determines which values
// in v are valid (not null). The valid slice must either be empty or be equal in length to v. If empty,
// all values in v are appended and considered valid.
func (b *Date32Builder) AppendValues(v []arrow.Date32, valid []bool) {
	if len(v) != len(valid) && len(valid) != 0 {
		panic("len(v) != len(valid) && len(valid) != 0")
	}

	b.Reserve(len(v))
	if len(v) > 0 {
		arrow.Date32Traits.Copy(b.rawData[b.length:], v)
	}
	b.builder.unsafeAppendBoolsToBitmap(valid, len(v))
}

func (b *Date32Builder) init(capacity int) {
	b.builder.init(capacity)

	b.data = memory.NewResizableBuffer(b.mem)
	bytesN := arrow.Date32Traits.BytesRequired(capacity)
	b.data.Resize(bytesN)
	b.rawData = arrow.Date32Traits.CastFromBytes(b.data.Bytes())
}

// Reserve ensures there is enough space for appending n elements
// by checking the capacity and calling Resize if necessary.
func (b *Date32Builder) Reserve(n int) {
	b.builder.reserve(n, b.Resize)
}

// Resize adjusts the space allocated by b to n elements. If n is greater than b.Cap(),
// additional memory will be allocated. If n is smaller, the allocated memory may reduced.
func (b *Date32Builder) Resize(n int) {
	nBuilder := n
	if n < minBuilderCapacity {
		n = minBuilderCapacity
	}

	if b.capacity == 0 {
		b.init(n)
	} else {
		b.builder.resize(nBuilder, b.init)
		b.data.Resize(arrow.Date32Traits.BytesRequired(n))
		b.rawData = arrow.Date32Traits.CastFromBytes(b.data.Bytes())
	}
}

// NewArray creates a Date32 array from the memory buffers used by the builder and resets the Date32Builder
// so it can be used to build a new array.
func (b *Date32Builder) NewArray() Interface {
	return b.NewDate32Array()
}

// NewDate32Array creates a Date32 array from the memory buffers used by the builder and resets the Date32Builder
// so it can be used to build a new array.
func (b *Date32Builder) NewDate32Array() (a *Date32) {
	data := b.newData()
	a = NewDate32Data(data)
	data.Release()
	return
}

func (b *Date32Builder) newData() (data *Data) {
	bytesRequired := arrow.Date32Traits.BytesRequired(b.length)
	if bytesRequired > 0 && bytesRequired < b.data.Len() {
		// trim buffers
		b.data.Resize(bytesRequired)
	}
	data = NewData(arrow.PrimitiveTypes.Date32, b.length, []*memory.Buffer{b.nullBitmap, b.data}, nil, b.nulls, 0)
	b.reset()

	if b.data != nil {
		b.data.Release()
		b.data = nil
		b.rawData = nil
	}

	return
}

type Date64Builder struct {
	builder

	data    *memory.Buffer
	rawData []arrow.Date64
}

func NewDate64Builder(mem memory.Allocator) *Date64Builder {
	return &Date64Builder{builder: builder{refCount: 1, mem: mem}}
}

// Release decreases the reference count by 1.
// When the reference count goes to zero, the memory is freed.
func (b *Date64Builder) Release() {
	debug.Assert(atomic.LoadInt64(&b.refCount) > 0, "too many releases")

	if atomic.AddInt64(&b.refCount, -1) == 0 {
		if b.nullBitmap != nil {
			b.nullBitmap.Release()
			b.nullBitmap = nil
		}
		if b.data != nil {
			b.data.Release()
			b.data = nil
			b.rawData = nil
		}
	}
}

func (b *Date64Builder) Append(v arrow.Date64) {
	b.Reserve(1)
	b.UnsafeAppend(v)
}

func (b *Date64Builder) AppendNull() {
	b.Reserve(1)
	b.UnsafeAppendBoolToBitmap(false)
}

func (b *Date64Builder) UnsafeAppend(v arrow.Date64) {
	bitutil.SetBit(b.nullBitmap.Bytes(), b.length)
	b.rawData[b.length] = v
	b.length++
}

func (b *Date64Builder) UnsafeAppendBoolToBitmap(isValid bool) {
	if isValid {
		bitutil.SetBit(b.nullBitmap.Bytes(), b.length)
	} else {
		b.nulls++
	}
	b.length++
}

// AppendValues will append the values in the v slice. The valid slice determines which values
// in v are valid (not null). The valid slice must either be empty or be equal in length to v. If empty,
// all values in v are appended and considered valid.
func (b *Date64Builder) AppendValues(v []arrow.Date64, valid []bool) {
	if len(v) != len(valid) && len(valid) != 0 {
		panic("len(v) != len(valid) && len(valid) != 0")
	}

	b.Reserve(len(v))
	if len(v) > 0 {
		arrow.Date64Traits.Copy(b.rawData[b.length:], v)
	}
	b.builder.unsafeAppendBoolsToBitmap(valid, len(v))
}

func (b *Date64Builder) init(capacity int) {
	b.builder.init(capacity)

	b.data = memory.NewResizableBuffer(b.mem)
	bytesN := arrow.Date64Traits.BytesRequired(capacity)
	b.data.Resize(bytesN)
	b.rawData = arrow.Date64Traits.CastFromBytes(b.data.Bytes())
}

// Reserve ensures there is enough space for appending n elements
// by checking the capacity and calling Resize if necessary.
func (b *Date64Builder) Reserve(n int) {
	b.builder.reserve(n, b.Resize)
}

// Resize adjusts the space allocated by b to n elements. If n is greater than b.Cap(),
// additional memory will be allocated. If n is smaller, the allocated memory may reduced.
func (b *Date64Builder) Resize(n int) {
	nBuilder := n
	if n < minBuilderCapacity {
		n = minBuilderCapacity
	}

	if b.capacity == 0 {
		b.init(n)
	} else {
		b.builder.resize(nBuilder, b.init)
		b.data.Resize(arrow.Date64Traits.BytesRequired(n))
		b.rawData = arrow.Date64Traits.CastFromBytes(b.data.Bytes())
	}
}

// NewArray creates a Date64 array from the memory buffers used by the builder and resets the Date64Builder
// so it can be used to build a new array.
func (b *Date64Builder) NewArray() Interface {
	return b.NewDate64Array()
}

// NewDate64Array creates a Date64 array from the memory buffers used by the builder and resets the Date64Builder
// so it can be used to build a new array.
func (b *Date64Builder) NewDate64Array() (a *Date64) {
	data := b.newData()
	a = NewDate64Data(data)
	data.Release()
	return
}

func (b *Date64Builder) newData() (data *Data) {
	bytesRequired := arrow.Date64Traits.BytesRequired(b.length)
	if bytesRequired > 0 && bytesRequired < b.data.Len() {
		// trim buffers
		b.data.Resize(bytesRequired)
	}
	data = NewData(arrow.PrimitiveTypes.Date64, b.length, []*memory.Buffer{b.nullBitmap, b.data}, nil, b.nulls, 0)
	b.reset()

	if b.data != nil {
		b.data.Release()
		b.data = nil
		b.rawData = nil
	}

	return
}

var (
	_ Builder = (*Int64Builder)(nil)
	_ Builder = (*Uint64Builder)(nil)
	_ Builder = (*Float64Builder)(nil)
	_ Builder = (*Int32Builder)(nil)
	_ Builder = (*Uint32Builder)(nil)
	_ Builder = (*Float32Builder)(nil)
	_ Builder = (*Int16Builder)(nil)
	_ Builder = (*Uint16Builder)(nil)
	_ Builder = (*Int8Builder)(nil)
	_ Builder = (*Uint8Builder)(nil)
	_ Builder = (*TimestampBuilder)(nil)
	_ Builder = (*Time32Builder)(nil)
	_ Builder = (*Time64Builder)(nil)
	_ Builder = (*Date32Builder)(nil)
	_ Builder = (*Date64Builder)(nil)
)


text:
.. highlight:: shell

============
Installation
============

Stable release
--------------

To install Hermes, run this command in your terminal:

.. code-block:: console

    $ pip install Hermes

This is the preferred method to install Hermes, as it will always install the most recent stable release.

If you don't have `pip`_ installed, this `Python installation guide`_ can guide
you through the process.

.. _pip: https://pip.pypa.io
.. _Python installation guide: http://docs.python-guide.org/en/latest/starting/installation/

From sources
------------

The sources for Hermes can be downloaded from the `Github repo`_.

You can either clone the public repository:

.. code-block:: console

    $ git clone git://github.com/xmnlab/Hermes

Or download the `tarball`_:

.. code-block:: console

    $ curl  -OL https://github.com/xmnlab/Hermes/tarball/master

Once you have a copy of the source, you can install it with:

.. code-block:: console

    $ python setup.py install

.. _Github repo: https://github.com/xmnlab/Hermes
.. _tarball: https://github.com/xmnlab/Hermes/tarball/master


text:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace MBCorpHealthTestMVC.Controllers
{
    public class PacienteController : Controller
    {
        // GET: Paciente
        public ActionResult Index()
        {
            return View();
        }

        // GET: Paciente/Details/5
        public ActionResult Details(int id)
        {
            return View();
        }

        // GET: Paciente/Create
        public ActionResult Create()
        {
            return View();
        }

        // POST: Paciente/Create
        [HttpPost]
        public ActionResult Create(FormCollection collection)
        {
            try
            {
                // TODO: Add insert logic here

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }

        // GET: Paciente/Edit/5
        public ActionResult Edit(int id)
        {
            return View();
        }

        // POST: Paciente/Edit/5
        [HttpPost]
        public ActionResult Edit(int id, FormCollection collection)
        {
            try
            {
                // TODO: Add update logic here

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }

        // GET: Paciente/Delete/5
        public ActionResult Delete(int id)
        {
            return View();
        }

        // POST: Paciente/Delete/5
        [HttpPost]
        public ActionResult Delete(int id, FormCollection collection)
        {
            try
            {
                // TODO: Add delete logic here

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }

        public ActionResult Listar()
        {
            return View();
        }
    }
}


text:
package com.reader.common;

import java.io.Serializable;
import java.util.Date;

public class BookMetadata implements Serializable, Comparable<BookMetadata> {

	/**
	 *
	 */
	private static final long serialVersionUID = -5110961974956474613L;

	private String fileName;

	private String name;

	private float ready;

	private int fontSize;

	private String fontName;

	private Date lastOpen;

	private int lastPosition;

	private int lastSection;

	public String getFileName() {
		return fileName;
	}

	public void setFileName(String fileName) {
		this.fileName = fileName;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	/**
	 * Ready percent
	 *
	 * @return
	 */
	public float getReady() {
		return ready;
	}

	public void setReady(float ready) {
		this.ready = ready;
	}

	public int getFontSize() {
		return fontSize;
	}

	public void setFontSize(int fontSize) {
		this.fontSize = fontSize;
	}

	public String getFontName() {
		return fontName;
	}

	public void setFontName(String fontName) {
		this.fontName = fontName;
	}

	public Date getLastOpen() {
		return lastOpen;
	}

	public void setLastOpen(Date lastOpen) {
		this.lastOpen = lastOpen;
	}

	@Override
	public int compareTo(BookMetadata o) {
		return o.lastOpen.compareTo(lastOpen);
	}

	@Override
	public String toString() {
		return name;
	}

	public int getLastPosition() {
		return lastPosition;
	}

	public void setLastPosition(int lastPosition) {
		this.lastPosition = lastPosition;
	}

	public int getLastSection() {
		return lastSection;
	}

	public void setLastSection(int lastSection) {
		this.lastSection = lastSection;
	}
}


text:
This test checks text editor javascript formatting.

/**
* Multi-line comment
*
*/
function foo(n) {
// one-line comment
function bar() {
return 42;D

var sum = 0;
for (var i = 0; i < n; ++i) {
for (var j = 0; j < n; ++j) {
sum += i + j;DD

if (sum > 1000) {
while (sum > 0) {
--sum;DDD


text:
USE [master];
GO

CREATE LOGIN NewRelic WITH PASSWORD=N'abcd1234!',
DEFAULT_DATABASE=[master], CHECK_EXPIRATION=OFF,
CHECK_POLICY=ON;
GO

GRANT VIEW SERVER STATE TO NewRelic;
GO

USE TestData;
GO

CREATE USER NewRelicUser FOR LOGIN NewRelic;
GO


text:
package org.apache.hadoop.hbase.master.snapshot;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import java.io.IOException;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;

import com.google.common.collect.Iterables;
import com.google.common.collect.ObjectArrays;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.MediumTests;
import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription;
import org.apache.hadoop.hbase.snapshot.SnapshotDescriptionUtils;
import org.apache.hadoop.hbase.snapshot.SnapshotReferenceUtil;
import org.apache.hadoop.hbase.snapshot.TakeSnapshotUtils;
import org.apache.hadoop.hbase.util.FSUtils;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

/**
 * Test that we correctly reload the cache, filter directories, etc.
 */
@Category(MediumTests.class)
public class TestSnapshotFileCache {

  private static final Log LOG = LogFactory.getLog(TestSnapshotFileCache.class);
  private static final HBaseTestingUtility UTIL = new HBaseTestingUtility();
  private static FileSystem fs;
  private static Path rootDir;

  @BeforeClass
  public static void startCluster() throws Exception {
    UTIL.startMiniDFSCluster(1);
    fs = UTIL.getDFSCluster().getFileSystem();
    rootDir = UTIL.getDefaultRootDirPath();
  }

  @AfterClass
  public static void stopCluster() throws Exception {
    UTIL.shutdownMiniDFSCluster();
  }

  @After
  public void cleanupFiles() throws Exception {
    // cleanup the snapshot directory
    Path snapshotDir = SnapshotDescriptionUtils.getSnapshotsDir(rootDir);
    fs.delete(snapshotDir, true);
  }

  @Test(timeout = 10000000)
  public void testLoadAndDelete() throws Exception {
    // don't refresh the cache unless we tell it to
    long period = Long.MAX_VALUE;
    Path snapshotDir = SnapshotDescriptionUtils.getSnapshotsDir(rootDir);
    SnapshotFileCache cache = new SnapshotFileCache(fs, rootDir, period, 10000000,
        "test-snapshot-file-cache-refresh", new SnapshotFiles());

    Path snapshot = new Path(snapshotDir, "snapshot");
    Path region = new Path(snapshot, "7e91021");
    Path family = new Path(region, "fam");
    Path file1 = new Path(family, "file1");
    Path file2 = new Path(family, "file2");

    // create two hfiles under the snapshot
    fs.createNewFile(file1);
    fs.createNewFile(file2);

    FSUtils.logFileSystemState(fs, rootDir, LOG);

    // then make sure the cache finds them
    Iterable<FileStatus> nonSnapshotFiles = cache.getUnreferencedFiles(
            Arrays.asList(FSUtils.listStatus(fs, family))
    );
    assertFalse("Cache didn't find:" + file1, Iterables.contains(nonSnapshotFiles, file1));
    assertFalse("Cache didn't find:" + file2, Iterables.contains(nonSnapshotFiles, file2));
    String not = "file-shouldn't-be-found";
    assertFalse("Cache found '" + not + "', but it shouldn't have.", Iterables.contains(nonSnapshotFiles, not));

    // make sure we get a little bit of separation in the modification times
    // its okay if we sleep a little longer (b/c of GC pause), as long as we sleep a little
    Thread.sleep(10);

    LOG.debug("Deleting snapshot.");
    // then delete the snapshot and make sure that we can still find the files
    if (!fs.delete(snapshot, true)) {
      throw new IOException("Couldn't delete " + snapshot + " for an unknown reason.");
    }
    FSUtils.logFileSystemState(fs, rootDir, LOG);

    LOG.debug("Checking to see if file is deleted.");
    nonSnapshotFiles = cache.getUnreferencedFiles(
            nonSnapshotFiles
    );

    assertFalse("Cache didn't find:" + file1, Iterables.contains(nonSnapshotFiles, file1));
    assertFalse("Cache didn't find:" + file2, Iterables.contains(nonSnapshotFiles, file2));

    // then trigger a refresh
    cache.triggerCacheRefreshForTesting();

    nonSnapshotFiles = cache.getUnreferencedFiles(
            nonSnapshotFiles
    );
    // and not it shouldn't find those files
    assertFalse("Cache found '" + file1 + "', but it shouldn't have.",
            Iterables.contains(nonSnapshotFiles, file1));
    assertFalse("Cache found '" + file2 + "', but it shouldn't have.",
            Iterables.contains(nonSnapshotFiles, file2));

    fs.delete(snapshotDir, true);
  }

  @Test
  public void testWeNeverCacheTmpDirAndLoadIt() throws Exception {

    final AtomicInteger count = new AtomicInteger(0);
    // don't refresh the cache unless we tell it to
    long period = Long.MAX_VALUE;
    Path snapshotDir = SnapshotDescriptionUtils.getSnapshotsDir(rootDir);
    SnapshotFileCache cache = new SnapshotFileCache(fs, rootDir, period, 10000000,
            "test-snapshot-file-cache-refresh", new SnapshotFiles()) {
      @Override
      List<String> getSnapshotsInProgress() throws IOException {
        List<String> result = super.getSnapshotsInProgress();
        count.incrementAndGet();
        return result;
      }
    };

    // create a file in a 'completed' snapshot
    Path snapshot = new Path(snapshotDir, "snapshot");
    Path region = new Path(snapshot, "7e91021");
    Path family = new Path(region, "fam");
    Path file1 = new Path(family, "file1");
    fs.createNewFile(file1);

    FileStatus[] completedFiles = FSUtils.listStatus(fs, family);

    // create an 'in progress' snapshot
    SnapshotDescription desc = SnapshotDescription.newBuilder().setName("working").build();
    snapshot = SnapshotDescriptionUtils.getWorkingSnapshotDir(desc, rootDir);
    region = new Path(snapshot, "7e91021");
    family = new Path(region, "fam");
    Path file2 = new Path(family, "file2");
    fs.createNewFile(file2);
    cache.triggerCacheRefreshForTesting();

    Iterable<FileStatus> deletableFiles = cache.getUnreferencedFiles(Arrays.asList(
            ObjectArrays.concat(completedFiles, FSUtils.listStatus(fs, family), FileStatus.class))
    );
    assertTrue(Iterables.isEmpty(deletableFiles));
    assertEquals(1, count.get()); // we check the tmp directory

    Path file3 = new Path(family, "file3");
    fs.create(file3);
    deletableFiles = cache.getUnreferencedFiles(Arrays.asList(
            ObjectArrays.concat(completedFiles, FSUtils.listStatus(fs, family), FileStatus.class))
    );
    assertTrue(Iterables.isEmpty(deletableFiles));
    assertEquals(2, count.get()); // we check the tmp directory

  }

  @Test
  public void testLoadsTmpDir() throws Exception {
    // don't refresh the cache unless we tell it to
    long period = Long.MAX_VALUE;
    Path snapshotDir = SnapshotDescriptionUtils.getSnapshotsDir(rootDir);
    SnapshotFileCache cache = new SnapshotFileCache(fs, rootDir, period, 10000000,
        "test-snapshot-file-cache-refresh", new SnapshotFiles());

    // create a file in a 'completed' snapshot
    Path snapshot = new Path(snapshotDir, "snapshot");
    Path region = new Path(snapshot, "7e91021");
    Path family = new Path(region, "fam");
    Path file1 = new Path(family, "file1");
    fs.createNewFile(file1);

    // create an 'in progress' snapshot
    SnapshotDescription desc = SnapshotDescription.newBuilder().setName("working").build();
    snapshot = SnapshotDescriptionUtils.getWorkingSnapshotDir(desc, rootDir);
    region = new Path(snapshot, "7e91021");
    family = new Path(region, "fam");
    Path file2 = new Path(family, "file2");
    fs.createNewFile(file2);

    FSUtils.logFileSystemState(fs, rootDir, LOG);

    // then make sure the cache finds both files
    Iterable<FileStatus> nonSnapshotFiles = cache.getUnreferencedFiles(
            Arrays.asList(FSUtils.listStatus(fs, family))
    );
    assertFalse("Cache didn't find:" + file1, Iterables.contains(nonSnapshotFiles, file1));
    assertFalse("Cache didn't find:" + file2, Iterables.contains(nonSnapshotFiles, file2));
  }

  @Test
  public void testJustFindLogsDirectory() throws Exception {
    // don't refresh the cache unless we tell it to
    long period = Long.MAX_VALUE;
    Path snapshotDir = SnapshotDescriptionUtils.getSnapshotsDir(rootDir);
    SnapshotFileCache cache = new SnapshotFileCache(fs, rootDir, period, 10000000,
        "test-snapshot-file-cache-refresh", new SnapshotFileCache.SnapshotFileInspector() {
            public Collection<String> filesUnderSnapshot(final Path snapshotDir)
                throws IOException {
              return SnapshotReferenceUtil.getHLogNames(fs, snapshotDir);
            }
        });

    // create a file in a 'completed' snapshot
    Path snapshot = new Path(snapshotDir, "snapshot");
    Path region = new Path(snapshot, "7e91021");
    Path family = new Path(region, "fam");
    Path file1 = new Path(family, "file1");
    fs.createNewFile(file1);

    // and another file in the logs directory
    Path logs = TakeSnapshotUtils.getSnapshotHLogsDir(snapshot, "server");
    Path log = new Path(logs, "me.hbase.com%2C58939%2C1350424310315.1350424315552");
    fs.createNewFile(log);

    FSUtils.logFileSystemState(fs, rootDir, LOG);

    Iterable<FileStatus> nonSnapshotFiles = cache.getUnreferencedFiles(
            Arrays.asList(FSUtils.listStatus(fs, family))
    );
    // then make sure the cache only finds the log files
    assertFalse("Cache found '" + file1 + "', but it shouldn't have.",
            Iterables.contains(nonSnapshotFiles, file1));
    assertFalse("Cache didn't find:" + log, Iterables.contains(nonSnapshotFiles, log));
  }

  @Test
  public void testReloadModifiedDirectory() throws IOException {
    // don't refresh the cache unless we tell it to
    long period = Long.MAX_VALUE;
    Path snapshotDir = SnapshotDescriptionUtils.getSnapshotsDir(rootDir);
    SnapshotFileCache cache = new SnapshotFileCache(fs, rootDir, period, 10000000,
        "test-snapshot-file-cache-refresh", new SnapshotFiles());

    Path snapshot = new Path(snapshotDir, "snapshot");
    Path region = new Path(snapshot, "7e91021");
    Path family = new Path(region, "fam");
    Path file1 = new Path(family, "file1");
    Path file2 = new Path(family, "file2");

    // create two hfiles under the snapshot
    fs.createNewFile(file1);
    fs.createNewFile(file2);

    FSUtils.logFileSystemState(fs, rootDir, LOG);

    Iterable<FileStatus> nonSnapshotFiles = cache.getUnreferencedFiles(
            Arrays.asList(FSUtils.listStatus(fs, family))
    );
    assertFalse("Cache didn't find " + file1, Iterables.contains(nonSnapshotFiles, file1));

    // now delete the snapshot and add a file with a different name
    fs.delete(snapshot, true);
    Path file3 = new Path(family, "new_file");
    fs.createNewFile(file3);

    FSUtils.logFileSystemState(fs, rootDir, LOG);
    nonSnapshotFiles = cache.getUnreferencedFiles(
            Arrays.asList(FSUtils.listStatus(fs, family))
    );
    assertFalse("Cache didn't find new file:" + file3, Iterables.contains(nonSnapshotFiles, file3));
  }

  @Test
  public void testSnapshotTempDirReload() throws IOException {
    long period = Long.MAX_VALUE;
    Path snapshotDir = new Path(SnapshotDescriptionUtils.getSnapshotsDir(rootDir),
        SnapshotDescriptionUtils.SNAPSHOT_TMP_DIR_NAME);
    SnapshotFileCache cache = new SnapshotFileCache(fs, rootDir, period, 10000000,
        "test-snapshot-file-cache-refresh", new SnapshotFiles());

    // Add a new snapshot
    Path snapshot1 = new Path(snapshotDir, "snapshot1");
    Path file1 = new Path(new Path(new Path(snapshot1, "7e91021"), "fam"), "file1");
    fs.createNewFile(file1);
    assertTrue(cache.getSnapshotsInProgress().contains(file1.getName()));

    // Add another snapshot
    Path snapshot2 = new Path(snapshotDir, "snapshot2");
    Path file2 = new Path(new Path(new Path(snapshot2, "7e91021"), "fam2"), "file2");
    fs.createNewFile(file2);
    assertTrue(cache.getSnapshotsInProgress().contains((file2.getName())));
  }

  class SnapshotFiles implements SnapshotFileCache.SnapshotFileInspector {
    public Collection<String> filesUnderSnapshot(final Path snapshotDir) throws IOException {
      Collection<String> files =  new HashSet<String>();
      files.addAll(SnapshotReferenceUtil.getHLogNames(fs, snapshotDir));
      files.addAll(SnapshotReferenceUtil.getHFileNames(fs, snapshotDir));
      return files;
    }
  };
}


text:
package org.wiztools.restclient.ui.reqssl;

import java.awt.FlowLayout;
import java.awt.event.ItemListener;
import javax.swing.ButtonGroup;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import org.wiztools.restclient.bean.KeyStoreType;

/**
 *
 * @author subwiz
 */
public class StoreTypePanel extends JPanel {

    private final JRadioButton jrb_jks = new JRadioButton(KeyStoreType.JKS.name());
    private final JRadioButton jrb_pkcs12 = new JRadioButton(KeyStoreType.PKCS12.name());
    private final JRadioButton jrb_pem = new JRadioButton(KeyStoreType.PEM.name());

    public StoreTypePanel() {
        this.setLayout(new FlowLayout(FlowLayout.LEFT));

        ButtonGroup grp = new ButtonGroup();
        grp.add(jrb_jks);
        grp.add(jrb_pkcs12);
        grp.add(jrb_pem);

        // JKS to be selected by default:
        jrb_jks.setSelected(true);

        add(jrb_jks);
        add(jrb_pkcs12);
        add(jrb_pem);
    }

    public KeyStoreType getSelectedKeyStoreType() {
        if(jrb_jks.isSelected()) {
            return KeyStoreType.JKS;
        }
        else if(jrb_pkcs12.isSelected()) {
            return KeyStoreType.PKCS12;
        }
        else if(jrb_pem.isSelected()) {
            return KeyStoreType.PEM;
        }
        return KeyStoreType.PEM;
    }

    public void setSelectedKeyStoreType(KeyStoreType type) {
        switch(type) {
            case JKS:
                jrb_jks.setSelected(true);
                break;
            case PKCS12:
                jrb_pkcs12.setSelected(true);
                break;
            case PEM:
                jrb_pem.setSelected(true);
                break;
            default:
                throw new IllegalArgumentException("Unknown keystore-type: " + type);
        }
    }

    public void addItemListener(ItemListener listener, KeyStoreType ... types) {
        for(KeyStoreType type: types) {
            switch(type) {
                case JKS:
                    jrb_jks.addItemListener(listener);
                    break;
                case PKCS12:
                    jrb_pkcs12.addItemListener(listener);
                    break;
                case PEM:
                    jrb_pem.addItemListener(listener);
                    break;
                default:
                    throw new IllegalArgumentException("Unknown keystore-type: " + type);
            }
        }
    }
}


text:
"use strict";

var Class = require('../');
var merge = require("mout/object/merge")

var Options = new Class({

  setOptions: function(options){
      var optionsStack = Array.prototype.slice.call(arguments,0),
          tmp = Object.getPrototypeOf(this);
      while(tmp) {
        optionsStack.push(tmp.options);
        tmp = tmp.constructor.parent;
      }
      optionsStack.push({});
      optionsStack.reverse();

      this.options = merge.apply(null, optionsStack)
      return this
  }
});

module.exports = Options;


text:
title:  Un gând de încheiere
date:  10/07/2020
---

Esenţa vieţii de creştin constă într-o relaţie cu Isus atât de bogată, încât vom tânji să le spunem şi altora despre El. Oricât de importantă ar fi o doctrină corectă, ea nu poate înlocui o viaţă transformată prin har şi schimbată prin dragoste. Ellen G. White explică foarte clar acest lucru: "Mântuitorul ştia că niciun argument, oricât de logic, nu ar fi înmuiat inimile învârtoşate şi nu ar fi putut străpunge crusta egoismului şi a spiritului lumesc. El ştia că ucenicii Săi trebuiau să fie înzestraţi cu putere cerească; că Evanghelia îşi va împlini lucrarea numai atunci când va fi vestită din inimi încălzite şi cu buze elocvente, printr-o cunoaştere vie a Aceluia care este Calea, Adevărul şi Viaţa." – Faptele apostolilor, p. 31. În cartea Hristos, Lumina lumii, ea adaugă acest gând profund: "Iubirea minunată a lui Hristos va înduioşa şi va supune inimile acolo unde simpla înşirare a doctrinei nu va izbuti nimic" (p. 826).

Există oameni care cred că a da mărturie personală înseamnă să încerce să-i convingă pe ceilalţi de adevărurile pe care le-au descoperit în Cuvântul lui Dumnezeu. Deşi este important ca, la momentul potrivit, să facem cunoscute aceste adevăruri, mărturia personală are mai mult de-a face cu eliberarea de vină, cu pacea, mila, iertarea, puterea, speranţa şi bucuria pe care le-am găsit în darul vieţii veşnice, oferit fără plată de Isus.

**Pentru studiu suplimentar**: : Elen G. White, Faptele apostolilor, cap. 41 "Vrei să mă îndupleci".

STUDIU LA RÂND – BIBLIA ŞI CARTEA EVANGHELIZARE

**Biblia: Psalmii 146 – Proverbele 2**

`1. Ce aleargă "cu iuţeală mare"?`

`2. Pe cine slăveşte Domnul?`

`3. Care este soarta tuturor celor lacomi de câştig?`

`4. Cine anume nu mai găseşte cărările vieţii?`

Evanghelizare, Secţiunea 8, subcapitolul "Întâmpinarea problemelor cu privire la respectarea Sabatului"

`5. Care este singurul lucru din lumea noastră pe care ne putem sprijini?`


text:
/*! UIkit 2.3.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
/*jshint new: true */
/*global $, jQuery, document, window, navigator*/

(function ($, doc, global) {

    "use strict";

    var UI = $.UIkit || {}, $html = $("html"), $win = $(window);

    if (UI.fn) {
        return;
    }

    UI.fn = function (command, options) {

        var args = arguments, cmd = command.match(/^([a-z\-]+)(?:\.([a-z]+))?/i), component = cmd[1], method = cmd[2];

        if (!UI[component]) {
            $.error("UIkit component [" + component + "] does not exist.");
            return this;
        }

        return this.each(function () {
            var $this = $(this), data = $this.data(component);
            if (!data) {
                $this.data(component, (data = new UI[component](this, method ? undefined : options)));
            }
            if (method) {
                data[method].apply(data, Array.prototype.slice.call(args, 1));
            }
        });
    };

    UI.support = {};

    UI.support.requestAnimationFrame = global.requestAnimationFrame || global.webkitRequestAnimationFrame || global.mozRequestAnimationFrame || global.msRequestAnimationFrame || global.oRequestAnimationFrame || function (callback) { global.setTimeout(callback, 1000 / 60); };
    UI.support.touch                 = (
        ('ontouchstart' in window && navigator.userAgent.toLowerCase().match(/mobile|tablet/)) ||
        (global.DocumentTouch && document instanceof global.DocumentTouch)  ||
        (global.navigator['msPointerEnabled'] && global.navigator['msMaxTouchPoints'] > 0) || //IE 10
        (global.navigator['pointerEnabled'] && global.navigator['maxTouchPoints'] > 0) || //IE >=11
        false
    );
    UI.support.mutationobserver      = (global.MutationObserver || global.WebKitMutationObserver || global.MozMutationObserver || null);

    UI.Utils = {};

    UI.Utils.debounce = function (func, wait, immediate) {
        var timeout;
        return function () {
            var context, later;
            var context = this, args = arguments;
            var later = function() {
                timeout = null;
                if (!immediate) func.apply(context, args);
            };
            var callNow = immediate && !timeout;
            clearTimeout(timeout);
            timeout = setTimeout(later, wait);
            if (callNow) func.apply(context, args);
        };
    };

    UI.Utils.isInView = function(element, options) {

        var $element = $(element);

        if (!$element.is(':visible')) {
            return false;
        }

        var window_left = $win.scrollLeft(), window_top = $win.scrollTop(), offset = $element.offset(), left = offset.left, top = offset.top;

        options = $.extend({topoffset:0, leftoffset:0}, options);

        if (top + $element.height() >= window_top && top - options.topoffset <= window_top + $win.height() &&
            left + $element.width() >= window_left && left - options.leftoffset <= window_left + $win.width()) {
          return true;
        } else {
          return false;
        }
    };

    UI.Utils.options = function(string) {

        if ($.isPlainObject(string)) return string;

        var start = (string ? string.indexOf("{") : -1), options = {};

        if (start != -1) {
            try {
                options = (new Function("", "var json = " + string.substr(start) + "; return JSON.parse(JSON.stringify(json));"))();
            } catch (e) {}
        }

        return options;
    };

    $.UIkit = UI;
    $.fn.uk = UI.fn;

    $(function(){

        $(doc).trigger("uk-domready");

        // Check for dom modifications
        if(!UI.support.mutationobserver) return;

        var observer = new UI.support.mutationobserver(UI.Utils.debounce(function(mutations) {
            $(doc).trigger("uk-domready");
        }, 300));

        // pass in the target node, as well as the observer options
        observer.observe(document.body, { childList: true, subtree: true });

        // remove css hover rules for touch devices
        if (UI.support.touch) {
            //UI.Utils.removeCssRules(/\.uk-(?!navbar).*:hover/);
        }
    });

})(jQuery, document, window);

(function($, UI) {

    "use strict";

    var $win           = $(window),
        scrollspies    = [],
        checkScrollSpy = function() {
            for(var i=0; i < scrollspies.length; i++) {
                UI.support.requestAnimationFrame.apply(window, [scrollspies[i].check]);
            }
        },

        ScrollSpy = function(element, options) {

            var $element = $(element);

            if($element.data("scrollspy")) return;

            this.options = $.extend({}, ScrollSpy.defaults, options);
            this.element = $(element);

            var $this = this, idle, inviewstate, initinview,
                fn = function(){

                    var inview = UI.Utils.isInView($this.element, $this.options);

                    if(inview && !inviewstate) {

                        if(idle) clearTimeout(idle);

                        if(!initinview) {
                            $this.element.addClass($this.options.initcls);
                            $this.offset = $this.element.offset();
                            initinview = true;

                            $this.element.trigger("uk-scrollspy-init");
                        }

                        idle = setTimeout(function(){

                            if(inview) {
                                $this.element.addClass("uk-scrollspy-inview").addClass($this.options.cls).width();
                            }

                        }, $this.options.delay);

                        inviewstate = true;
                        $this.element.trigger("uk.scrollspy.inview");
                    }

                    if (!inview && inviewstate && $this.options.repeat) {
                        $this.element.removeClass("uk-scrollspy-inview").removeClass($this.options.cls);
                        inviewstate = false;

                        $this.element.trigger("uk.scrollspy.outview");
                    }
                };

            fn();

            this.element.data("scrollspy", this);

            this.check = fn;
            scrollspies.push(this);
        };

    ScrollSpy.defaults = {
        "cls"        : "uk-scrollspy-inview",
        "initcls"    : "uk-scrollspy-init-inview",
        "topoffset"  : 0,
        "leftoffset" : 0,
        "repeat"     : false,
        "delay"      : 0
    };

    UI["scrollspy"] = ScrollSpy;

    var fnCheck = function(){
        checkScrollSpy();
    };

    // listen to scroll and resize
    $win.on("scroll", fnCheck).on("resize orientationchange", UI.Utils.debounce(fnCheck, 50));

    // init code
    $(document).on("uk-domready", function(e) {
        $("[data-uk-scrollspy]").each(function() {

            var element = $(this);

            if (!element.data("scrollspy")) {
                var obj = new ScrollSpy(element, UI.Utils.options(element.attr("data-uk-scrollspy")));
            }
        });

    });

})(jQuery, jQuery.UIkit);


text:
function updateChannelData ({input, state, output}) {
  const channel = {
    name: input.channelName,
    isLoaded: true,
    isLoading: false,
    data: input.result
  }
  state.set(['app', 'channels', 'current', input.channelName], channel)
}

export default updateChannelData


text:
package com.github.simonesestito.classeviva_api;

import android.util.Log;

import com.android.volley.AuthFailureError;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.StringRequest;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.HashMap;
import java.util.Map;

public class JsonArrayRequest extends StringRequest {

    private Map<String, String> params;
    private int method;
    private String apiKey;

    public JsonArrayRequest(int method, String apiKey, String url, Map<String, String> params, final OnResultsAvailable<JSONArray> listener, final ClassevivaSession instance) {
        super(method, url, new Response.Listener<String>() {
            @Override
            public void onResponse(String response) {
                Log.wtf("ClasseViva Response", response);
                try {
                    //Transform String to JSONArray
                    listener.onResultsAvailable(new JSONArray(response), instance);
                } catch (JSONException e) {
                    listener.onError(e);
                }
            }
        }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                try {
                    String response = new String(error.networkResponse.data);
                    Log.wtf("Bad Internet response", response);

                    //Have I made too many requests?
                    JSONObject object = new JSONObject(response);
                    if (object.getJSONObject("response").getString("msg").equalsIgnoreCase("Call limit reached."))
                        listener.onError(new Exception("Call limit reached.", error));
                    else
                        throw new Exception(); //Call "catch" block

                } catch (Exception e){
                    e.printStackTrace();
                    listener.onError(error);
                }
            }
        });

        //Assign fields value
        this.params = params;
        this.method = method;
        this.apiKey = apiKey;
    }

    @Override
    public Map<String, String> getHeaders() throws AuthFailureError {
        //Set your API Key in Headers
        Map<String, String> head = new HashMap<>();
        head.put("X-API-KEY", apiKey);
        return head;
    }

    @Override
    public int getMethod() {
        //Set custom method
        return method;
    }

    @Override
    protected Map<String, String> getParams() throws AuthFailureError {
        //Set custom parameters
        return params;
    }
}