text:
package com.mindorks.framework.mvp.ui.feed.blogs;

import android.content.Intent;
import android.net.Uri;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.mindorks.framework.mvp.R;
import com.mindorks.framework.mvp.data.network.model.BlogResponse;
import com.mindorks.framework.mvp.ui.base.BaseViewHolder;
import com.mindorks.framework.mvp.utils.AppLogger;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by Janisharali on 25-05-2017.
 */

public class BlogAdapter extends RecyclerView.Adapter<BaseViewHolder> {

    public static final int VIEW_TYPE_EMPTY = 0;
    public static final int VIEW_TYPE_NORMAL = 1;

    private Callback mCallback;
    private List<BlogResponse.Blog> mBlogResponseList;

    public BlogAdapter(List<BlogResponse.Blog> blogResponseList) {
        mBlogResponseList = blogResponseList;
    }

    public void setCallback(Callback callback) {
        mCallback = callback;
    }

    @Override
    public void onBindViewHolder(BaseViewHolder holder, int position) {
        holder.onBind(position);
    }

    @Override
    public BaseViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {

        switch (viewType) {
            case VIEW_TYPE_NORMAL:
                return new ViewHolder(
                        LayoutInflater.from(parent.getContext()).inflate(R.layout.item_blog_view, parent, false));
            case VIEW_TYPE_EMPTY:
            default:
                return new EmptyViewHolder(
                        LayoutInflater.from(parent.getContext()).inflate(R.layout.item_empty_view, parent, false));
        }
    }

    @Override
    public int getItemViewType(int position) {
        if (mBlogResponseList != null && mBlogResponseList.size() > 0) {
            return VIEW_TYPE_NORMAL;
        } else {
            return VIEW_TYPE_EMPTY;
        }
    }

    @Override
    public int getItemCount() {
        if (mBlogResponseList != null && mBlogResponseList.size() > 0) {
            return mBlogResponseList.size();
        } else {
            return 1;
        }
    }

    public void addItems(List<BlogResponse.Blog> blogList) {
        mBlogResponseList.addAll(blogList);
        notifyDataSetChanged();
    }

    public interface Callback {
        void onBlogEmptyViewRetryClick();
    }

    public class ViewHolder extends BaseViewHolder {

        @BindView(R.id.cover_image_view)
        ImageView coverImageView;

        @BindView(R.id.title_text_view)
        TextView titleTextView;

        @BindView(R.id.author_text_view)
        TextView authorTextView;

        @BindView(R.id.date_text_view)
        TextView dateTextView;

        @BindView(R.id.content_text_view)
        TextView contentTextView;

        public ViewHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }

        protected void clear() {
            coverImageView.setImageDrawable(null);
            titleTextView.setText("");
            contentTextView.setText("");
        }

        public void onBind(int position) {
            super.onBind(position);

            final BlogResponse.Blog blog = mBlogResponseList.get(position);

            if (blog.getCoverImgUrl() != null) {
                Glide.with(itemView.getContext())
                        .load(blog.getCoverImgUrl())
                        .asBitmap()
                        .centerCrop()
                        .into(coverImageView);
            }

            if (blog.getTitle() != null) {
                titleTextView.setText(blog.getTitle());
            }

            if (blog.getAuthor() != null) {
                authorTextView.setText(blog.getAuthor());
            }

            if (blog.getDate() != null) {
                dateTextView.setText(blog.getDate());
            }

            if (blog.getDescription() != null) {
                contentTextView.setText(blog.getDescription());
            }

            itemView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (blog.getBlogUrl() != null) {
                        try {
                            Intent intent = new Intent();
                            intent.setAction(Intent.ACTION_VIEW);
                            intent.addCategory(Intent.CATEGORY_BROWSABLE);
                            intent.setData(Uri.parse(blog.getBlogUrl()));
                            itemView.getContext().startActivity(intent);
                        } catch (Exception e) {
                            AppLogger.d("url error");
                        }
                    }
                }
            });
        }
    }

    public class EmptyViewHolder extends BaseViewHolder {

        @BindView(R.id.btn_retry)
        Button retryButton;

        @BindView(R.id.tv_message)
        TextView messageTextView;

        public EmptyViewHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }

        @Override
        protected void clear() {

        }

        @OnClick(R.id.btn_retry)
        void onRetryClick() {
            if (mCallback != null)
                mCallback.onBlogEmptyViewRetryClick();
        }
    }
}


text:
package org.apache.tomcat.util.compat;

import java.util.Locale;

public class JreVendor {

    static {
        /**
         * There are a few places where Tomcat either accesses JVM internals
         * (e.g. the memory leak protection) or where feature support varies
         * between JVMs (e.g. SPNEGO). These flags exist to enable Tomcat to
         * adjust its behaviour based on the vendor of the JVM. In an ideal
         * world this code would not exist.
         */
        String vendor = System.getProperty("java.vendor", "");
        vendor = vendor.toLowerCase(Locale.ENGLISH);

        if (vendor.startsWith("oracle") || vendor.startsWith("sun")) {
            IS_ORACLE_JVM = true;
            IS_IBM_JVM = false;
        } else if (vendor.contains("ibm")) {
            IS_ORACLE_JVM = false;
            IS_IBM_JVM = true;
        } else {
            IS_ORACLE_JVM = false;
            IS_IBM_JVM = false;
        }
    }

    public static final boolean IS_ORACLE_JVM;

    public static final boolean IS_IBM_JVM;
}

redpajama_set_name: RedPajamaGithub


text:
package org.apache.metamodel.json;

import java.io.File;
import java.io.InputStream;

import org.apache.metamodel.DataContext;
import org.apache.metamodel.MetaModelException;
import org.apache.metamodel.MetaModelHelper;
import org.apache.metamodel.QueryPostprocessDataContext;
import org.apache.metamodel.convert.DocumentConverter;
import org.apache.metamodel.data.CachingDataSetHeader;
import org.apache.metamodel.data.DataSet;
import org.apache.metamodel.data.DataSetHeader;
import org.apache.metamodel.data.DocumentSource;
import org.apache.metamodel.data.DocumentSourceDataSet;
import org.apache.metamodel.data.MaxRowsDataSet;
import org.apache.metamodel.data.MaxRowsDocumentSource;
import org.apache.metamodel.query.SelectItem;
import org.apache.metamodel.schema.Column;
import org.apache.metamodel.schema.Schema;
import org.apache.metamodel.schema.Table;
import org.apache.metamodel.schema.builder.DocumentSourceProvider;
import org.apache.metamodel.schema.builder.SchemaBuilder;
import org.apache.metamodel.schema.builder.SingleTableInferentialSchemaBuilder;
import org.apache.metamodel.util.FileHelper;
import org.apache.metamodel.util.FileResource;
import org.apache.metamodel.util.Resource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.MappingJsonFactory;

/**
 * {@link DataContext} implementation that works on JSON files or
 * {@link Resource}s.
 */
public class JsonDataContext extends QueryPostprocessDataContext implements DocumentSourceProvider {

    private static final Logger logger = LoggerFactory.getLogger(JsonDataContext.class);

    private final Resource _resource;
    private final SchemaBuilder _schemaBuilder;

    public JsonDataContext(File file) {
        this(new FileResource(file));
    }

    public JsonDataContext(Resource resource) {
        this(resource, new SingleTableInferentialSchemaBuilder(resource));
    }

    public JsonDataContext(Resource resource, SchemaBuilder schemaBuilder) {
        _resource = resource;
        _schemaBuilder = schemaBuilder;
    }

    @Override
    protected Schema getMainSchema() throws MetaModelException {
        _schemaBuilder.offerSources(this);
        return _schemaBuilder.build();
    }

    @Override
    protected String getMainSchemaName() throws MetaModelException {
        return _schemaBuilder.getSchemaName();
    }

    @Override
    protected DataSet materializeMainSchemaTable(Table table, Column[] columns, int maxRows) {
        final DocumentConverter documentConverter = _schemaBuilder.getDocumentConverter(table);
        final SelectItem[] selectItems = MetaModelHelper.createSelectItems(columns);
        final DataSetHeader header = new CachingDataSetHeader(selectItems);
        final DocumentSource documentSource = getDocumentSourceForTable(table.getName());

        DataSet dataSet = new DocumentSourceDataSet(header, documentSource, documentConverter);

        if (maxRows > 0) {
            dataSet = new MaxRowsDataSet(dataSet, maxRows);
        }

        return dataSet;
    }

    private DocumentSource createDocumentSource() {
        final InputStream inputStream = _resource.read();
        try {
            final MappingJsonFactory jsonFactory = new MappingJsonFactory();
            final JsonParser parser = jsonFactory.createParser(inputStream);
            logger.debug("Created JSON parser for resource: {}", _resource);

            return new JsonDocumentSource(parser, _resource.getName());
        } catch (Exception e) {
            FileHelper.safeClose(inputStream);
            throw new MetaModelException("Unexpected error while creating JSON parser", e);
        }
    }

    @Override
    public DocumentSource getMixedDocumentSourceForSampling() {
        return new MaxRowsDocumentSource(createDocumentSource(), 1000);
    }

    @Override
    public DocumentSource getDocumentSourceForTable(String sourceCollectionName) {
        // only a single source collection - returning that
        return createDocumentSource();
    }
}


text:
import {potions, alchemicals} from './Enums.js'
import {MyIcon} from './MyIcon.js'
import {encyclopediaTableInfo, encyclopediaClassify} from './Logic.js'
import {mkAntdRows, mkTableCell} from './Misc.js'

import React from 'react'

import _ from 'lodash'

import Table from 'antd/lib/table'

function EncyclopediaView({worlds}) {
  const data = mkAntdRows(encyclopediaTableInfo(worlds), encyclopediaClassify)

  let columns = _.keys(alchemicals).map((name, index) =>
    ({
      title: index,
      dataIndex: index,
      key: name,
      width: 150,
      render: (chance, row) => mkTableCell(chance, row.hedge, v => v === 0 || v === 1)
    })
  )
  columns.unshift({
    title:
,
    dataIndex: "index",
    key: "icon",
    width: 150,
    render: index => <MyIcon imageDir="aspects" name={_.keys(potions)[index*2]} />
  })

  return <>

Encyclopedia

 record.index}
      pagination={false}
      size="small"
      showHeader={false}
    />
  </>
}

