text:
<?xml version="1.0" encoding="UTF-8"?>
<project name="nunaliit2-js" default="default">
    <description>
		Useful scripts for Javascript library
    </description>

	<property name="javascript.dest.dir" location="./dummy_place"/>
	<property name="compressor.js" location="./target/tools/nunaliit2-javascript.jar"/>
	<property name="compressor.css" location="./target/tools/nunaliit2-css.jar"/>

    <!-- =================================
          target: default

          Do nothing
         ================================= -->
    <target name="default" description="description">

    </target>

    <!-- =================================
          target: javascript-copy

          Compresses and copies Javascript Files to destination
         ================================= -->
    <target
    	name="javascript-copy"
    	description="Copy Nunaliit2 javascript library"
    	depends="-javascript-copy-conditions,-javascript-copy-error,library-compress"
    	if="javascript-dest-exists"
    	>
    	<!-- Copy -->
    	<mkdir dir="${javascript.dest.dir}/nunaliit2"/>
		<copy todir="${javascript.dest.dir}/nunaliit2">
			<fileset dir="./src/main/js/nunaliit2"/>
		</copy>
    </target>

    <target
    	name="-javascript-copy-error"
    	description="Report error"
    	depends="-javascript-copy-conditions"
    	unless="javascript-dest-exists"
    	>
    	<fail message="Destination directory does not exist: ${javascript.dest.dir}"/>
    </target>

	<target name="-javascript-copy-conditions">
		<available file="${javascript.dest.dir}" property="javascript-dest-exists"/>
	</target>

    <!-- =================================
          target: vendor-files-copy

          Copies special files in vendor area (CouchDb application)
         ================================= -->
    <target
    	name="vendor-files-copy"
    	description="Copy Nunaliit2 vendor files"
    	depends="-vendor-files-copy-conditions,-vendor-files-copy-error"
    	if="vendor-files-dest-exists"
    	>
    	<!-- Copy -->
		<copy
			file="./src/main/js/nunaliit2/n2.couchUtils.js"
			tofile="${javascript.dest.dir}/n2.couchUtils.js"
			/>
		<copy
			file="./src/main/js/nunaliit2/n2.couchTiles.js"
			tofile="${javascript.dest.dir}/n2.couchTiles.js"
			/>
    </target>

    <target
    	name="-vendor-files-copy-error"
    	description="Report error"
    	depends="-vendor-files-copy-conditions"
    	unless="vendor-files-dest-exists"
    	>
    	<fail message="Destination directory does not exist: ${javascript.dest.dir}"/>
    </target>

	<target name="-vendor-files-copy-conditions">
		<available file="${javascript.dest.dir}" property="vendor-files-dest-exists"/>
	</target>

    <!-- =================================
          target: library-compress

          Compresses library files to destination
         ================================= -->
    <target
    	name="library-compress"
    	description="Compresses library files"
    	depends="-library-compress-conditions,-library-compress-error"
    	if="compressor-tools-exists"
    	>
    	<!-- Perform compression -->
        <java
        	jar="${compressor.js}"
        	fork="true"
        	>
          <arg line="--config-file ./compress/nunaliit2.cfg"/>
          <arg line="--license-file ./compress/license.txt"/>
          <arg line="--source-dir ./src/main/js/nunaliit2"/>
          <arg line="--output ./src/main/js/nunaliit2/nunaliit2.js"/>
          <arg line="--output-debug ./src/main/js/nunaliit2/nunaliit2-debug.js"/>
        </java>
        <java
        	jar="${compressor.js}"
        	fork="true"
        	>
          <arg line="--config-file ./compress/nunaliit2-couch.cfg"/>
          <arg line="--license-file ./compress/license.txt"/>
          <arg line="--source-dir ./src/main/js/nunaliit2"/>
          <arg line="--output ./src/main/js/nunaliit2/nunaliit2-couch.js"/>
          <arg line="--output-debug ./src/main/js/nunaliit2/nunaliit2-couch-debug.js"/>
        </java>
        <java
        	jar="${compressor.js}"
        	fork="true"
        	>
          <arg line="--config-file ./compress/nunaliit2-couch-mobile.cfg"/>
          <arg line="--license-file ./compress/license.txt"/>
          <arg line="--source-dir ./src/main/js/nunaliit2"/>
          <arg line="--output ./src/main/js/nunaliit2/nunaliit2-couch-mobile.js"/>
          <arg line="--output-debug ./src/main/js/nunaliit2/nunaliit2-couch-mobile-debug.js"/>
        </java>

    	<!--  Generate CSS libraries -->
        <java
        	jar="${compressor.css}"
        	fork="true"
        	dir="."
        	>
          <arg line="--config-file ./compress/nunaliit2-css.cfg"/>
          <arg line="--license-file ./compress/license.txt"/>
          <arg line="--source-dir ./src/main/js/nunaliit2/css/basic"/>
          <arg line="--output ./src/main/js/nunaliit2/css/basic/nunaliit2.css"/>
        </java>
        <java
        	jar="${compressor.css}"
        	fork="true"
        	dir="."
        	>
          <arg line="--config-file ./compress/nunaliit2-css-mobile.cfg"/>
          <arg line="--license-file ./compress/license.txt"/>
          <arg line="--source-dir ./src/main/js/nunaliit2/css/basic"/>
          <arg line="--output ./src/main/js/nunaliit2/css/basic/nunaliit2-mobile.css"/>
        </java>
    </target>

	<target
    	name="-library-compress-error"
    	description="Report error"
    	depends="-library-compress-conditions"
    	unless="compressor-tools-exists"
    	>
    	<fail message="Compressor tools not found: ${compressor.js} - ${compressor.css}"/>
    </target>

	<target name="-library-compress-conditions">
		<condition property="compressor-tools-exists">
			<and>
				<available file="${compressor.js}"/>
				<available file="${compressor.css}"/>
			</and>
		</condition>
	</target>

    <!-- =================================
          target: test

          Create links for HTML testing
         ================================= -->
    <target name="test" description="Build test links">
    	<delete dir="./src/main/js/js-external" failonerror="false"/>
        <exec dir="./src/main/webapp" executable="svn">
        	<arg line="export https://svn.gcrc.carleton.ca/nunaliit2/trunk/sdk/nunaliit2-js-external/src/main/js/js-external js-external"/>
        </exec>
    </target>

</project>

redpajama_set_name: RedPajamaGithub


text:
module.exports.globals = {
  _: true,
  async: true,
  sails: true,
  services: true,
  models: true
};