export {EncyclopediaView}


text:
<?xml version="1.0"?>
<config>
    <modules>
        <Edge_QuickOrder>
            <version>1.0.0</version>
        </Edge_QuickOrder>
    </modules>
    <global>
        <helpers>
            <edgequickorder>
                <class>Edge_QuickOrder_Helper</class>
            </edgequickorder>
        </helpers>
        <blocks>
            <edgequickorder>
                <class>Edge_QuickOrder_Block</class>
            </edgequickorder>
        </blocks>
    </global>
    <frontend>
        <routers>
            <edgequickorder>
                <use>standard</use>
                <args>
                    <module>Edge_QuickOrder</module>
                    <frontName>edgequickorder</frontName>
                </args>
            </edgequickorder>
        </routers>
        <layout>
            <updates>
                <edgequickorder>
                    <file>edge/quickorder.xml</file>
                </edgequickorder>
            </updates>
        </layout>
    </frontend>
</config>


text:
#pragma once
#ifndef CLSPARSE_BENCHMARK_DENSE2CSR_HXX__
#define CLSPARSE_BENCHMARK_DENSE2CSR_HXX__

#include "clSPARSE.h"
#include "clfunc_common.hpp"

template <typename T>
class xDense2Csr: public clsparseFunc
{
public:
    xDense2Csr( PFCLSPARSETIMER sparseGetTimer, size_t profileCount, cl_device_type devType, cl_bool keep_explicit_zeroes = true ): clsparseFunc( devType, CL_QUEUE_PROFILING_ENABLE ), gpuTimer( nullptr ), cpuTimer( nullptr )
    {
        gpuTimer = nullptr;
        cpuTimer = nullptr;

        //      Create and initialize our timer class, if the external timer shared library loaded
        if( sparseGetTimer )
        {
            gpuTimer = sparseGetTimer( CLSPARSE_GPU );
            gpuTimer->Reserve( 1, profileCount );
            gpuTimer->setNormalize( true );

            cpuTimer = sparseGetTimer( CLSPARSE_CPU );
            cpuTimer->Reserve( 1, profileCount );
            cpuTimer->setNormalize( true );

            gpuTimerID = gpuTimer->getUniqueID( "GPU xDense2Csr", 0 );
            cpuTimerID = cpuTimer->getUniqueID( "CPU xDense2Csr", 0 );
        }
        clsparseEnableAsync( control, false );
        explicit_zeroes = keep_explicit_zeroes;
    }// End of constructor

    ~xDense2Csr( )
    {
    }

    void call_func( )
    {
      if( gpuTimer && cpuTimer )
      {
        gpuTimer->Start( gpuTimerID );
        cpuTimer->Start( cpuTimerID );

        xDense2Csr_Function( false );

        cpuTimer->Stop( cpuTimerID );
        gpuTimer->Stop( gpuTimerID );
      }
      else
      {
        xDense2Csr_Function( false );
      }
    }// end of call_func

    double gflops( )
    {
        return 0.0;
    }// end

    std::string gflops_formula( )
    {
        return "N/A";
    }// end

    double bandwidth( )
    {
#if 0
        //  Assuming that accesses to the vector always hit in the cache after the first access
        //  There are NNZ integers in the cols[ ] array
        //  You access each integer value in row_delimiters[ ] once.
        //  There are NNZ float_types in the vals[ ] array
        //  You read num_cols floats from the vector, afterwards they cache perfectly.
        //  Finally, you write num_rows floats out to DRAM at the end of the kernel.
        return ( sizeof( cl_int )*( csrMtx.num_nonzeros + csrMtx.num_rows ) + sizeof( T ) * ( csrMtx.num_nonzeros + csrMtx.num_cols + csrMtx.num_rows ) ) / time_in_ns( );
#endif
        // Number of Elements converted in unit time
        return (csrMtx.num_cols * csrMtx.num_rows / time_in_ns());
    }

    std::string bandwidth_formula( )
    {
        //return "GiB/s";
        return "GiElements/s";
    }

    void setup_buffer( double pAlpha, double pBeta, const std::string& path )
    {
        sparseFile = path;

        // Read sparse data from file and construct a COO matrix from it
        clsparseIdx_t nnz;
        clsparseIdx_t row;
        clsparseIdx_t col;
        clsparseStatus fileError = clsparseHeaderfromFile( &nnz, &row, &col, sparseFile.c_str( ) );
        if( fileError != clsparseSuccess )
             throw clsparse::io_exception( "Could not read matrix market header from disk: " + sparseFile );

        // Now initialise a CSR matrix from the COO matrix
        clsparseInitCsrMatrix( &csrMtx );
        csrMtx.num_nonzeros = nnz;
        csrMtx.num_rows     = row;
        csrMtx.num_cols     = col;

        //clsparseCsrMetaSize( &csrMtx, control );

        cl_int status;
        csrMtx.values = ::clCreateBuffer( ctx, CL_MEM_READ_ONLY,
            csrMtx.num_nonzeros * sizeof( T ), NULL, &status );
        CLSPARSE_V( status, "::clCreateBuffer csrMtx.values" );

        csrMtx.col_indices = ::clCreateBuffer( ctx, CL_MEM_READ_ONLY,
            csrMtx.num_nonzeros * sizeof(clsparseIdx_t), NULL, &status);
        CLSPARSE_V( status, "::clCreateBuffer csrMtx.col_indices" );

        csrMtx.row_pointer = ::clCreateBuffer( ctx, CL_MEM_READ_ONLY,
            (csrMtx.num_rows + 1) * sizeof(clsparseIdx_t), NULL, &status);
        CLSPARSE_V( status, "::clCreateBuffer csrMtx.row_pointer" );

        if(typeid(T) == typeid(float))
            fileError = clsparseSCsrMatrixfromFile( &csrMtx, sparseFile.c_str( ), control, explicit_zeroes );
        else if (typeid(T) == typeid(double))
            fileError = clsparseDCsrMatrixfromFile( &csrMtx, sparseFile.c_str( ), control, explicit_zeroes );
        else
            fileError = clsparseInvalidType;

        if( fileError != clsparseSuccess )
            throw std::runtime_error( "Could not read matrix market data from disk: " + sparseFile );

		// Initialize the input dense matrix
		cldenseInitMatrix(&A);
		A.major    = rowMajor;
		A.num_rows = row;
		A.num_cols = col;
		A.lead_dim = col;  // To Check!! VK;
		A.values = clCreateBuffer(ctx, CL_MEM_READ_WRITE,
			                      row * col * sizeof(T), NULL, &status);
		CLSPARSE_V(status, "::clCreateBuffer A.values");

        if(typeid(T) == typeid(float))
		{
			clsparseScsr2dense(&csrMtx, &A, control);
		}
		else if (typeid(T) == typeid(double))
		{
			clsparseDcsr2dense(&csrMtx, &A, control);
		}
		// Check whether we need any barrier here: clFinish(queue)

		// Output CSR Matrix
		clsparseInitCsrMatrix(&csrMatx);
		csrMatx.num_cols     = csrMtx.num_cols;
		csrMatx.num_rows     = csrMtx.num_rows;
		csrMatx.num_nonzeros = csrMtx.num_nonzeros;

        csrMatx.values = ::clCreateBuffer( ctx, CL_MEM_WRITE_ONLY,
                                           csrMtx.num_nonzeros * sizeof( T ), NULL, &status );
		CLSPARSE_V(status, "::clCreateBuffer csrMatx.values");

        csrMatx.col_indices = ::clCreateBuffer( ctx, CL_MEM_WRITE_ONLY,
            csrMtx.num_nonzeros * sizeof(clsparseIdx_t), NULL, &status);
		CLSPARSE_V(status, "::clCreateBuffer csrMatx.col_indices");

        csrMatx.row_pointer = ::clCreateBuffer( ctx, CL_MEM_WRITE_ONLY,
                                           (csrMtx.num_rows + 1) * sizeof( clsparseIdx_t ), NULL, &status );
		CLSPARSE_V(status, "::clCreateBuffer csrMatx.row_pointer");
    }// End of function

    void initialize_cpu_buffer( )
    {
    }

    void initialize_gpu_buffer( )
    {
    }

    void reset_gpu_write_buffer( )
    {
        clsparseIdx_t scalar_i = 0;
		T scalar_f   = 0;

        CLSPARSE_V(::clEnqueueFillBuffer(queue, csrMatx.row_pointer, &scalar_i, sizeof(clsparseIdx_t), 0,
            sizeof(clsparseIdx_t) * (csrMatx.num_rows + 1), 0, NULL, NULL), "::clEnqueueFillBuffer row");

        CLSPARSE_V(::clEnqueueFillBuffer(queue, csrMatx.col_indices, &scalar_i, sizeof(clsparseIdx_t), 0,
            sizeof(clsparseIdx_t) * csrMatx.num_nonzeros, 0, NULL, NULL), "::clEnqueueFillBuffer col");

		CLSPARSE_V(::clEnqueueFillBuffer(queue, csrMatx.values, &scalar_f, sizeof(T), 0,
			sizeof(T) * csrMatx.num_nonzeros, 0, NULL, NULL), "::clEnqueueFillBuffer values");
    }// end

    void read_gpu_buffer( )
    {
    }

    void cleanup( )
    {
        if( gpuTimer && cpuTimer )
        {
          std::cout << "clSPARSE matrix: " << sparseFile << std::endl;
#if 0
          size_t sparseBytes = 0;
          cpuTimer->pruneOutliers( 3.0 );
          cpuTimer->Print( sparseBytes, "GiB/s" );
          cpuTimer->Reset( );

          gpuTimer->pruneOutliers( 3.0 );
          gpuTimer->Print( sparseBytes, "GiB/s" );
          gpuTimer->Reset( );
#endif
		  // Calculate Number of Elements transformed per unit time
          clsparseIdx_t sparseElements = A.num_cols * A.num_rows;
		  cpuTimer->pruneOutliers(3.0);
		  cpuTimer->Print(sparseElements, "GiElements/s");
		  cpuTimer->Reset();

		  gpuTimer->pruneOutliers(3.0);
		  gpuTimer->Print(sparseElements, "GiElements/s");
		  gpuTimer->Reset();
        }

        //this is necessary since we are running a iteration of tests and calculate the average time. (in client.cpp)
        //need to do this before we eventually hit the destructor
        CLSPARSE_V( ::clReleaseMemObject( csrMtx.values ), "clReleaseMemObject csrMtx.values" );
        CLSPARSE_V( ::clReleaseMemObject( csrMtx.col_indices ), "clReleaseMemObject csrMtx.col_indices" );
        CLSPARSE_V( ::clReleaseMemObject( csrMtx.row_pointer ), "clReleaseMemObject csrMtx.row_pointer" );

        CLSPARSE_V( ::clReleaseMemObject( csrMatx.values ), "clReleaseMemObject csrMatx.values" );
        CLSPARSE_V( ::clReleaseMemObject( csrMatx.col_indices ), "clReleaseMemObject csrMatx.col_indices" );
        CLSPARSE_V( ::clReleaseMemObject( csrMatx.row_pointer ), "clReleaseMemObject csrMatx.row_pointer" );

        CLSPARSE_V( ::clReleaseMemObject( A.values ), "clReleaseMemObject A.values" );
    }// End of function

private:
    void xDense2Csr_Function( bool flush );

    //  Timers we want to keep
    clsparseTimer* gpuTimer;
    clsparseTimer* cpuTimer;
    size_t gpuTimerID, cpuTimerID;

    std::string sparseFile;

    //device values
    clsparseCsrMatrix csrMtx;
    clsparseCsrMatrix csrMatx;
    cldenseMatrix A;

    // host values
    cl_bool explicit_zeroes;

    //  OpenCL state
    cl_command_queue_properties cqProp;

}; // class xDense2Csr

template<> void
xDense2Csr<float>::xDense2Csr_Function( bool flush )
{
      //call dense2csr
    clsparseSdense2csr(&A, &csrMatx, control);

    if( flush )
        clFinish( queue );
}// end

template<> void
xDense2Csr<double>::xDense2Csr_Function( bool flush )
{
     //call dense2csr
    clsparseDdense2csr(&A, &csrMatx, control);

    if( flush )
        clFinish( queue );
}// end

#endif // ifndef CLSPARSE_BENCHMARK_DENSE2CSR_HXX__


text:
.class public interface abstract Lcom/google/inject/spi/ProviderKeyBinding;
.super Ljava/lang/Object;
.source "ProviderKeyBinding.java"

# interfaces
.implements Lcom/google/inject/Binding;

# annotations
.annotation system Ldalvik/annotation/Signature;
    value = {
        "<T:",
        "Ljava/lang/Object;",
        ">",
        "Ljava/lang/Object;",
        "Lcom/google/inject/Binding",
        "<TT;>;"
    }
.end annotation

# virtual methods
.method public abstract getProviderKey()Lcom/google/inject/Key;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "()",
            "Lcom/google/inject/Key",
            "<+",
            "Ljavax/inject/Provider",
            "<+TT;>;>;"
        }
    .end annotation
.end method


text:
package com.sequenceiq.notification;

import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

import javax.inject.Inject;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import com.google.common.collect.Lists;
import com.sequenceiq.cloudbreak.client.RestClientUtil;
import com.sequenceiq.cloudbreak.event.ResourceEvent;
import com.sequenceiq.cloudbreak.structuredevent.event.CloudbreakNotification;

@Component
public class NotificationService {

    @Inject
    private NotificationSender notificationSender;

    @Inject
    private NotificationAssemblingService notificationAssemblingService;

    @Value("${notification.urls:}")
    private String notificationUrls;

    public void send(Notification<CloudbreakNotification> notification) {
        notificationSender.send(notification, getNotificationUrls(), RestClientUtil.get());
    }

    public void send(ResourceEvent resourceEvent) {
        send(resourceEvent, Collections.emptySet(), null, null);
    }

    public void send(ResourceEvent resourceEvent, String userId) {
        send(resourceEvent, Collections.emptySet(), null, userId);
    }

    public void send(ResourceEvent resourceEvent, Object payload, String userId) {
        send(resourceEvent, Collections.emptySet(), payload, userId);
    }

    public void send(ResourceEvent resourceEvent, Collection<?> messageArgs, Object payload) {
        notificationSender.send(
                notificationAssemblingService.createNotification(resourceEvent, messageArgs, payload),
                getNotificationUrls(),
                RestClientUtil.get());
    }

    public void send(ResourceEvent resourceEvent, Collection<?> messageArgs, Object payload, String userId) {
        notificationSender.send(
                notificationAssemblingService.createNotification(resourceEvent, messageArgs, payload, userId),
                getNotificationUrls(),
                RestClientUtil.get());
    }

    private List<String> getNotificationUrls() {
        return Lists.newArrayList(notificationUrls.trim().split(","))
                .stream()
                .filter(Objects::nonNull)
                .filter(e -> !e.isEmpty())
                .map(url -> {
                    if (isUrlMissProtocol(url)) {
                        return "http://" + url;
                    }
                    return url;
                })
                .collect(Collectors.toList());
    }

    private boolean isUrlMissProtocol(String url) {
        return !(url.startsWith("http://") ^ url.startsWith("https://"));
    }

}


text:
/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package io.trino.operator.aggregation;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.primitives.Ints;
import io.trino.metadata.TestingFunctionResolution;
import io.trino.operator.aggregation.groupby.AggregationTestInput;
import io.trino.operator.aggregation.groupby.AggregationTestInputBuilder;
import io.trino.operator.aggregation.groupby.AggregationTestOutput;
import io.trino.operator.aggregation.histogram.Histogram;
import io.trino.spi.block.Block;
import io.trino.spi.block.BlockBuilder;
import io.trino.spi.type.ArrayType;
import io.trino.spi.type.MapType;
import io.trino.spi.type.RowType;
import io.trino.spi.type.SqlTimestampWithTimeZone;
import io.trino.spi.type.TimeZoneKey;
import io.trino.sql.tree.QualifiedName;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.testng.annotations.Test;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.OptionalInt;
import java.util.Random;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

import static io.trino.block.BlockAssertions.createBooleansBlock;
import static io.trino.block.BlockAssertions.createDoublesBlock;
import static io.trino.block.BlockAssertions.createLongsBlock;
import static io.trino.block.BlockAssertions.createStringArraysBlock;
import static io.trino.block.BlockAssertions.createStringsBlock;
import static io.trino.operator.OperatorAssertion.toRow;
import static io.trino.operator.aggregation.AggregationTestUtils.assertAggregation;
import static io.trino.spi.type.BigintType.BIGINT;
import static io.trino.spi.type.BooleanType.BOOLEAN;
import static io.trino.spi.type.DateTimeEncoding.packDateTimeWithZone;
import static io.trino.spi.type.DateTimeEncoding.unpackMillisUtc;
import static io.trino.spi.type.DateTimeEncoding.unpackZoneKey;
import static io.trino.spi.type.DoubleType.DOUBLE;
import static io.trino.spi.type.TimeZoneKey.getTimeZoneKey;
import static io.trino.spi.type.TimestampWithTimeZoneType.TIMESTAMP_WITH_TIME_ZONE;
import static io.trino.spi.type.VarcharType.VARCHAR;
import static io.trino.sql.analyzer.TypeSignatureProvider.fromTypes;
import static io.trino.sql.planner.plan.AggregationNode.Step.SINGLE;
import static io.trino.util.DateTimeZoneIndex.getDateTimeZone;
import static io.trino.util.StructuralTestUtil.mapBlockOf;
import static io.trino.util.StructuralTestUtil.mapType;
import static org.testng.Assert.assertTrue;

public class TestHistogram
{
    private static final TimeZoneKey TIME_ZONE_KEY = getTimeZoneKey("UTC");
    private static final DateTimeZone DATE_TIME_ZONE = getDateTimeZone(TIME_ZONE_KEY);
    private static final TestingFunctionResolution FUNCTION_RESOLUTION = new TestingFunctionResolution();

    @Test
    public void testSimpleHistograms()
    {
        assertAggregation(
                FUNCTION_RESOLUTION,
                QualifiedName.of(Histogram.NAME),
                fromTypes(VARCHAR),
                ImmutableMap.of("a", 1L, "b", 1L, "c", 1L),
                createStringsBlock("a", "b", "c"));

        assertAggregation(
                FUNCTION_RESOLUTION,
                QualifiedName.of(Histogram.NAME),
                fromTypes(BIGINT),
                ImmutableMap.of(100L, 1L, 200L, 1L, 300L, 1L),
                createLongsBlock(100L, 200L, 300L));

        assertAggregation(
                FUNCTION_RESOLUTION,
                QualifiedName.of(Histogram.NAME),
                fromTypes(DOUBLE),
                ImmutableMap.of(0.1, 1L, 0.3, 1L, 0.2, 1L),
                createDoublesBlock(0.1, 0.3, 0.2));

        assertAggregation(
                FUNCTION_RESOLUTION,
                QualifiedName.of(Histogram.NAME),
                fromTypes(BOOLEAN),
                ImmutableMap.of(true, 1L, false, 1L),
                createBooleansBlock(true, false));
    }

    @Test
    public void testSharedGroupBy()
    {
        assertAggregation(
                FUNCTION_RESOLUTION,
                QualifiedName.of(Histogram.NAME),
                fromTypes(VARCHAR),
                ImmutableMap.of("a", 1L, "b", 1L, "c", 1L),
                createStringsBlock("a", "b", "c"));

        assertAggregation(
                FUNCTION_RESOLUTION,
                QualifiedName.of(Histogram.NAME),
                fromTypes(BIGINT),
                ImmutableMap.of(100L, 1L, 200L, 1L, 300L, 1L),
                createLongsBlock(100L, 200L, 300L));

        assertAggregation(
                FUNCTION_RESOLUTION,
                QualifiedName.of(Histogram.NAME), fromTypes(DOUBLE),
                ImmutableMap.of(0.1, 1L, 0.3, 1L, 0.2, 1L),
                createDoublesBlock(0.1, 0.3, 0.2));

        assertAggregation(
                FUNCTION_RESOLUTION,
                QualifiedName.of(Histogram.NAME),
                fromTypes(BOOLEAN),
                ImmutableMap.of(true, 1L, false, 1L),
                createBooleansBlock(true, false));
    }