text:
Ext.define('OppUI.view.loadtestDashboard.loadtestreport.timeseriescombo.TimeSeriesComboBoxModel', {
    extend: 'Ext.app.ViewModel',
    alias: 'viewmodel.timeseriescombobox',
    data: {
        name: 'OppUI'
    },

    stores: {
        timesSeriesCombo: {
            autoLoad: true,
            fields: [ "display","value" ],
            proxy: {
                type: 'memory',
                reader: {
                    type: 'json'
                },
                data: [{"display":'Min', "value":'resp_min'}, {"display":'Average', "value":'resp_avg'},
                        {"display":'Median', "value":'resp_median'}, {"display":'Max', "value":'resp_max'},
                        {"display":'75th PCT', "value":'resp_pct75'}, {"display":'90th PCT', "value":'resp_pct90'},
                        {"display":'nth PCT', "value":'nPCT'},
                        {"display":'Transaction count', "value":'call_count'}, {"display":'Error count', "value":'error_count'},
                        {"display":'Std. Dev.', "value":'resp_stddev'}, {"display":'Total Bytes Rec.', "value":'total_bytes_received'},
                        {"display":'Total Bytes Sent', "value":'total_bytes_sent'}, {"display":'Total Bytes', "value":'total_bytes'}
                    ]
            }
        }
    }
});


text:
package ro.pub.acs.traffic.utils;

public class Results {
	public float speed;
	public double log, lat;
	public long timestamp;
	public double accuracy;

	public Results(float speed, double log, double lat, long timestamp) {
		this.speed = speed;
		this.log = log;
		this.lat = lat;
		this.timestamp = timestamp;
	}

	public String toString() {
		return this.log + " " + this.lat + " " + this.speed + " "
				+ this.timestamp;
	}
}


text:
class UILabel;
class UIEditField :
	public UIBox, public ITextInputReceiver
{
public:
	UIEditField(int, int, int, int);
	UIEditField(ClassReflectionNode* Targetprop);
	~UIEditField();
	void SetLabel(std::string lavel);
	void MouseMove(int x, int y) override;
	void GetValueText(std::string & string);
	bool MouseClick(int x, int y) override;
	void MouseClickUp(int x, int y) override;
	// Inherited via UIWidget
	void Render() override;
	void Update();
	void SendValue();
	bool CheckValidInput(char c);

	void UpdateScaled() override;

	void ProcessUIInputEvent(UIInputEvent& e) override;
	void ReceiveCommitedText(const std::string& text) override;
	std::string GetStartValue() override;
	void OnUpdate(const std::string & DisplayText) override;
	enum VectorComponent
	{
		X,
		Y,
		Z,
		W
	};
	VectorComponent Targetcomponent = VectorComponent::X;
private:

	UILabel* Textlabel = nullptr;
	UIBox* TextBox = nullptr;
	class UIButton* Toggle = nullptr;
	glm::vec3 colour = glm::vec3(0.8f);
	CollisionRect Rect;
	CollisionRect ValueDrawChangeRect;
	std::string nextext;
	std::string LastText;
	bool WasSelected = false;
	MemberValueType::Type FilterType = MemberValueType::Limit;
	EditValueType::Type EditMode = EditValueType::Value;
	bool Enabled = true;
	bool SupportsScroll = true;
	bool Scrolling = false;
	int startx = 0;
	float StartValue = 0.0f;
	float ScrollScale = 0.001f;
	ClassReflectionNode* Node = nullptr;
};


text:
package cz.cdv.datex2.handlers;

import eu.datex2.schema._2._2_0.D2LogicalModel;

public interface Datex2Handler {

	void handle(D2LogicalModel value);

}


text:
$(document).ready(function() {
    createForm();

});
//
// ------------------------ Create form
function createForm() {
    var dataJson = new Object({
        'form':'signup',
        'type':'web'
    });
    $.ajax({
        url: 'http://localhost:3000/endpoint',
        type: 'get',
        dataType: 'jsonp',
        jsonp: "callback",
        data: JSON.stringify(dataJson),
        timeout: 30000,
        headers: {"cache-control": "no-cache"},
        success: function (data) {
            console.log(data);

        },
        error: function (xhr, ajaxOptions, thrownErr) {

        },
        beforeSend: function () {

        }
    });
}


text:
import System.Environment(getArgs)
import Analyzer.Checker
import qualified Data.ByteString as BS

main = do
  (p:ws:_) <- getArgs
  hss <- headerFiles ws
  let validCaseTrie = toTrie hss
  headersAndSources <- headerAndSourceFiles p
  mapM_ (fixFile validCaseTrie) headersAndSources
    where fixFile valid h = do
              c <- BS.readFile h
              maybe
                (putStr ".")
                (\_c -> print ("fixed file " ++ h) >> BS.writeFile h _c)
                (fixIncludes c valid)


text:
package org.deidentifier.arx.gui.view.impl.common.table;

import org.eclipse.nebula.widgets.nattable.command.ILayerCommand;
import org.eclipse.nebula.widgets.nattable.layer.ILayer;

/**
 *
 */
public class FillLayerResetCommand implements ILayerCommand{

    @Override
    public ILayerCommand cloneCommand() {
        return new FillLayerResetCommand();
    }

    @Override
    public boolean convertToTargetLayer(ILayer targetLayer) {
        return true;
    }
}


text:
namespace net {

class X509Certificate;
typedef std::vector<scoped_refptr<X509Certificate>> CertificateList;

// TestRootCerts is a helper class for unit tests that is used to
// artificially mark a certificate as trusted, independent of the local
// machine configuration.
//
// Test roots can be added using the ScopedTestRoot class below. See the
// class documentation for usage and limitations.
class NET_EXPORT TestRootCerts {
 public:
  // Obtains the Singleton instance to the trusted certificates.
  static TestRootCerts* GetInstance();

  TestRootCerts(const TestRootCerts&) = delete;
  TestRootCerts& operator=(const TestRootCerts&) = delete;

  // Returns true if an instance exists, without forcing an initialization.
  static bool HasInstance();

  // Clears the trusted status of any certificates that were previously
  // marked trusted via Add().
  void Clear();

  // Returns true if there are no certificates that have been marked trusted.
  bool IsEmpty() const;

#if BUILDFLAG(IS_APPLE)
  CFArrayRef temporary_roots() const { return temporary_roots_; }

  // Modifies the root certificates of |trust_ref| to include the
  // certificates stored in |temporary_roots_|. If IsEmpty() is true, this
  // does not modify |trust_ref|.
  OSStatus FixupSecTrustRef(SecTrustRef trust_ref) const;
#elif BUILDFLAG(IS_WIN)
  HCERTSTORE temporary_roots() const { return temporary_roots_; }

  // Returns an HCERTCHAINENGINE suitable to be used for certificate
  // validation routines, or NULL to indicate that the default system chain
  // engine is appropriate.
  crypto::ScopedHCERTCHAINENGINE GetChainEngine() const;
#endif

  TrustStore* test_trust_store() { return &test_trust_store_; }

 private:
  friend struct base::LazyInstanceTraitsBase<TestRootCerts>;
  friend class ScopedTestRoot;