    @Test
    public void testDuplicateKeysValues()
    {
        assertAggregation(
                FUNCTION_RESOLUTION,
                QualifiedName.of(Histogram.NAME),
                fromTypes(VARCHAR),
                ImmutableMap.of("a", 2L, "b", 1L),
                createStringsBlock("a", "b", "a"));

        long timestampWithTimeZone1 = packDateTimeWithZone(new DateTime(1970, 1, 1, 0, 0, 0, 0, DATE_TIME_ZONE).getMillis(), TIME_ZONE_KEY);
        long timestampWithTimeZone2 = packDateTimeWithZone(new DateTime(2015, 1, 1, 0, 0, 0, 0, DATE_TIME_ZONE).getMillis(), TIME_ZONE_KEY);
        assertAggregation(
                FUNCTION_RESOLUTION,
                QualifiedName.of(Histogram.NAME),
                fromTypes(TIMESTAMP_WITH_TIME_ZONE),
                ImmutableMap.of(SqlTimestampWithTimeZone.newInstance(3, unpackMillisUtc(timestampWithTimeZone1), 0, unpackZoneKey(timestampWithTimeZone1)), 2L, SqlTimestampWithTimeZone.newInstance(3, unpackMillisUtc(timestampWithTimeZone2), 0, unpackZoneKey(timestampWithTimeZone2)), 1L),
                createLongsBlock(timestampWithTimeZone1, timestampWithTimeZone1, timestampWithTimeZone2));
    }

    @Test
    public void testWithNulls()
    {
        assertAggregation(
                FUNCTION_RESOLUTION,
                QualifiedName.of(Histogram.NAME),
                fromTypes(BIGINT),
                ImmutableMap.of(1L, 1L, 2L, 1L),
                createLongsBlock(2L, null, 1L));

        assertAggregation(
                FUNCTION_RESOLUTION,
                QualifiedName.of(Histogram.NAME),
                fromTypes(BIGINT),
                null,
                createLongsBlock((Long) null));
    }

    @Test
    public void testArrayHistograms()
    {
        ArrayType arrayType = new ArrayType(VARCHAR);
        assertAggregation(
                FUNCTION_RESOLUTION,
                QualifiedName.of(Histogram.NAME),
                fromTypes(arrayType),
                ImmutableMap.of(ImmutableList.of("a", "b", "c"), 1L, ImmutableList.of("d", "e", "f"), 1L, ImmutableList.of("c", "b", "a"), 1L),
                createStringArraysBlock(ImmutableList.of(ImmutableList.of("a", "b", "c"), ImmutableList.of("d", "e", "f"), ImmutableList.of("c", "b", "a"))));
    }

    @Test
    public void testMapHistograms()
    {
        MapType innerMapType = mapType(VARCHAR, VARCHAR);

        BlockBuilder builder = innerMapType.createBlockBuilder(null, 3);
        innerMapType.writeObject(builder, mapBlockOf(VARCHAR, VARCHAR, ImmutableMap.of("a", "b")));
        innerMapType.writeObject(builder, mapBlockOf(VARCHAR, VARCHAR, ImmutableMap.of("c", "d")));
        innerMapType.writeObject(builder, mapBlockOf(VARCHAR, VARCHAR, ImmutableMap.of("e", "f")));

        assertAggregation(
                FUNCTION_RESOLUTION,
                QualifiedName.of(Histogram.NAME),
                fromTypes(innerMapType),
                ImmutableMap.of(ImmutableMap.of("a", "b"), 1L, ImmutableMap.of("c", "d"), 1L, ImmutableMap.of("e", "f"), 1L),
                builder.build());
    }

    @Test
    public void testRowHistograms()
    {
        RowType innerRowType = RowType.from(ImmutableList.of(
                RowType.field("f1", BIGINT),
                RowType.field("f2", DOUBLE)));
        BlockBuilder builder = innerRowType.createBlockBuilder(null, 3);
        innerRowType.writeObject(builder, toRow(ImmutableList.of(BIGINT, DOUBLE), 1L, 1.0));
        innerRowType.writeObject(builder, toRow(ImmutableList.of(BIGINT, DOUBLE), 2L, 2.0));
        innerRowType.writeObject(builder, toRow(ImmutableList.of(BIGINT, DOUBLE), 3L, 3.0));

        assertAggregation(
                FUNCTION_RESOLUTION,
                QualifiedName.of(Histogram.NAME),
                fromTypes(innerRowType),
                ImmutableMap.of(ImmutableList.of(1L, 1.0), 1L, ImmutableList.of(2L, 2.0), 1L, ImmutableList.of(3L, 3.0), 1L),
                builder.build());
    }

    @Test
    public void testLargerHistograms()
    {
        assertAggregation(
                FUNCTION_RESOLUTION,
                QualifiedName.of(Histogram.NAME),
                fromTypes(VARCHAR),
                ImmutableMap.of("a", 25L, "b", 10L, "c", 12L, "d", 1L, "e", 2L),
                createStringsBlock("a", "b", "c", "d", "e", "e", "c", "a", "a", "a", "b", "a", "a", "a", "a", "b", "a", "a", "a", "a", "b", "a", "a", "a", "a", "b", "a", "a", "a", "a", "b", "a", "c", "c", "b", "a", "c", "c", "b", "a", "c", "c", "b", "a", "c", "c", "b", "a", "c", "c"));
    }

    @Test
    public void testEmptyHistogramOutputsNull()
    {
        TestingAggregationFunction function = getInternalDefaultVarCharAggregation();
        GroupedAggregator groupedAggregator = function.createAggregatorFactory(SINGLE, Ints.asList(new int[] {}), OptionalInt.empty())
                .createGroupedAggregator();
        BlockBuilder blockBuilder = function.getFinalType().createBlockBuilder(null, 1000);

        groupedAggregator.evaluate(0, blockBuilder);
        assertTrue(blockBuilder.isNull(0));
    }

    @Test
    public void testSharedGroupByWithOverlappingValuesRunner()
    {
        TestingAggregationFunction classicFunction = getInternalDefaultVarCharAggregation();
        TestingAggregationFunction singleInstanceFunction = getInternalDefaultVarCharAggregation();

        testSharedGroupByWithOverlappingValuesRunner(classicFunction);
        testSharedGroupByWithOverlappingValuesRunner(singleInstanceFunction);
    }

    @Test
    public void testSharedGroupByWithDistinctValuesPerGroup()
    {
        // test that two groups don't affect one another
        TestingAggregationFunction classicFunction = getInternalDefaultVarCharAggregation();
        TestingAggregationFunction singleInstanceFunction = getInternalDefaultVarCharAggregation();
        testSharedGroupByWithDistinctValuesPerGroupRunner(classicFunction);
        testSharedGroupByWithDistinctValuesPerGroupRunner(singleInstanceFunction);
    }

    @Test
    public void testSharedGroupByWithOverlappingValuesPerGroup()
    {
        // test that two groups don't affect one another
        TestingAggregationFunction classicFunction = getInternalDefaultVarCharAggregation();
        TestingAggregationFunction singleInstanceFunction = getInternalDefaultVarCharAggregation();
        testSharedGroupByWithOverlappingValuesPerGroupRunner(classicFunction);
        testSharedGroupByWithOverlappingValuesPerGroupRunner(singleInstanceFunction);
    }

    @Test
    public void testSharedGroupByWithManyGroups()
    {
        // uses a large enough data set to induce rehashing and test correctness
        TestingAggregationFunction classicFunction = getInternalDefaultVarCharAggregation();
        TestingAggregationFunction singleInstanceFunction = getInternalDefaultVarCharAggregation();

        // this is to validate the test as there have been test-bugs that looked like code bugs--if both fail, likely a test bug
        testManyValuesInducingRehash(classicFunction);
        testManyValuesInducingRehash(singleInstanceFunction);
    }

    private static void testManyValuesInducingRehash(TestingAggregationFunction aggregationFunction)
    {
        double distinctFraction = 0.1f;
        int numGroups = 50000;
        int itemCount = 30;
        Random random = new Random();
        GroupedAggregator groupedAggregator = aggregationFunction.createAggregatorFactory(SINGLE, ImmutableList.of(0), OptionalInt.empty())
                .createGroupedAggregator();

        for (int j = 0; j < numGroups; j++) {
            Map<String, Long> expectedValues = new HashMap<>();
            List<String> valueList = new ArrayList<>();

            for (int i = 0; i < itemCount; i++) {
                String str = String.valueOf(i % 10);
                String item = IntStream.range(0, itemCount).mapToObj(x -> str).collect(Collectors.joining());
                boolean distinctValue = random.nextDouble() < distinctFraction;
                if (distinctValue) {
                    // produce a unique value for the histogram
                    item = j + "-" + item;
                    valueList.add(item);
                }
                else {
                    valueList.add(item);
                }
                expectedValues.compute(item, (k, v) -> v == null ? 1L : ++v);
            }

            Block block = createStringsBlock(valueList);
            AggregationTestInputBuilder testInputBuilder = new AggregationTestInputBuilder(
                    new Block[] {block},
                    aggregationFunction);
            AggregationTestInput test1 = testInputBuilder.build();

            test1.runPagesOnAggregatorWithAssertion(j, aggregationFunction.getFinalType(), groupedAggregator, new AggregationTestOutput(expectedValues));
        }
    }

    private static void testSharedGroupByWithOverlappingValuesPerGroupRunner(TestingAggregationFunction aggregationFunction)
    {
        Block block1 = createStringsBlock("a", "b", "c");
        Block block2 = createStringsBlock("b", "c", "d");
        AggregationTestOutput aggregationTestOutput1 = new AggregationTestOutput(ImmutableMap.of("a", 1L, "b", 1L, "c", 1L));
        AggregationTestInputBuilder testBuilder1 = new AggregationTestInputBuilder(
                new Block[] {block1},
                aggregationFunction);
        AggregationTestInput test1 = testBuilder1.build();
        GroupedAggregator groupedAggregator = test1.createGroupedAggregator();

        test1.runPagesOnAggregatorWithAssertion(0L, aggregationFunction.getFinalType(), groupedAggregator, aggregationTestOutput1);

        AggregationTestOutput aggregationTestOutput2 = new AggregationTestOutput(ImmutableMap.of("b", 1L, "c", 1L, "d", 1L));
        AggregationTestInputBuilder testbuilder2 = new AggregationTestInputBuilder(
                new Block[] {block2},
                aggregationFunction);
        AggregationTestInput test2 = testbuilder2.build();
        test2.runPagesOnAggregatorWithAssertion(255L, aggregationFunction.getFinalType(), groupedAggregator, aggregationTestOutput2);
    }

    private static void testSharedGroupByWithDistinctValuesPerGroupRunner(TestingAggregationFunction aggregationFunction)
    {
        Block block1 = createStringsBlock("a", "b", "c");
        Block block2 = createStringsBlock("d", "e", "f");
        AggregationTestOutput aggregationTestOutput1 = new AggregationTestOutput(ImmutableMap.of("a", 1L, "b", 1L, "c", 1L));
        AggregationTestInputBuilder testInputBuilder1 = new AggregationTestInputBuilder(
                new Block[] {block1},
                aggregationFunction);
        AggregationTestInput test1 = testInputBuilder1.build();
        GroupedAggregator groupedAggregator = test1.createGroupedAggregator();

        test1.runPagesOnAggregatorWithAssertion(0L, aggregationFunction.getFinalType(), groupedAggregator, aggregationTestOutput1);

        AggregationTestOutput aggregationTestOutput2 = new AggregationTestOutput(ImmutableMap.of("d", 1L, "e", 1L, "f", 1L));
        AggregationTestInputBuilder testBuilder2 = new AggregationTestInputBuilder(
                new Block[] {block2},
                aggregationFunction);
        AggregationTestInput test2 = testBuilder2.build();
        test2.runPagesOnAggregatorWithAssertion(255L, aggregationFunction.getFinalType(), groupedAggregator, aggregationTestOutput2);
    }

    private static void testSharedGroupByWithOverlappingValuesRunner(TestingAggregationFunction aggregationFunction)
    {
        Block block1 = createStringsBlock("a", "b", "c", "d", "a1", "b2", "c3", "d4", "a", "b2", "c", "d4", "a3", "b3", "c3", "b2");
        AggregationTestInputBuilder testInputBuilder1 = new AggregationTestInputBuilder(
                new Block[] {block1},
                aggregationFunction);
        AggregationTestOutput aggregationTestOutput1 = new AggregationTestOutput(ImmutableMap.<String, Long>builder()
                .put("a", 2L)
                .put("b", 1L)
                .put("c", 2L)
                .put("d", 1L)
                .put("a1", 1L)
                .put("b2", 3L)
                .put("c3", 2L)
                .put("d4", 2L)
                .put("a3", 1L)
                .put("b3", 1L)
                .build());
        AggregationTestInput test1 = testInputBuilder1.build();

        test1.runPagesOnAggregatorWithAssertion(0L, aggregationFunction.getFinalType(), test1.createGroupedAggregator(), aggregationTestOutput1);
    }

    private static TestingAggregationFunction getInternalDefaultVarCharAggregation()
    {
        return FUNCTION_RESOLUTION.getAggregateFunction(QualifiedName.of(Histogram.NAME), fromTypes(VARCHAR));
    }
}


text:
package org.w3c.domts.level1.core;

import org.w3c.dom.*;

import org.w3c.domts.DOMTestCase;
import org.w3c.domts.DOMTestDocumentBuilderFactory;

/**
 *     The "getNamedItem(name)" method returns a node of any
 *    type specified by name.
 *
 *    Retrieve the second employee and create a NamedNodeMap
 *    listing of the attributes of the last child.  Once the
 *    list is created an invocation of the "getNamedItem(name)"
 *    method is done with name="street".  This should result
 *    in the method returning an Attr node.
* @author NIST
* @author Mary Brady
* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1074577549
* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096
* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1112119403
*/
public final class namednodemapreturnattrnode extends DOMTestCase {

   /**
    * Constructor.
    * @param factory document factory, may not be null
    * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration
    */
   public namednodemapreturnattrnode(final DOMTestDocumentBuilderFactory factory)  throws org.w3c.domts.DOMTestIncompatibleException {
      super(factory);

    //
    //   check if loaded documents are supported for content type
    //
    String contentType = getContentType();
    preload(contentType, "staff", false);
    }

   /**
    * Runs the test case.
    * @throws Throwable Any uncaught exception causes test to fail
    */
   public void runTest() throws Throwable {
      Document doc;
      NodeList elementList;
      Node testEmployee;
      NamedNodeMap attributes;
      Node streetAttr;
      String attrName;
      doc = (Document) load("staff", false);
      elementList = doc.getElementsByTagName("address");
      testEmployee = elementList.item(1);
      attributes = testEmployee.getAttributes();
      streetAttr = attributes.getNamedItem("street");
      assertInstanceOf("typeAssert", Attr.class, streetAttr);
attrName = streetAttr.getNodeName();
      assertEquals("nodeName", "street", attrName);
      attrName = ((Attr) /*Node */streetAttr).getName();
      assertEquals("attrName", "street", attrName);
      }
   /**
    *  Gets URI that identifies the test.
    *  @return uri identifier of test
    */
   public String getTargetURI() {
      return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/namednodemapreturnattrnode";
   }
   /**
    * Runs this test from the command line.
    * @param args command line arguments
    */
   public static void main(final String[] args) {
        DOMTestCase.doMain(namednodemapreturnattrnode.class, args);
   }
}


text:
require 'spec_helper'

describe Squib::Deck do

  context '#hint' do

    it 'sets hinting to conf' do
      mock_conf = double(Squib::Conf)
      expect(mock_conf).to receive(:text_hint=).with(:cyan).once
      Squib::Deck.new do
        @conf = mock_conf
        hint text: :cyan
      end
    end

  end

  context '#set' do

    it 'puts font in @font' do
      deck = Squib::Deck.new do
        set font: 'foo'
      end
      expect(deck.font).to eq ('foo')
    end

    it 'raises deprecation errors on img_dir' do
      set_img_dir = Proc.new do
        Squib::Deck.new do
          set img_dir: 'foo'
        end
      end
      expect { set_img_dir.call }.to raise_error('DEPRECATED: As of v0.7 img_dir is no longer supported in "set". Use config.yml instead.')
    end

  end

end


text:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<META http-equiv="Content-Type" content="text/html; charset=utf-8">
<TITLE>
Controller (Douyu 0.7.1 API)
</TITLE>

<META NAME="date" CONTENT="2011-06-23">

<LINK REL ="stylesheet" TYPE="text/css" HREF="../../stylesheet.css" TITLE="Style">

      概述
      软件包
    类
      使用
      树
      已过时
      索引
      帮助

 上一个类
 下一个类

  框架
 无框架

  所有类

  摘要: 必需 | 可选

详细信息: 元素

douyu.mvc

注释类型 Controller

@Retention(value=RUNTIME)
@Target(value=TYPE)
public @interface Controller

可选元素摘要

 java.lang.String
defaultAction

 HttpMethod[]
httpMethods

          Controller所能接受的HTTT请求方法类型,会被Action中的值覆盖

defaultAction

public abstract java.lang.String defaultAction

默认值:
"index"

httpMethods

public abstract HttpMethod[] httpMethods

Controller所能接受的HTTT请求方法类型,会被Action中的值覆盖

默认值:
{douyu.http.HttpMethod.GET, douyu.http.HttpMethod.POST}

      概述
      软件包
    类
      使用
      树
      已过时
      索引
      帮助

 上一个类
 下一个类

  框架
 无框架

  所有类

  摘要: 必需 | 可选

详细信息: 元素


text:
package org.wso2.carbon.device.mgt.extensions.utils;

import org.testng.Assert;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
import org.wso2.carbon.base.MultitenantConstants;
import org.wso2.carbon.device.mgt.common.license.mgt.License;
import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManagementException;
import org.wso2.carbon.device.mgt.extensions.device.type.template.util.DeviceSchemaInitializer;
import org.wso2.carbon.device.mgt.extensions.license.mgt.file.FileSystemBasedLicenseManager;

import java.io.File;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

/**
 * This is a test case for testing common utilities used.
 */
public class UtilsTest {
    private FileSystemBasedLicenseManager fileSystemBasedLicenseManager;

    @BeforeTest
    public void setup() {
        fileSystemBasedLicenseManager = new FileSystemBasedLicenseManager();
    }

    @Test(description = "This testcase tests the functionality of the DeviceSchemaInitializer")
    public void testDeviceSchemaInitializer()
            throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
        String deviceType = "sample2";
        String expectedDBLocation =
                System.getProperty("carbon.home") + File.separator + "dbscripts" + File.separator + "cdm"
                        + File.separator + "plugins" + File.separator + deviceType + File.separator + "h2.sql";
        DeviceSchemaInitializer deviceSchemaInitializer = new DeviceSchemaInitializer(null, deviceType,
                MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
        Method getDbScriptLocation = DeviceSchemaInitializer.class
                .getDeclaredMethod("getDbScriptLocation", String.class);
        getDbScriptLocation.setAccessible(true);

        String dbLocation = (String) getDbScriptLocation.invoke(deviceSchemaInitializer, "h2");
        Assert.assertEquals(dbLocation, expectedDBLocation,
                "Expected DB location for the device type is not retrieved");
    }

    @Test(description = "This test case tests the getLicense method of the FileBasedLicenseManager")
    public void testFileBasedLicenseManagerGetLicense() throws LicenseManagementException {
        License fileBasedLicense = fileSystemBasedLicenseManager.getLicense("test","en_US");
        Assert.assertEquals(fileBasedLicense.getText(), "This is a file based license",
                "FileBased License cannot " + "be retrieved by FileBasedLicenseManager");
    }