  TestRootCerts();
  ~TestRootCerts();

  // Marks |certificate| as trusted in the effective trust store
  // used by CertVerifier::Verify(). Returns false if the
  // certificate could not be marked trusted.
  bool Add(X509Certificate* certificate);

  // Performs platform-dependent operations.
  void Init();
  bool AddImpl(X509Certificate* certificate);
  void ClearImpl();

#if BUILDFLAG(IS_WIN)
  HCERTSTORE temporary_roots_;
#elif BUILDFLAG(IS_APPLE)
  base::ScopedCFTypeRef<CFMutableArrayRef> temporary_roots_;
#endif

  TrustStoreInMemory test_trust_store_;
};

// Scoped helper for unittests to handle safely managing trusted roots.
//
// Limitations:
// Multiple instances of ScopedTestRoot may be created at once, which will
// trust the union of the certs provided. However, when one of the
// ScopedTestRoot instances removes its trust, either by going out of scope, or
// by Reset() being called, *all* test root certs will be untrusted. (This
// limitation could be removed if a reason arises.)
class NET_EXPORT ScopedTestRoot {
 public:
  ScopedTestRoot();
  // Creates a ScopedTestRoot that adds |cert| to the TestRootCerts store.
  explicit ScopedTestRoot(X509Certificate* cert);
  // Creates a ScopedTestRoot that adds |certs| to the TestRootCerts store.
  explicit ScopedTestRoot(CertificateList certs);

  ScopedTestRoot(const ScopedTestRoot&) = delete;
  ScopedTestRoot& operator=(const ScopedTestRoot&) = delete;

  ScopedTestRoot(ScopedTestRoot&& other);
  ScopedTestRoot& operator=(ScopedTestRoot&& other);

  ~ScopedTestRoot();

  // Assigns |certs| to be the new test root certs. If |certs| is empty, undoes
  // any work the ScopedTestRoot may have previously done.
  // If |certs_| contains certificates (due to a prior call to Reset or due to
  // certs being passed at construction), the existing TestRootCerts store is
  // cleared.
  void Reset(CertificateList certs);

  // Returns true if this ScopedTestRoot has no certs assigned.
  bool IsEmpty() const { return certs_.empty(); }

 private:
  CertificateList certs_;
};

}  // namespace net

#endif  // NET_CERT_TEST_ROOT_CERTS_H_


text:
<?php
namespace pmill\Auth\Exceptions;

class TwoFactorAuthException extends \Exception
{

}


text:
package org.apache.lucene.util.packed;

import org.apache.lucene.store.IndexInput;

import java.io.IOException;

/* Reads directly from disk on each get */
class DirectPackedReader extends PackedInts.ReaderImpl {
  private final IndexInput in;
  private final long startPointer;
  private final long valueMask;

  public DirectPackedReader(int bitsPerValue, int valueCount, IndexInput in) {
    super(valueCount, bitsPerValue);
    this.in = in;

    startPointer = in.getFilePointer();
    if (bitsPerValue == 64) {
      valueMask = -1L;
    } else {
      valueMask = (1L << bitsPerValue) - 1;
    }
  }

  @Override
  public long get(int index) {
    final long majorBitPos = (long)index * bitsPerValue;
    final long elementPos = majorBitPos >>> 3;
    try {
      in.seek(startPointer + elementPos);

      final int bitPos = (int) (majorBitPos & 7);
      // round up bits to a multiple of 8 to find total bytes needed to read
      final int roundedBits = ((bitPos + bitsPerValue + 7) & ~7);
      // the number of extra bits read at the end to shift out
      int shiftRightBits = roundedBits - bitPos - bitsPerValue;

      long rawValue;
      switch (roundedBits >>> 3) {
        case 1:
          rawValue = in.readByte();
          break;
        case 2:
          rawValue = in.readShort();
          break;
        case 3:
          rawValue = ((long)in.readShort() << 8) | (in.readByte() & 0xFFL);
          break;
        case 4:
          rawValue = in.readInt();
          break;
        case 5:
          rawValue = ((long)in.readInt() << 8) | (in.readByte() & 0xFFL);
          break;
        case 6:
          rawValue = ((long)in.readInt() << 16) | (in.readShort() & 0xFFFFL);
          break;
        case 7:
          rawValue = ((long)in.readInt() << 24) | ((in.readShort() & 0xFFFFL) << 8) | (in.readByte() & 0xFFL);
          break;
        case 8:
          rawValue = in.readLong();
          break;
        case 9:
          // We must be very careful not to shift out relevant bits. So we account for right shift
          // we would normally do on return here, and reset it.
          rawValue = (in.readLong() << (8 - shiftRightBits)) | ((in.readByte() & 0xFFL) >>> shiftRightBits);
          shiftRightBits = 0;
          break;
        default:
          throw new AssertionError("bitsPerValue too large: " + bitsPerValue);
      }
      return (rawValue >>> shiftRightBits) & valueMask;

    } catch (IOException ioe) {
      throw new IllegalStateException("failed", ioe);
    }
  }

  @Override
  public long ramBytesUsed() {
    return 0;
  }
}


text:
package gov.healthit.chpl.auth.entity;

import java.util.Date;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

@Entity
@Table(name="invited_user_permission")
public class InvitationPermissionEntity {

	@Id
	@Basic( optional = false )
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column( name = "invited_user_permission_id", nullable = false  )
	private Long id;

	@ManyToOne(fetch=FetchType.LAZY)
    @JoinColumn(name="invited_user_id")
	private InvitationEntity invitedUser;

	@Column(name = "user_permission_id")
	private Long userPermissionId;

	@Column(name="creation_date")
	private Date creationDate;

	@Column(name="last_modified_user")
	private Long lastModifiedUser;

	@Column(name="last_modified_date")
	private Date lastModifiedDate;

	@Column(name="deleted")
	private Boolean deleted;

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Date getCreationDate() {
		return creationDate;
	}

	public void setCreationDate(Date creationDate) {
		this.creationDate = creationDate;
	}

	public Long getLastModifiedUser() {
		return lastModifiedUser;
	}

	public void setLastModifiedUser(Long lastModifiedUser) {
		this.lastModifiedUser = lastModifiedUser;
	}

	public Date getLastModifiedDate() {
		return lastModifiedDate;
	}

	public void setLastModifiedDate(Date lastModifiedDate) {
		this.lastModifiedDate = lastModifiedDate;
	}

	public Boolean getDeleted() {
		return deleted;
	}

	public void setDeleted(Boolean deleted) {
		this.deleted = deleted;
	}

	public Long getUserPermissionId() {
		return userPermissionId;
	}

	public void setUserPermissionId(Long userPermissionId) {
		this.userPermissionId = userPermissionId;
	}

	public InvitationEntity getInvitedUser() {
		return invitedUser;
	}