    @Test(description = "This test case tests the behaviour of file based license manager when the relevant license "
            + "is missing in file system", expectedExceptions = {LicenseManagementException.class},
            expectedExceptionsMessageRegExp = "License file not found in the path for the device type test2")
    public void testFileBasedLicenseManagerGetNonExistingLicense() throws LicenseManagementException {
       fileSystemBasedLicenseManager.getLicense("test2","en_US");
    }

    @Test(description = "This test case make sure the File Based License cannot be added without adding directly to "
            + "file system", expectedExceptions = {UnsupportedOperationException.class},
            expectedExceptionsMessageRegExp = "'addLicense' method is not supported in FileSystemBasedLicenseManager")
    public void testFileBasedLicenseManagerAddLicense() throws LicenseManagementException {
       fileSystemBasedLicenseManager.addLicense("test", null);
    }
}


text:
package org.ladanse.service.command.event;

import org.ladanse.dto.event.EventPatchDto;
import org.ladanse.persistence.entity.account.Account;
import org.ladanse.persistence.entity.event.Event;
import org.ladanse.persistence.repository.AccountRepository;
import org.ladanse.persistence.repository.EventRepository;
import org.ladanse.service.ResourceNotFoundException;
import org.ladanse.service.cqrs.Command;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.sql.Timestamp;
import java.time.LocalDateTime;

@Component
public class PatchEventCommand implements Command
{
    private AccountRepository accountRepository;
    private EventRepository eventRepository;

    private Integer eventId;
    private EventPatchDto eventPatchDto;

    public PatchEventCommand setEventId(Integer eventId)
    {
        this.eventId = eventId;
        return this;
    }

    public PatchEventCommand setEventPatchDto(EventPatchDto eventPatchDto)
    {
        this.eventPatchDto = eventPatchDto;

        return this;
    }

    public void execute()
            throws ResourceNotFoundException
    {
        Event event = eventRepository.findOne(eventId);

        if (event == null)
        {
            throw new ResourceNotFoundException(String.format("Could not find event with id %d", eventId));
        }

        Account organiser = accountRepository.findOne(eventPatchDto.getOrganiserId());

        if (organiser == null)
        {
            throw new ResourceNotFoundException(String.format(
                    "Could not find account with id %d to set as organiser",
                    eventPatchDto.getOrganiserId()));
        }

        event.setName(eventPatchDto.getName())
             .setDescription(eventPatchDto.getDescription())
             .setInviteTime(Timestamp.valueOf(eventPatchDto.getInviteTime()
                                                           .toLocalDateTime()))
             .setStartTime(Timestamp.valueOf(eventPatchDto.getInviteTime()
                                                          .toLocalDateTime()))
             .setEndTime(Timestamp.valueOf(eventPatchDto.getInviteTime()
                                                        .toLocalDateTime()))
             .setLastModifiedTime(Timestamp.valueOf(LocalDateTime.now()));

        eventRepository.saveAndFlush(event);
    }

    @Autowired
    public PatchEventCommand(AccountRepository accountRepository,
                             EventRepository eventRepository)
    {
        this.accountRepository = accountRepository;
        this.eventRepository = eventRepository;
    }
}


text:
package org.apache.felix.ipojo.composite.service.provides;

import java.util.ArrayList;
import java.util.List;

import org.apache.felix.ipojo.architecture.HandlerDescription;
import org.apache.felix.ipojo.composite.CompositeHandler;
import org.apache.felix.ipojo.metadata.Attribute;
import org.apache.felix.ipojo.metadata.Element;
import org.apache.felix.ipojo.util.DependencyModel;

/**
 * Provided Service Handler Description for composite.
 *
 * @author Felix Project Team
 */
public class ProvidedServiceHandlerDescription extends HandlerDescription {

    /**
     * Provided Service Description list.
     */
    private List m_services = new ArrayList();

    /**
     * List of exports.
     */
    private List m_exports;

    /**
     * Constructor.
     *
     * @param handler : composite handler.
     * @param services : The list of Provided Service.
     * @param exporters : list of managed exports
     */
    public ProvidedServiceHandlerDescription(CompositeHandler handler, List services, List exporters) {
        super(handler);
        m_services = services;
        m_exports = exporters;
    }

    /**
     * Get the handler description.
     * @return the provided service handler description
     * @see org.apache.felix.ipojo.architecture.HandlerDescription#getHandlerInfo()
     */
    public Element getHandlerInfo() {
        Element services = super.getHandlerInfo();
        for (int i = 0; i < m_services.size(); i++) {
            ProvidedService svc = (ProvidedService) m_services.get(i);
            Element service = new Element("service", "");
            String state = "unregistered";
            if (svc.isRegistered()) {
                state = "registered";
            }
            String spec = "[" + svc.getSpecification() + "]";
            service.addAttribute(new Attribute("Specification", spec));
            service.addAttribute(new Attribute("State", state));
            services.addElement(service);
        }

        for (int i = 0; i < m_exports.size(); i++) {
            ServiceExporter exp = (ServiceExporter) m_exports.get(i);
            Element expo = new Element("Exports", "");
            expo.addAttribute(new Attribute("Specification", exp.getSpecification().getName()));
            expo.addAttribute(new Attribute("Filter", exp.getFilter()));
            if (exp.getState() == DependencyModel.RESOLVED) {
                expo.addAttribute(new Attribute("State", "resolved"));
            } else {
                expo.addAttribute(new Attribute("State", "unresolved"));
            }
            services.addElement(expo);
        }

        return services;
    }

}


text:
/**************************************************************************//**
 * @file     qei.c
 * @version  V3.00
 * $Revision: 2 $
 * $Date: 17/09/20 9:33a $
 * @brief    Quadrature Encoder Interface (QEI) driver source file
 *
 * @note
 * @copyright SPDX-License-Identifier: Apache-2.0
 * Copyright (C) 2017 Nuvoton Technology Corp. All rights reserved.
*****************************************************************************/
#include "NuMicro.h"

/** @addtogroup Standard_Driver Standard Driver
  @{
*/

/** @addtogroup QEI_Driver QEI Driver
  @{
*/

/** @addtogroup QEI_EXPORTED_FUNCTIONS QEI Exported Functions
  @{
*/

/**
  * @brief      Close QEI function
  * @param[in]  qei         The pointer of the specified QEI module.
  * @return     None
  * @details    This function reset QEI configuration and stop QEI counting.
  */
void QEI_Close(QEI_T* qei)
{
    /* Reset QEI configuration */
    qei->CTL = 0UL;
}

/**
  * @brief      Disable QEI interrupt
  * @param[in]  qei         The pointer of the specified QEI module.
  * @param[in]  u32IntSel   Interrupt type selection.
  *                         - \ref QEI_CTL_DIRIEN_Msk   : Direction change interrupt
  *                         - \ref QEI_CTL_OVUNIEN_Msk  : Counter overflow or underflow interrupt
  *                         - \ref QEI_CTL_CMPIEN_Msk   : Compare-match interrupt
  *                         - \ref QEI_CTL_IDXIEN_Msk   : Index detected interrupt
  * @return     None
  * @details    This function disable QEI specified interrupt.
  */
void QEI_DisableInt(QEI_T* qei, uint32_t u32IntSel)
{
    /* Disable QEI specified interrupt */
    QEI_DISABLE_INT(qei, u32IntSel);

    /* Disable NVIC QEI IRQ */
    if((qei == QEI0) || (qei == QEI0_NS))
    {
        NVIC_DisableIRQ(QEI0_IRQn);
    }
    else
    {
        NVIC_DisableIRQ(QEI1_IRQn);
    }
}

/**
  * @brief      Enable QEI interrupt
  * @param[in]  qei         The pointer of the specified QEI module.
  * @param[in]  u32IntSel   Interrupt type selection.
  *                         - \ref QEI_CTL_DIRIEN_Msk   : Direction change interrupt
  *                         - \ref QEI_CTL_OVUNIEN_Msk  : Counter overflow or underflow interrupt
  *                         - \ref QEI_CTL_CMPIEN_Msk   : Compare-match interrupt
  *                         - \ref QEI_CTL_IDXIEN_Msk   : Index detected interrupt
  * @return     None
  * @details    This function enable QEI specified interrupt.
  */
void QEI_EnableInt(QEI_T* qei, uint32_t u32IntSel)
{
    /* Enable QEI specified interrupt */
    QEI_ENABLE_INT(qei, u32IntSel);

    /* Enable NVIC QEI IRQ */
    if((qei == QEI0) || (qei == QEI0_NS))
    {
        NVIC_EnableIRQ(QEI0_IRQn);
    }
    else
    {
        NVIC_EnableIRQ(QEI1_IRQn);
    }
}

/**
  * @brief      Open QEI in specified mode and enable input
  * @param[in]  qei         The pointer of the specified QEI module.
  * @param[in]  u32Mode     QEI counting mode.
  *                         - \ref QEI_CTL_X4_FREE_COUNTING_MODE
  *                         - \ref QEI_CTL_X2_FREE_COUNTING_MODE
  *                         - \ref QEI_CTL_X4_COMPARE_COUNTING_MODE
  *                         - \ref QEI_CTL_X2_COMPARE_COUNTING_MODE
  * @param[in]  u32Value    The counter maximum value in compare-counting mode.
  * @return     None
  * @details    This function set QEI in specified mode and enable input.
  */
void QEI_Open(QEI_T* qei, uint32_t u32Mode, uint32_t u32Value)
{
    /* Set QEI function configuration */
    /* Set QEI counting mode */
    /* Enable IDX, QEA and QEB input to QEI controller */
    qei->CTL = (qei->CTL & (~QEI_CTL_MODE_Msk)) | ((u32Mode) | QEI_CTL_CHAEN_Msk | QEI_CTL_CHBEN_Msk | QEI_CTL_IDXEN_Msk);

    /* Set QEI maximum count value in in compare-counting mode */
    qei->CNTMAX = u32Value;
}

/**
  * @brief      Start QEI function
  * @param[in]  qei     The pointer of the specified QEI module.
  * @return     None
  * @details    This function enable QEI function and start QEI counting.
  */