	public void setInvitedUser(InvitationEntity invitedUser) {
		this.invitedUser = invitedUser;
	}
}


text:
package org.easybatch.integration.apache.common.csv;

/**
 * Dummy class used for tests.
 *
 * @author Mahmoud Ben Hassine (mahmoud@benhassine.fr)
 */
public class Foo {

    private String firstName;

    private String lastName;

    private int age;

    private boolean married;

    public Foo() {
    }

    public boolean isMarried() {
        return married;
    }

    public void setMarried(boolean married) {
        this.married = married;
    }

    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    public String getFirstName() {
        return firstName;
    }

    public String getLastName() {
        return lastName;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

}


text:
package eu.luminis.elastic.search;

import eu.luminis.elastic.IndexDocumentHelper;
import eu.luminis.elastic.SingleClusterRestClientConfig;
import eu.luminis.elastic.TestConfig;
import eu.luminis.elastic.document.helpers.MessageEntity;
import eu.luminis.elastic.document.helpers.MessageEntityTypeReference;
import eu.luminis.elastic.index.IndexService;
import eu.luminis.elastic.search.response.HitsAggsResponse;
import eu.luminis.elastic.search.response.aggregations.Aggregation;
import eu.luminis.elastic.search.response.aggregations.bucket.DateHistogramAggregation;
import eu.luminis.elastic.search.response.aggregations.bucket.DateHistogramBucket;
import eu.luminis.elastic.search.response.aggregations.bucket.HistogramAggregation;
import eu.luminis.elastic.search.response.aggregations.bucket.HistogramBucket;
import eu.luminis.elastic.search.response.aggregations.bucket.TermsAggregation;
import eu.luminis.elastic.search.response.aggregations.metric.SingleValueMetricsAggregation;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.Collections;
import java.util.Date;

import static eu.luminis.elastic.SingleClusterRestClientFactoryBean.DEFAULT_CLUSTER_NAME;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {SingleClusterRestClientConfig.class, TestConfig.class})
public class SearchServiceAggsIT {
    public static final String TEST_AGGS = "test_aggs";
    public static final int NUM_DAYS_TO_SUBTRACT_1 = 1;
    public static final int NUM_DAYS_TO_SUBTRACT_2 = 2;
    public static final int NUM_DAYS_TO_SUBTRACT_5 = 5;
    public static final ZoneId ZONE_ID = ZoneId.of("Europe/Amsterdam");

    @Autowired
    private IndexService indexService;

    @Autowired
    private IndexDocumentHelper indexDocumentHelper;

    @Autowired
    private SingleClusterSearchService searchService;

    @Before
    public void setUp() throws Exception {
        Boolean test_aggs = indexService.indexExist(DEFAULT_CLUSTER_NAME, "test_aggs");
        if (test_aggs) {
            indexService.dropIndex(DEFAULT_CLUSTER_NAME, TEST_AGGS);
        }
        String indexProps = "{\n" +
                "  \"settings\": {\n" +
                "    \"number_of_replicas\": 0,\n" +
                "    \"number_of_shards\": 1\n" +
                "  },\n" +
                "  \"mappings\": {\n" +
                "    \"test_agg\": {\n" +
                "      \"properties\": {\n" +
                "        \"message\": {\n" +
                "          \"type\": \"text\"\n" +
                "        },\n" +
                "        \"tags\": {\n" +
                "          \"type\": \"keyword\"\n" +
                "        },\n" +
                "        \"year\": {\n" +
                "          \"type\": \"long\"\n" +
                "        },\n" +
                "        \"created\": {\n" +
                "          \"type\": \"date\"\n" +
                "        }\n" +
                "      }\n" +
                "    }\n" +
                "  }\n" +
                "}";
        indexService.createIndex(DEFAULT_CLUSTER_NAME, TEST_AGGS, indexProps);
        test_aggs = indexService.indexExist(DEFAULT_CLUSTER_NAME, "test_aggs");
        assertTrue("The index should now exist", test_aggs);

        indexDocumentHelper.indexDocument(TEST_AGGS, "test_agg", "one", "message one", Collections.singletonList("news"), 1970L, createDate(NUM_DAYS_TO_SUBTRACT_1));
        indexDocumentHelper.indexDocument(TEST_AGGS, "test_agg", "two", "message two", Collections.singletonList("blog"), 1980L, createDate(NUM_DAYS_TO_SUBTRACT_1));
        indexDocumentHelper.indexDocument(TEST_AGGS, "test_agg", "three", "message three", Collections.singletonList("news"), 1985L, createDate(NUM_DAYS_TO_SUBTRACT_2));
        indexDocumentHelper.indexDocument(TEST_AGGS, "test_agg", "four", "message four", Collections.singletonList("twitter"), 2000, createDate(NUM_DAYS_TO_SUBTRACT_5));
        indexService.refreshIndexes(DEFAULT_CLUSTER_NAME, TEST_AGGS);
    }

    @Test
    public void findTerms() {
        SearchByTemplateRequest request = SearchByTemplateRequest.create()
                .setIndexName(TEST_AGGS)
                .setTemplateName("find_message_aggs.twig")
                .setAddId(true)
                .setTypeReference(new MessageEntityTypeReference());

        HitsAggsResponse<MessageEntity> response = searchService.aggsByTemplate(request);

        assertEquals(4, response.getHits().size());
        Aggregation byTags = response.getAggregations().get("byTags");
        assertNotNull(byTags);
        assertTrue(byTags instanceof TermsAggregation);
        TermsAggregation termsbyTags = (TermsAggregation) byTags;
        assertEquals(3, termsbyTags.getBuckets().size());
    }

    @Test
    public void testFindTermsNoAggs() {
        SearchByTemplateRequest request = SearchByTemplateRequest.create()
                .setIndexName(TEST_AGGS)
                .setTemplateName("find_message.twig")
                .setAddId(true)
                .setTypeReference(new MessageEntityTypeReference());

        HitsAggsResponse<MessageEntity> response = searchService.aggsByTemplate(request);

        assertEquals(4, response.getHits().size());
        assertNull(response.getAggregations());
    }

    @Test
    public void testFindTermsNoHits() {
        SearchByTemplateRequest request = SearchByTemplateRequest.create()
                .setIndexName(TEST_AGGS)
                .setTemplateName("find_message_aggs_no_hits.twig")
                .setAddId(true)
                .setTypeReference(new MessageEntityTypeReference());

        HitsAggsResponse<MessageEntity> response = searchService.aggsByTemplate(request);

        assertEquals(0, response.getHits().size());
        Aggregation byTags = response.getAggregations().get("byTags");
        assertNotNull(byTags);
        assertTrue(byTags instanceof TermsAggregation);
        TermsAggregation termsbyTags = (TermsAggregation) byTags;
        assertEquals(3, termsbyTags.getBuckets().size());
    }