void QEI_Start(QEI_T* qei)
{
    /* Enable QEI controller function */
    qei->CTL |= QEI_CTL_QEIEN_Msk;
}

/**
  * @brief      Stop QEI function
  * @param[in]  qei     The pointer of the specified QEI module.
  * @return     None
  * @details    This function disable QEI function and stop QEI counting.
  */
void QEI_Stop(QEI_T* qei)
{
    /* Disable QEI controller function */
    qei->CTL &= (~QEI_CTL_QEIEN_Msk);
}

/**@}*/ /* end of group QEI_EXPORTED_FUNCTIONS */

/**@}*/ /* end of group QEI_Driver */

/**@}*/ /* end of group Standard_Driver */

/*** (C) COPYRIGHT 2017 Nuvoton Technology Corp. ***/


text: kubectl.sh create -f ./replication_controller.yaml


text:
/*jshint node:true, mocha:true */

'use strict';

require('should');

var adapter = require('floating-adapter');
var Decimal = require('linear-arbitrary-precision')(adapter);
var anyToAny = require('../src/linear-preset-any-to-any')(Decimal);
var temp = require('linear-presets-temperature').conversions;

function scaleVals(scale) {
  return scale.map(Number)
}

describe('convert units any to any', function() {
  it('should return presets for any to any', function() {
    anyToAny(temp, 'kelvin', 'fahrenheit').map(scaleVals)
      .should.eql([[273.15, 373.15], [32, 212]]);

    anyToAny(temp, 'celsius', 'fahrenheit').map(scaleVals)
      .should.eql([[0, 1], [32, 33.8]]);

    anyToAny(temp, 'fahrenheit', 'celsius').map(scaleVals)
      .should.eql([[32, 212], [0, 100]]);

    anyToAny(temp, 'celsius', 'celsius').map(scaleVals)
      .should.eql([[0, 1], [0, 1]]);
  });
});


text:
/*
 *  pixalloc.c
 *
 *      Custom memory storage with allocator and deallocator
 *
 *          l_int32       pmsCreate()
 *          void          pmsDestroy()
 *          void         *pmsCustomAlloc()
 *          void          pmsCustomDealloc()
 *          void         *pmsGetAlloc()
 *          l_int32       pmsGetLevelForAlloc()
 *          l_int32       pmsGetLevelForDealloc()
 *          void          pmsLogInfo()
 */

#include BLIK_OPENALPR_U_allheaders_h //original-code:"allheaders.h"

/*-------------------------------------------------------------------------*
 *                          Pix Memory Storage                             *
 *                                                                         *
 *  This is a simple utility for handling pix memory storage.  It is       *
 *  enabled by setting the PixMemoryManager allocators to the functions    *
 *  that are defined here                                                  *
 *        pmsCustomAlloc()                                                 *
 *        pmsCustomDealloc()                                               *
 *  Use pmsCreate() at the beginning to do the pre-allocation, and         *
 *  pmsDestroy() at the end to clean it up.                                *
 *-------------------------------------------------------------------------*/
/*
 *  In the following, the "memory" refers to the image data
 *  field that is used within the pix.  The memory store is a
 *  continuous block of memory, that is logically divided into
 *  smaller "chunks" starting with a set at a minimum size, and
 *  followed by sets of increasing size that are a power of 2 larger
 *  than the minimum size.  You must specify the number of chunks
 *  of each size.
 *
 *  A requested data chunk, if it exists, is borrowed from the memory
 *  storage, and returned after use.  If the chunk is too small, or
 *  too large, or if all chunks in the appropriate size range are
 *  in use, the memory is allocated dynamically and freed after use.
 *
 *  There are four parameters that determine the use of pre-allocated memory:
 *
 *    minsize: any requested chunk smaller than this is allocated
 *             dynamically and destroyed after use.  No preallocated
 *             memory is used.
 *    smallest: the size of the smallest pre-allocated memory chunk.
 *    nlevels:  the number of different sizes of data chunks, each a
 *              power of 2 larger than 'smallest'.
 *    numalloc: a Numa of size 'nlevels' containing the number of data
 *              chunks for each size that are in the memory store.
 *
 *  As an example, suppose:
 *    minsize = 0.5MB
 *    smallest = 1.0MB
 *    nlevels = 4
 *    numalloc = {10, 5, 5, 5}
 *  Then the total amount of allocated memory (in MB) is
 *    10 * 1 + 5 * 2 + 5 * 4 + 5 * 8 = 80 MB
 *  Any pix requiring less than 0.5 MB or more than 8 MB of memory will
 *  not come from the memory store.  Instead, it will be dynamically
 *  allocated and freed after use.
 *
 *  How is this implemented?
 *
 *  At setup, the full data block size is computed and allocated.
 *  The addresses of the individual chunks are found, and the pointers
 *  are stored in a set of Ptra (generic pointer arrays), using one Ptra
 *  for each of the sizes of the chunks.  When returning a chunk after
 *  use, it is necessary to determine from the address which size level
 *  (ptra) the chunk belongs to.  This is done by comparing the address
 *  of the associated chunk.
 *
 *  In the event that memory chunks need to be dynamically allocated,
 *  either (1) because they are too small or too large for the memory
 *  store or (2) because all the pix of that size (i.e., in the
 *  appropriate level) in the memory store are in use, the
 *  addresses generated will be outside the pre-allocated block.
 *  After use they won't be returned to a ptra; instead the deallocator
 *  will free them.
 */

struct PixMemoryStore
{
    struct L_Ptraa  *paa;          /* Holds ptrs to allocated memory        */
    size_t           minsize;      /* Pix smaller than this (in bytes)      */
                                   /* are allocated dynamically             */
    size_t           smallest;     /* Smallest mem (in bytes) alloc'd       */
    size_t           largest;      /* Larest mem (in bytes) alloc'd         */
    size_t           nbytes;       /* Size of allocated block w/ all chunks */
    l_int32          nlevels;      /* Num of power-of-2 sizes pre-alloc'd   */
    size_t          *sizes;        /* Mem sizes at each power-of-2 level    */
    l_int32         *allocarray;   /* Number of mem alloc'd at each size    */
    l_uint32        *baseptr;      /* ptr to allocated array                */
    l_uint32        *maxptr;       /* ptr just beyond allocated memory      */
    l_uint32       **firstptr;     /* array of ptrs to first chunk in size  */
    l_int32         *memused;      /* log: total # of pix used (by level)   */
    l_int32         *meminuse;     /* log: # of pix in use (by level)       */
    l_int32         *memmax;       /* log: max # of pix in use (by level)   */
    l_int32         *memempty;     /* log: # of pix alloc'd because         */
                                   /*      the store was empty (by level)   */
    char            *logfile;      /* log: set to null if no logging        */
};
typedef struct PixMemoryStore   L_PIX_MEM_STORE;

static L_PIX_MEM_STORE  *CustomPMS = NULL;

/*!
 *  pmsCreate()
 *
 *      Input:  minsize (of data chunk that can be supplied by pms)
 *              smallest (bytes of the smallest pre-allocated data chunk.
 *              numalloc (array with the number of data chunks for each
 *                        size that are in the memory store)
 *              logfile (use for debugging; null otherwise)
 *      Return: 0 if OK, 1 on error
 *
 *  Notes:
 *      (1) This computes the size of the block of memory required
 *          and allocates it.  Each chunk starts on a 32-bit word boundary.
 *          The chunk sizes are in powers of 2, starting at @smallest,
 *          and the number of levels and chunks at each level is
 *          specified by @numalloc.
 *      (2) This is intended to manage the image data for a small number
 *          of relatively large pix.  The system malloc is expected to
 *          handle very large numbers of small chunks efficiently.
 *      (3) Important: set the allocators and call this function
 *          before any pix have been allocated.  Destroy all the pix
 *          in the normal way before calling pmsDestroy().
 *      (4) The pms struct is stored in a static global, so this function
 *          is not thread-safe.  When used, there must be only one thread
 *          per process.
 */
l_int32
pmsCreate(size_t       minsize,
          size_t       smallest,
          NUMA        *numalloc,
          const char  *logfile)
{
l_int32           nlevels, i, j, nbytes;
l_int32          *alloca;
l_float32         nchunks;
l_uint32         *baseptr, *data;
l_uint32        **firstptr;
size_t           *sizes;
L_PIX_MEM_STORE  *pms;
L_PTRA           *pa;
L_PTRAA          *paa;

    PROCNAME("createPMS");

    if (!numalloc)
        return ERROR_INT("numalloc not defined", procName, 1);
    numaGetSum(numalloc, &nchunks);
    if (nchunks > 1000.0)
        L_WARNING("There are %.0f chunks\n", procName, nchunks);

    if ((pms = (L_PIX_MEM_STORE *)CALLOC(1, sizeof(L_PIX_MEM_STORE))) == NULL)
        return ERROR_INT("pms not made", procName, 1);
    CustomPMS = pms;

        /* Make sure that minsize and smallest are multiples of 32 bit words */
    if (minsize % 4 != 0)
        minsize -= minsize % 4;
    pms->minsize = minsize;
    nlevels = numaGetCount(numalloc);
    pms->nlevels = nlevels;

    if ((sizes = (size_t *)CALLOC(nlevels, sizeof(size_t))) == NULL)
        return ERROR_INT("sizes not made", procName, 1);
    pms->sizes = sizes;
    if (smallest % 4 != 0)
        smallest += 4 - (smallest % 4);
    pms->smallest = smallest;
    for (i = 0; i < nlevels; i++)
        sizes[i] = smallest * (1 << i);
    pms->largest = sizes[nlevels - 1];

    alloca = numaGetIArray(numalloc);
    pms->allocarray = alloca;
    if ((paa = ptraaCreate(nlevels)) == NULL)
        return ERROR_INT("paa not made", procName, 1);
    pms->paa = paa;

    for (i = 0, nbytes = 0; i < nlevels; i++)
        nbytes += alloca[i] * sizes[i];
    pms->nbytes = nbytes;

    if ((baseptr = (l_uint32 *)CALLOC(nbytes / 4, sizeof(l_uint32))) == NULL)
        return ERROR_INT("calloc fail for baseptr", procName, 1);
    pms->baseptr = baseptr;
    pms->maxptr = baseptr + nbytes / 4;  /* just beyond the memory store */
    if ((firstptr = (l_uint32 **)CALLOC(nlevels, sizeof(l_uint32 *))) == NULL)
        return ERROR_INT("calloc fail for firstptr", procName, 1);
    pms->firstptr = firstptr;

    data = baseptr;
    for (i = 0; i < nlevels; i++) {
        if ((pa = ptraCreate(alloca[i])) == NULL)
            return ERROR_INT("pa not made", procName, 1);
        ptraaInsertPtra(paa, i, pa);
        firstptr[i] = data;
        for (j = 0; j < alloca[i]; j++) {
            ptraAdd(pa, data);
            data += sizes[i] / 4;
        }
    }

    if (logfile) {
        pms->memused = (l_int32 *)CALLOC(nlevels, sizeof(l_int32));
        pms->meminuse = (l_int32 *)CALLOC(nlevels, sizeof(l_int32));
        pms->memmax = (l_int32 *)CALLOC(nlevels, sizeof(l_int32));
        pms->memempty = (l_int32 *)CALLOC(nlevels, sizeof(l_int32));
        pms->logfile = stringNew(logfile);
    }

    return 0;
}