    @Test
    public void testCalculateAvgYearPerTag() {

        doCalculateYearPerTag((key, value) -> {
            switch (key) {
                case "news":
                    assertEquals((1970D + 1985D) / 2D, value, 0.01);
                    break;
                case "blog":
                    assertEquals(1980D, value, 0.01);
                    break;
                case "twitter":
                    assertEquals(2000D, value, 0.01);
                    break;
            }
        }, "terms_calculated_avg.twig");
    }

    @Test
    public void testCalculateSumPerYearTag() {
        doCalculateYearPerTag((key, value) -> {
            switch (key) {
                case "news":
                    assertEquals(1970D + 1985D, value, 0.01);
                    break;
                case "blog":
                    assertEquals(1980D, value, 0.01);
                    break;
                case "twitter":
                    assertEquals(2000D, value, 0.01);
                    break;
            }
        }, "terms_calculated_sum.twig");
    }

    @Test
    public void testCalculateMinPerYearTag() {
        doCalculateYearPerTag((key, value) -> {
            switch (key) {
                case "news":
                    assertEquals(1970D, value, 0.01);
                    break;
                case "blog":
                    assertEquals(1980D, value, 0.01);
                    break;
                case "twitter":
                    assertEquals(2000D, value, 0.01);
                    break;
            }
        }, "terms_calculated_min.twig");
    }

    @Test
    public void testCalculateMaxPerYearTag() {
        doCalculateYearPerTag((key, value) -> {
            switch (key) {
                case "news":
                    assertEquals(1985D, value, 0.01);
                    break;
                case "blog":
                    assertEquals(1980D, value, 0.01);
                    break;
                case "twitter":
                    assertEquals(2000D, value, 0.01);
                    break;
            }
        }, "terms_calculated_max.twig");
    }

    @Test
    public void testCalculateCardinalityPerYearTag() {
        doCalculateYearPerTag((key, value) -> {
            switch (key) {
                case "news":
                    assertEquals(2, value, 0.01);
                    break;
                case "blog":
                    assertEquals(1, value, 0.01);
                    break;
                case "twitter":
                    assertEquals(1, value, 0.01);
                    break;
            }
        }, "terms_calculated_cardinality.twig");
    }

    @Test
    public void testCalculateValueCountPerYearTag() {
        doCalculateYearPerTag((key, value) -> {
            switch (key) {
                case "news":
                    assertEquals(2, value, 0.01);
                    break;
                case "blog":
                    assertEquals(1, value, 0.01);
                    break;
                case "twitter":
                    assertEquals(1, value, 0.01);
                    break;
            }
        }, "terms_calculated_value_count.twig");
    }

    private void doCalculateYearPerTag(CheckCalculaterAggregation check, String template) {
        SearchByTemplateRequest request = SearchByTemplateRequest.create()
                .setIndexName(TEST_AGGS)
                .setTemplateName(template)
                .setAddId(true)
                .setTypeReference(new MessageEntityTypeReference());

        HitsAggsResponse<MessageEntity> response = searchService.aggsByTemplate(request);

        assertEquals(0, response.getHits().size());
        Aggregation termsCalcTerms = response.getAggregations().get("calcTerms");
        assertNotNull(termsCalcTerms);
        assertTrue(termsCalcTerms instanceof TermsAggregation);
        TermsAggregation terms = (TermsAggregation) termsCalcTerms;

        terms.getBuckets().forEach(bucket -> {
            Aggregation aggregation = bucket.getAggregations().get("calculated");
            assertTrue(aggregation instanceof SingleValueMetricsAggregation);
            SingleValueMetricsAggregation singleValueMetricsAggregation = (SingleValueMetricsAggregation) aggregation;

            Double value = singleValueMetricsAggregation.getValue();

            String key = bucket.getKey();
            check.check(key, value);
        });
    }

    @Test
    public void testFindHistogramByYear() {
        SearchByTemplateRequest request = SearchByTemplateRequest.create()
                .setIndexName(TEST_AGGS)
                .setTemplateName("find_message_range_aggs_no_hits.twig")
                .setAddId(true)
                .setTypeReference(new MessageEntityTypeReference());

        HitsAggsResponse<MessageEntity> response = searchService.aggsByTemplate(request);

        assertEquals(0, response.getHits().size());
        Aggregation byHistogram = response.getAggregations().get("byHistogram");
        assertNotNull(byHistogram);
        assertTrue(byHistogram instanceof HistogramAggregation);
        HistogramAggregation histoAggs = (HistogramAggregation) byHistogram;
        assertEquals(4, histoAggs.getBuckets().size());

        checkHistoBucket(histoAggs.getBuckets().get(0), 1, "1970.0");
        checkHistoBucket(histoAggs.getBuckets().get(1), 2, "1980.0");
        checkHistoBucket(histoAggs.getBuckets().get(2), 0, "1990.0");
        checkHistoBucket(histoAggs.getBuckets().get(3), 1, "2000.0");
    }

    @Test
    public void testFindDateHistogramByDay() {
        SearchByTemplateRequest request = SearchByTemplateRequest.create()
                .setIndexName(TEST_AGGS)
                .setTemplateName("find_message_date_histo_no_hits.twig")
                .setAddId(true)
                .setTypeReference(new MessageEntityTypeReference());

        HitsAggsResponse<MessageEntity> response = searchService.aggsByTemplate(request);

        assertEquals(0, response.getHits().size());
        assertEquals(4, response.getTotalHits());

        Aggregation byDateHistogram = response.getAggregations().get("byDateHistogram");
        assertNotNull(byDateHistogram);
        assertTrue(byDateHistogram instanceof DateHistogramAggregation);
        DateHistogramAggregation histoAggs = (DateHistogramAggregation) byDateHistogram;
        assertEquals(5, histoAggs.getBuckets().size());

        checkDateHistoBucket(histoAggs.getBuckets().get(0),
                1, expectedMilis(NUM_DAYS_TO_SUBTRACT_5), expectKeyAsString(NUM_DAYS_TO_SUBTRACT_5));
        checkDateHistoBucket(histoAggs.getBuckets().get(1),
                0, expectedMilis(4), expectKeyAsString(4));
        checkDateHistoBucket(histoAggs.getBuckets().get(2),
                0, expectedMilis(3), expectKeyAsString(3));
        checkDateHistoBucket(histoAggs.getBuckets().get(3),
                1, expectedMilis(NUM_DAYS_TO_SUBTRACT_2), expectKeyAsString(NUM_DAYS_TO_SUBTRACT_2));
        checkDateHistoBucket(histoAggs.getBuckets().get(4),
                2, expectedMilis(NUM_DAYS_TO_SUBTRACT_1), expectKeyAsString(NUM_DAYS_TO_SUBTRACT_1));
    }

    @Test
    public void testFindDateHistogramByDayNestedTerms() {
        SearchByTemplateRequest request = SearchByTemplateRequest.create()
                .setIndexName(TEST_AGGS)
                .setTemplateName("date_histo_nested_terms.twig")
                .setAddId(true)
                .setTypeReference(new MessageEntityTypeReference());

        HitsAggsResponse<MessageEntity> response = searchService.aggsByTemplate(request);

        assertEquals(0, response.getHits().size());
        assertEquals(4, response.getTotalHits());

        Aggregation byDateHistogram = response.getAggregations().get("byDateHistogram");
        assertNotNull(byDateHistogram);
        assertTrue(byDateHistogram instanceof DateHistogramAggregation);
        DateHistogramAggregation histoAggs = (DateHistogramAggregation) byDateHistogram;
        assertEquals(5, histoAggs.getBuckets().size());

        DateHistogramBucket bucket = histoAggs.getBuckets().get(4);
        checkDateHistoBucket(bucket,
                2, expectedMilis(NUM_DAYS_TO_SUBTRACT_1), expectKeyAsString(NUM_DAYS_TO_SUBTRACT_1));

        Aggregation byTags = bucket.getAggregations().get("byTags");
        assertTrue(byTags instanceof TermsAggregation);
        TermsAggregation byTagsTerms = (TermsAggregation) byTags;
        assertEquals(2, byTagsTerms.getBuckets().size());
        byTagsTerms.getBuckets().forEach(termsBucket -> {
            switch (termsBucket.getKey()) {
                case "news":
                case "blog":
                    break;
                default:
                    fail("tag should have been news or blog");
            }
        });
    }

    private void checkHistoBucket(HistogramBucket bucket, long expectedCount, String expectedKey) {
        assertEquals(expectedCount, bucket.getDocCount().longValue());
        assertEquals(expectedKey, bucket.getKey());
    }

    private void checkDateHistoBucket(DateHistogramBucket bucket,
                                      long expectedCount,
                                      long expectedKey,
                                      String expectedKeyAsString) {
        assertEquals(expectedCount, bucket.getDocCount().longValue());
        assertEquals(expectedKey, bucket.getKey().longValue());
        assertEquals(expectedKeyAsString, bucket.getKeyAsString());
    }

    private Date createDate(int numDaysToSubtract) {
        LocalDateTime date = LocalDateTime.now();

        LocalDateTime newDate = date.minusDays(numDaysToSubtract);

        return Date.from(newDate.atZone(ZoneId.systemDefault()).toInstant());
    }

    private long expectedMilis(int numDaysToSubtract) {
        LocalDate date = LocalDate.now();

        LocalDateTime newDate = LocalDateTime.from(date.minusDays(numDaysToSubtract).atStartOfDay(ZONE_ID));

        return Date.from(newDate.atZone(ZoneId.systemDefault()).toInstant()).getTime();
    }

    private String expectKeyAsString(int numDaysToSubtract) {
        LocalDate date = LocalDate.now();

        LocalDate newDate = date.minusDays(numDaysToSubtract);

        DateTimeFormatter formatter = DateTimeFormatter.ISO_DATE;

        return newDate.format(formatter);
    }

    private interface CheckCalculaterAggregation {
        void check(String key, Double value);
    }
}


text:
<?php

namespace Proyectos\DepartamentoBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * Asignatura
 *
 * @ORM\Table(name="asignatura", indexes={@ORM\Index(name="fk_asignatura_alumno_idx", columns={"alumno_idalumno"}), @ORM\Index(name="fk_asignatura_profesor1_idx", columns={"profesor_idprofesor"})})
 * @ORM\Entity
 */
class Asignatura
{
    /**
     * @var integer
     *
     * @ORM\Column(name="idasignatura", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="IDENTITY")
     */
    private $idasignatura;

    /**
     * @var string
     *
     * @ORM\Column(name="nombre", type="string", length=45, nullable=true)
     */
    private $nombre;

    /**
     * @var \Proyectos\DepartamentoBundle\Entity\Alumno
     *
     * @ORM\ManyToOne(targetEntity="Proyectos\DepartamentoBundle\Entity\Alumno")
     * @ORM\JoinColumns({
     *   @ORM\JoinColumn(name="alumno_idalumno", referencedColumnName="idalumno")
     * })
     */
    private $alumnoalumno;

    /**
     * @var \Proyectos\DepartamentoBundle\Entity\Profesor
     *
     * @ORM\ManyToOne(targetEntity="Proyectos\DepartamentoBundle\Entity\Profesor")
     * @ORM\JoinColumns({
     *   @ORM\JoinColumn(name="profesor_idprofesor", referencedColumnName="idprofesor")
     * })
     */
    private $profesorprofesor;

    /**
     * Get idasignatura
     *
     * @return integer
     */
    public function getIdasignatura()
    {
        return $this->idasignatura;
    }

    /**
     * Set nombre
     *
     * @param string $nombre
     * @return Asignatura
     */
    public function setNombre($nombre)
    {
        $this->nombre = $nombre;

        return $this;
    }

    /**
     * Get nombre
     *
     * @return string
     */
    public function getNombre()
    {
        return $this->nombre;
    }

    /**
     * Set alumnoalumno
     *
     * @param \Proyectos\DepartamentoBundle\Entity\Alumno $alumnoalumno
     * @return Asignatura
     */
    public function setAlumnoalumno(\Proyectos\DepartamentoBundle\Entity\Alumno $alumnoalumno = null)
    {
        $this->alumnoalumno = $alumnoalumno;

        return $this;
    }

    /**
     * Get alumnoalumno
     *
     * @return \Proyectos\DepartamentoBundle\Entity\Alumno
     */
    public function getAlumnoalumno()
    {
        return $this->alumnoalumno;
    }

    /**
     * Set profesorprofesor
     *
     * @param \Proyectos\DepartamentoBundle\Entity\Profesor $profesorprofesor
     * @return Asignatura
     */
    public function setProfesorprofesor(\Proyectos\DepartamentoBundle\Entity\Profesor $profesorprofesor = null)
    {
        $this->profesorprofesor = $profesorprofesor;

        return $this;
    }

    /**
     * Get profesorprofesor
     *
     * @return \Proyectos\DepartamentoBundle\Entity\Profesor
     */
    public function getProfesorprofesor()
    {
        return $this->profesorprofesor;
    }
}


text:
// This is an independent project of an individual developer. Dear PVS-Studio, please check it.
// PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com

using ITCC.YandexSpeechKitClient.Attributes;

namespace ITCC.YandexSpeechKitClient.Enums
{
    /// <summary>
    /// Language model used for recognition.
    /// </summary>
    public enum SpeechModel
    {
        /// <summary>
        /// Phrases (3-5 words) on different topics, including queries in search engines (on websites).
        /// </summary>
        [EnumValueString("queries")]
        Queries,