/*!
 *  pmsDestroy()
 *
 *      Input:  (none)
 *      Return: void
 *
 *  Notes:
 *      (1) Important: call this function at the end of the program, after
 *          the last pix has been destroyed.
 */
void
pmsDestroy()
{
L_PIX_MEM_STORE  *pms;

    if ((pms = CustomPMS) == NULL)
        return;

    ptraaDestroy(&pms->paa, FALSE, FALSE);  /* don't touch the ptrs */
    FREE(pms->baseptr);  /* free the memory */

    if (pms->logfile) {
        pmsLogInfo();
        FREE(pms->logfile);
        FREE(pms->memused);
        FREE(pms->meminuse);
        FREE(pms->memmax);
        FREE(pms->memempty);
    }

    FREE(pms->sizes);
    FREE(pms->allocarray);
    FREE(pms->firstptr);
    FREE(pms);
    CustomPMS = NULL;
    return;
}

/*!
 *  pmsCustomAlloc()
 *
 *      Input: nbytes (min number of bytes in the chunk to be retrieved)
 *      Return: data (ptr to chunk)
 *
 *  Notes:
 *      (1) This attempts to find a suitable pre-allocated chunk.
 *          If not found, it dynamically allocates the chunk.
 *      (2) If logging is turned on, the allocations that are not taken
 *          from the memory store, and are at least as large as the
 *          minimum size the store can handle, are logged to file.
 */
void *
pmsCustomAlloc(size_t  nbytes)
{
l_int32           level;
void             *data;
L_PIX_MEM_STORE  *pms;
L_PTRA           *pa;

    PROCNAME("pmsCustomAlloc");

    if ((pms = CustomPMS) == NULL)
        return (void *)ERROR_PTR("pms not defined", procName, NULL);

    pmsGetLevelForAlloc(nbytes, &level);

    if (level < 0) {  /* size range invalid; must alloc */
        if ((data = pmsGetAlloc(nbytes)) == NULL)
            return (void *)ERROR_PTR("data not made", procName, NULL);
    } else {  /* get from store */
        pa = ptraaGetPtra(pms->paa, level, L_HANDLE_ONLY);
        data = ptraRemoveLast(pa);
        if (data && pms->logfile) {
            pms->memused[level]++;
            pms->meminuse[level]++;
            if (pms->meminuse[level] > pms->memmax[level])
                pms->memmax[level]++;
        }
        if (!data) {  /* none left at this level */
            data = pmsGetAlloc(nbytes);
            if (pms->logfile)
                pms->memempty[level]++;
        }
    }

    return data;
}

/*!
 *  pmsCustomDealloc()
 *
 *      Input: data (to be freed or returned to the storage)
 *      Return: void
 */
void
pmsCustomDealloc(void  *data)
{
l_int32           level;
L_PIX_MEM_STORE  *pms;
L_PTRA           *pa;

    PROCNAME("pmsCustomDealloc");

    if ((pms = CustomPMS) == NULL) {
        L_ERROR("pms not defined\n", procName);
        return;
    }

    if (pmsGetLevelForDealloc(data, &level) == 1) {
        L_ERROR("level not found\n", procName);
        return;
    }

    if (level < 0) {  /* no logging; just free the data */
        FREE(data);
    } else {  /* return the data to the store */
        pa = ptraaGetPtra(pms->paa, level, L_HANDLE_ONLY);
        ptraAdd(pa, data);
        if (pms->logfile)
            pms->meminuse[level]--;
    }

    return;
}

/*!
 *  pmsGetAlloc()
 *
 *      Input:  nbytes
 *      Return: data
 *
 *  Notes:
 *      (1) This is called when a request for pix data cannot be
 *          obtained from the preallocated memory store.  After use it
 *          is freed like normal memory.
 *      (2) If logging is on, only write out allocs that are as large as
 *          the minimum size handled by the memory store.
 *      (3) size_t is %lu on 64 bit platforms and %u on 32 bit platforms.
 *          The C99 platform-independent format specifier for size_t is %zu,
 *          but windows hasn't conformed, so we are forced to go back to
 *          C89, use %lu, and cast to get platform-independence.  Ugh.
 */
void *
pmsGetAlloc(size_t  nbytes)
{
void             *data;
FILE             *fp;
L_PIX_MEM_STORE  *pms;

    PROCNAME("pmsGetAlloc");

    if ((pms = CustomPMS) == NULL)
        return (void *)ERROR_PTR("pms not defined", procName, NULL);

    if ((data = (void *)CALLOC(nbytes, sizeof(char))) == NULL)
        return (void *)ERROR_PTR("data not made", procName, NULL);
    if (pms->logfile && nbytes >= pms->smallest) {
        fp = fopenWriteStream(pms->logfile, "a");
        fprintf(fp, "Alloc %lu bytes at %p\n", (unsigned long)nbytes, data);
        fclose(fp);
    }

    return data;
}

/*!
 *  pmsGetLevelForAlloc()
 *
 *      Input: nbytes (min number of bytes in the chunk to be retrieved)
 *             &level (<return>; -1 if either too small or too large)
 *      Return: 0 if OK, 1 on error
 */
l_int32
pmsGetLevelForAlloc(size_t    nbytes,
                    l_int32  *plevel)
{
l_int32           i;
l_float64         ratio;
L_PIX_MEM_STORE  *pms;

    PROCNAME("pmsGetLevelForAlloc");

    if (!plevel)
        return ERROR_INT("&level not defined", procName, 1);
    *plevel = -1;
    if ((pms = CustomPMS) == NULL)
        return ERROR_INT("pms not defined", procName, 1);

    if (nbytes < pms->minsize || nbytes > pms->largest)
        return 0;   /*  -1  */

    ratio = (l_float64)nbytes / (l_float64)(pms->smallest);
    for (i = 0; i < pms->nlevels; i++) {
        if (ratio <= 1.0)
            break;
        ratio /= 2.0;
    }
    *plevel = i;

    return 0;
}

/*!
 *  pmsGetLevelForDealloc()
 *
 *      Input: data (ptr to memory chunk)
 *             &level (<return> level in memory store; -1 if allocated
 *                     outside the store)
 *      Return: 0 if OK, 1 on error
 */
l_int32
pmsGetLevelForDealloc(void     *data,
                      l_int32  *plevel)
{
l_int32           i;
l_uint32         *first;
L_PIX_MEM_STORE  *pms;

    PROCNAME("pmsGetLevelForDealloc");

    if (!plevel)
        return ERROR_INT("&level not defined", procName, 1);
    *plevel = -1;
    if (!data)
        return ERROR_INT("data not defined", procName, 1);
    if ((pms = CustomPMS) == NULL)
        return ERROR_INT("pms not defined", procName, 1);

    if (data < (void *)pms->baseptr || data >= (void *)pms->maxptr)
        return 0;   /*  -1  */

    for (i = 1; i < pms->nlevels; i++) {
        first = pms->firstptr[i];
        if (data < (void *)first)
            break;
    }
    *plevel = i - 1;

    return 0;
}

/*!
 *  pmsLogInfo()
 *
 *      Input:  (none)
 *      Return: void
 */
void
pmsLogInfo()
{
l_int32           i;
L_PIX_MEM_STORE  *pms;

    if ((pms = CustomPMS) == NULL)
        return;

    fprintf(stderr, "Total number of pix used at each level\n");
    for (i = 0; i < pms->nlevels; i++)
         fprintf(stderr, " Level %d (%lu bytes): %d\n", i,
                 (unsigned long)pms->sizes[i], pms->memused[i]);

    fprintf(stderr, "Max number of pix in use at any time in each level\n");
    for (i = 0; i < pms->nlevels; i++)
         fprintf(stderr, " Level %d (%lu bytes): %d\n", i,
                 (unsigned long)pms->sizes[i], pms->memmax[i]);

    fprintf(stderr, "Number of pix alloc'd because none were available\n");
    for (i = 0; i < pms->nlevels; i++)
         fprintf(stderr, " Level %d (%lu bytes): %d\n", i,
                 (unsigned long)pms->sizes[i], pms->memempty[i]);

    return;
}


text:
package com.github.jnthnclt.os.lab.core.guts.api;

import com.github.jnthnclt.os.lab.core.guts.IndexRangeId;
import java.util.List;
import com.github.jnthnclt.os.lab.core.guts.ReadOnlyIndex;

/**
 *
 * @author jonathan.colt
 */
public interface CommitIndex {

    ReadOnlyIndex commit(List<IndexRangeId> ids) throws Exception;

}


text:
import camelCaseToDash from './camelCaseToDash';

describe('camelCaseToDash', () => {
  it('should transfer camel case string to dash', () => {
    expect(camelCaseToDash('backgroundColor')).toEqual('background-color');
  });

  it('should return empty when given null or undefined or empty string', () => {
    expect(camelCaseToDash('')).toEqual('');
    expect(camelCaseToDash()).toEqual('');
  });
});