        /// <summary>
        /// Addresses and names of businesses and geographical features.
        /// </summary>
        [EnumValueString("maps")]
        Maps,

        /// <summary>
        /// Names of months, ordinal numbers, and cardinal numbers.
        /// </summary>
        [EnumValueString("dates")]
        Dates,

        /// <summary>
        /// First names and last names and requests to connect to someone on the phone.
        /// </summary>
        [EnumValueString("names")]
        Names,

        /// <summary>
        /// Cardinal numbers from 1 to 999 and separators — comma, dot, and dash. The model is for dictating phone numbers, account numbers, or document numbers.
        /// </summary>
        [EnumValueString("numbers")]
        Numbers,

        /// <summary>
        /// Titles of musical works and names of artists. This model is not intended for recognizing fragments of music. It is only for recognizing names of songs and performers.
        /// </summary>
        [EnumValueString("music")]
        Music,

        /// <summary>
        /// Phrases related to making orders in online stores (confirming an order and the delivery method).
        /// </summary>
        [EnumValueString("buying")]
        Buying
    }
}


text:
#ifndef _OS_OSBYTEORDER_H
#define _OS_OSBYTEORDER_H

#include <stdint.h>
#include <libkern/_OSByteOrder.h>

/* Macros for swapping constant values in the preprocessing stage. */
#define OSSwapConstInt16(x)     __DARWIN_OSSwapConstInt16(x)
#define OSSwapConstInt32(x)     __DARWIN_OSSwapConstInt32(x)
#define OSSwapConstInt64(x)     __DARWIN_OSSwapConstInt64(x)

#if !defined(__DARWIN_OS_INLINE)
# if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
#        define __DARWIN_OS_INLINE static inline
# elif defined(__MWERKS__) || defined(__cplusplus)
#        define __DARWIN_OS_INLINE static inline
# else
#        define __DARWIN_OS_INLINE static __inline__
# endif
#endif

#if defined(__GNUC__)

#if (defined(__i386__) || defined(__x86_64__))
#include <libkern/i386/OSByteOrder.h>
#elif defined (__arm__) || defined(__arm64__)
#include <libkern/arm/OSByteOrder.h>
#else
#include <libkern/machine/OSByteOrder.h>
#endif

#else /* ! __GNUC__ */

#include <libkern/machine/OSByteOrder.h>

#endif /* __GNUC__ */

#define OSSwapInt16(x)  __DARWIN_OSSwapInt16(x)
#define OSSwapInt32(x)  __DARWIN_OSSwapInt32(x)
#define OSSwapInt64(x)  __DARWIN_OSSwapInt64(x)

enum {
	OSUnknownByteOrder,
	OSLittleEndian,
	OSBigEndian
};

__DARWIN_OS_INLINE
int32_t
OSHostByteOrder(void)
{
#if defined(__LITTLE_ENDIAN__)
	return OSLittleEndian;
#elif defined(__BIG_ENDIAN__)
	return OSBigEndian;
#else
	return OSUnknownByteOrder;
#endif
}

#define OSReadBigInt(x, y)              OSReadBigInt32(x, y)
#define OSWriteBigInt(x, y, z)          OSWriteBigInt32(x, y, z)
#define OSSwapBigToHostInt(x)           OSSwapBigToHostInt32(x)
#define OSSwapHostToBigInt(x)           OSSwapHostToBigInt32(x)
#define OSReadLittleInt(x, y)           OSReadLittleInt32(x, y)
#define OSWriteLittleInt(x, y, z)       OSWriteLittleInt32(x, y, z)
#define OSSwapHostToLittleInt(x)        OSSwapHostToLittleInt32(x)
#define OSSwapLittleToHostInt(x)        OSSwapLittleToHostInt32(x)

/* Functions for loading native endian values. */

__DARWIN_OS_INLINE
uint16_t
_OSReadInt16(
	const volatile void               * base,
	uintptr_t                     byteOffset
	)
{
	return *(volatile uint16_t *)((uintptr_t)base + byteOffset);
}

__DARWIN_OS_INLINE
uint32_t
_OSReadInt32(
	const volatile void               * base,
	uintptr_t                     byteOffset
	)
{
	return *(volatile uint32_t *)((uintptr_t)base + byteOffset);
}

__DARWIN_OS_INLINE
uint64_t
_OSReadInt64(
	const volatile void               * base,
	uintptr_t                     byteOffset
	)
{
	return *(volatile uint64_t *)((uintptr_t)base + byteOffset);
}

/* Functions for storing native endian values. */

__DARWIN_OS_INLINE
void
_OSWriteInt16(
	volatile void               * base,
	uintptr_t                     byteOffset,
	uint16_t                      data
	)
{
	*(volatile uint16_t *)((uintptr_t)base + byteOffset) = data;
}

__DARWIN_OS_INLINE
void
_OSWriteInt32(
	volatile void               * base,
	uintptr_t                     byteOffset,
	uint32_t                      data
	)
{
	*(volatile uint32_t *)((uintptr_t)base + byteOffset) = data;
}

__DARWIN_OS_INLINE
void
_OSWriteInt64(
	volatile void               * base,
	uintptr_t                     byteOffset,
	uint64_t                      data
	)
{
	*(volatile uint64_t *)((uintptr_t)base + byteOffset) = data;
}

#if             defined(__BIG_ENDIAN__)

/* Functions for loading big endian to host endianess. */

#define OSReadBigInt16(base, byteOffset) _OSReadInt16(base, byteOffset)
#define OSReadBigInt32(base, byteOffset) _OSReadInt32(base, byteOffset)
#define OSReadBigInt64(base, byteOffset) _OSReadInt64(base, byteOffset)

/* Functions for storing host endianess to big endian. */

#define OSWriteBigInt16(base, byteOffset, data) _OSWriteInt16(base, byteOffset, data)
#define OSWriteBigInt32(base, byteOffset, data) _OSWriteInt32(base, byteOffset, data)
#define OSWriteBigInt64(base, byteOffset, data) _OSWriteInt64(base, byteOffset, data)

/* Functions for loading little endian to host endianess. */

#define OSReadLittleInt16(base, byteOffset) OSReadSwapInt16(base, byteOffset)
#define OSReadLittleInt32(base, byteOffset) OSReadSwapInt32(base, byteOffset)
#define OSReadLittleInt64(base, byteOffset) OSReadSwapInt64(base, byteOffset)

/* Functions for storing host endianess to little endian. */

#define OSWriteLittleInt16(base, byteOffset, data) OSWriteSwapInt16(base, byteOffset, data)
#define OSWriteLittleInt32(base, byteOffset, data) OSWriteSwapInt32(base, byteOffset, data)
#define OSWriteLittleInt64(base, byteOffset, data) OSWriteSwapInt64(base, byteOffset, data)

/* Host endianess to big endian byte swapping macros for constants. */

#define OSSwapHostToBigConstInt16(x) ((uint16_t)(x))
#define OSSwapHostToBigConstInt32(x) ((uint32_t)(x))
#define OSSwapHostToBigConstInt64(x) ((uint64_t)(x))

/* Generic host endianess to big endian byte swapping functions. */

#define OSSwapHostToBigInt16(x) ((uint16_t)(x))
#define OSSwapHostToBigInt32(x) ((uint32_t)(x))
#define OSSwapHostToBigInt64(x) ((uint64_t)(x))

/* Host endianess to little endian byte swapping macros for constants. */

#define OSSwapHostToLittleConstInt16(x) OSSwapConstInt16(x)
#define OSSwapHostToLittleConstInt32(x) OSSwapConstInt32(x)
#define OSSwapHostToLittleConstInt64(x) OSSwapConstInt64(x)

/* Generic host endianess to little endian byte swapping functions. */

#define OSSwapHostToLittleInt16(x) OSSwapInt16(x)
#define OSSwapHostToLittleInt32(x) OSSwapInt32(x)
#define OSSwapHostToLittleInt64(x) OSSwapInt64(x)

/* Big endian to host endianess byte swapping macros for constants. */

#define OSSwapBigToHostConstInt16(x) ((uint16_t)(x))
#define OSSwapBigToHostConstInt32(x) ((uint32_t)(x))
#define OSSwapBigToHostConstInt64(x) ((uint64_t)(x))

/* Generic big endian to host endianess byte swapping functions. */

#define OSSwapBigToHostInt16(x) ((uint16_t)(x))
#define OSSwapBigToHostInt32(x) ((uint32_t)(x))
#define OSSwapBigToHostInt64(x) ((uint64_t)(x))

/* Little endian to host endianess byte swapping macros for constants. */

#define OSSwapLittleToHostConstInt16(x) OSSwapConstInt16(x)
#define OSSwapLittleToHostConstInt32(x) OSSwapConstInt32(x)
#define OSSwapLittleToHostConstInt64(x) OSSwapConstInt64(x)

/* Generic little endian to host endianess byte swapping functions. */

#define OSSwapLittleToHostInt16(x) OSSwapInt16(x)
#define OSSwapLittleToHostInt32(x) OSSwapInt32(x)
#define OSSwapLittleToHostInt64(x) OSSwapInt64(x)

#elif           defined(__LITTLE_ENDIAN__)

/* Functions for loading big endian to host endianess. */

#define OSReadBigInt16(base, byteOffset) OSReadSwapInt16(base, byteOffset)
#define OSReadBigInt32(base, byteOffset) OSReadSwapInt32(base, byteOffset)
#define OSReadBigInt64(base, byteOffset) OSReadSwapInt64(base, byteOffset)

/* Functions for storing host endianess to big endian. */

#define OSWriteBigInt16(base, byteOffset, data) OSWriteSwapInt16(base, byteOffset, data)
#define OSWriteBigInt32(base, byteOffset, data) OSWriteSwapInt32(base, byteOffset, data)
#define OSWriteBigInt64(base, byteOffset, data) OSWriteSwapInt64(base, byteOffset, data)

/* Functions for loading little endian to host endianess. */

#define OSReadLittleInt16(base, byteOffset) _OSReadInt16(base, byteOffset)
#define OSReadLittleInt32(base, byteOffset) _OSReadInt32(base, byteOffset)
#define OSReadLittleInt64(base, byteOffset) _OSReadInt64(base, byteOffset)

/* Functions for storing host endianess to little endian. */

#define OSWriteLittleInt16(base, byteOffset, data) _OSWriteInt16(base, byteOffset, data)
#define OSWriteLittleInt32(base, byteOffset, data) _OSWriteInt32(base, byteOffset, data)
#define OSWriteLittleInt64(base, byteOffset, data) _OSWriteInt64(base, byteOffset, data)

/* Host endianess to big endian byte swapping macros for constants. */

#define OSSwapHostToBigConstInt16(x) OSSwapConstInt16(x)
#define OSSwapHostToBigConstInt32(x) OSSwapConstInt32(x)
#define OSSwapHostToBigConstInt64(x) OSSwapConstInt64(x)

/* Generic host endianess to big endian byte swapping functions. */

#define OSSwapHostToBigInt16(x) OSSwapInt16(x)
#define OSSwapHostToBigInt32(x) OSSwapInt32(x)
#define OSSwapHostToBigInt64(x) OSSwapInt64(x)

/* Host endianess to little endian byte swapping macros for constants. */

#define OSSwapHostToLittleConstInt16(x) ((uint16_t)(x))
#define OSSwapHostToLittleConstInt32(x) ((uint32_t)(x))
#define OSSwapHostToLittleConstInt64(x) ((uint64_t)(x))

/* Generic host endianess to little endian byte swapping functions. */

#define OSSwapHostToLittleInt16(x) ((uint16_t)(x))
#define OSSwapHostToLittleInt32(x) ((uint32_t)(x))
#define OSSwapHostToLittleInt64(x) ((uint64_t)(x))

/* Big endian to host endianess byte swapping macros for constants. */

#define OSSwapBigToHostConstInt16(x) OSSwapConstInt16(x)
#define OSSwapBigToHostConstInt32(x) OSSwapConstInt32(x)
#define OSSwapBigToHostConstInt64(x) OSSwapConstInt64(x)

/* Generic big endian to host endianess byte swapping functions. */

#define OSSwapBigToHostInt16(x) OSSwapInt16(x)
#define OSSwapBigToHostInt32(x) OSSwapInt32(x)
#define OSSwapBigToHostInt64(x) OSSwapInt64(x)

/* Little endian to host endianess byte swapping macros for constants. */

#define OSSwapLittleToHostConstInt16(x) ((uint16_t)(x))
#define OSSwapLittleToHostConstInt32(x) ((uint32_t)(x))
#define OSSwapLittleToHostConstInt64(x) ((uint64_t)(x))

/* Generic little endian to host endianess byte swapping functions. */

#define OSSwapLittleToHostInt16(x) ((uint16_t)(x))
#define OSSwapLittleToHostInt32(x) ((uint32_t)(x))
#define OSSwapLittleToHostInt64(x) ((uint64_t)(x))

#else
#error Unknown endianess.
#endif

#endif /* ! _OS_OSBYTEORDER_H */


text:
package io.crate.core.collections;

import java.util.Collections;
import java.util.Iterator;

public interface Bucket extends Iterable<Row> {

    Bucket EMPTY = new Bucket() {
        @Override
        public Iterator<Row> iterator() {
            return Collections.emptyIterator();
        }

        @Override
        public int size() {
            return 0;
        }

        @Override
        public String toString() {
            return "Empty Bucket";
        }
    };

    /**
     * Returns the number of rows in this bucket.
     *
     * @return the number of rows
     */
    int size();
}