text:
namespace palo {
namespace column_file {

using namespace testing;

TEST(TestStream, UncompressOutStream) {
    // write data
    OutStream *out_stream =
            new(std::nothrow) OutStream(OLAP_DEFAULT_COLUMN_STREAM_BUFFER_SIZE, NULL);
    ASSERT_TRUE(out_stream != NULL);
    ASSERT_TRUE(out_stream->_compressor == NULL);

    out_stream->write(0x5a);
    out_stream->flush();

    ASSERT_EQ(out_stream->get_stream_length(), sizeof(StreamHead) + 1);

    ASSERT_EQ(out_stream->output_buffers().size(), 1);

    std::vector<ByteBuffer*>::const_iterator it = out_stream->output_buffers().begin();
    ASSERT_EQ((*it)->position(), 0);
    StreamHead head;
    (*it)->get((char *)&head, sizeof(head));
    ASSERT_EQ(head.type, StreamHead::UNCOMPRESSED);
    ASSERT_EQ(head.length, 1);
    char data;
    ASSERT_EQ(OLAP_SUCCESS, (*it)->get((char *)&data));
    ASSERT_EQ(0x5A, data);
    ASSERT_NE(OLAP_SUCCESS, (*it)->get((char *)&data));

    SAFE_DELETE(out_stream);
}

TEST(TestStream, UncompressOutStream2) {
    // write data
    OutStream *out_stream =
            new(std::nothrow) OutStream(OLAP_DEFAULT_COLUMN_STREAM_BUFFER_SIZE, NULL);
    ASSERT_TRUE(out_stream != NULL);
    ASSERT_TRUE(out_stream->_compressor == NULL);

    for (int32_t i = 0; i < OLAP_DEFAULT_COLUMN_STREAM_BUFFER_SIZE; i++) {
        out_stream->write(0x5a);
    }
    out_stream->write(0x5a);
    out_stream->flush();

    uint64_t stream_length = sizeof(StreamHead)*2 + OLAP_DEFAULT_COLUMN_STREAM_BUFFER_SIZE + 1;
    ASSERT_EQ(out_stream->get_stream_length(), stream_length);

    ASSERT_EQ(out_stream->output_buffers().size(), 2);

    std::vector<ByteBuffer*> inputs;
    std::vector<ByteBuffer*>::const_iterator it = out_stream->output_buffers().begin();
    for (; it != out_stream->output_buffers().end(); ++it) {
        ByteBuffer *tmp_byte_buffer = ByteBuffer::reference_buffer(*it, 0, (*it)->limit());
        inputs.push_back(tmp_byte_buffer);
    }
    std::vector<uint64_t> offsets;
    offsets.push_back(0);
    offsets.push_back(sizeof(StreamHead) + OLAP_DEFAULT_COLUMN_STREAM_BUFFER_SIZE);
    InStream *in_stream =
            new (std::nothrow) InStream(&inputs,
                                        offsets,
                                        out_stream->get_stream_length(),
                                        NULL,
                                        out_stream->get_total_buffer_size());

    char data;
    for (int32_t i = 0; i < OLAP_DEFAULT_COLUMN_STREAM_BUFFER_SIZE-1; i++) {

        ASSERT_EQ(in_stream->read(&data), OLAP_SUCCESS);
        ASSERT_EQ(data, 0x5a);
    }
    ASSERT_EQ(in_stream->read(&data), OLAP_SUCCESS);
    ASSERT_EQ(data, 0x5a);
    ASSERT_EQ(in_stream->read(&data), OLAP_SUCCESS);
    ASSERT_EQ(data, 0x5a);

    ASSERT_NE(in_stream->read(&data), OLAP_SUCCESS);

    SAFE_DELETE(out_stream);
    SAFE_DELETE(in_stream);
}

TEST(TestStream, UncompressOutStream3) {
    // write data
    OutStream *out_stream =
            new(std::nothrow) OutStream(OLAP_DEFAULT_COLUMN_STREAM_BUFFER_SIZE, NULL);
    ASSERT_TRUE(out_stream != NULL);
    ASSERT_TRUE(out_stream->_compressor == NULL);

    for (int32_t i = 0; i < OLAP_DEFAULT_COLUMN_STREAM_BUFFER_SIZE; i++) {
        out_stream->write(0x5a);
    }
    char write_data[2] = {0x5a, 0x5a};
    out_stream->write(write_data, 2);
    out_stream->flush();

    uint64_t stream_length = sizeof(StreamHead)*2 + OLAP_DEFAULT_COLUMN_STREAM_BUFFER_SIZE + 2;
    ASSERT_EQ(out_stream->get_stream_length(), stream_length);

    ASSERT_EQ(out_stream->output_buffers().size(), 2);

    std::vector<ByteBuffer*> inputs;
    std::vector<ByteBuffer*>::const_iterator it = out_stream->output_buffers().begin();
    for (; it != out_stream->output_buffers().end(); ++it) {
        ByteBuffer *tmp_byte_buffer = ByteBuffer::reference_buffer(*it, 0, (*it)->limit());
        inputs.push_back(tmp_byte_buffer);
    }

    std::vector<uint64_t> offsets;
    offsets.push_back(0);
    offsets.push_back(sizeof(StreamHead) + OLAP_DEFAULT_COLUMN_STREAM_BUFFER_SIZE);
    InStream *in_stream =
            new (std::nothrow) InStream(&inputs,
                                        offsets,
                                        out_stream->get_stream_length(),
                                        NULL,
                                        out_stream->get_total_buffer_size());

    char data;
    for (int32_t i = 0; i < OLAP_DEFAULT_COLUMN_STREAM_BUFFER_SIZE; i++) {

        ASSERT_EQ(in_stream->read(&data), OLAP_SUCCESS);
        ASSERT_EQ(data, 0x5a);
    }
    ASSERT_EQ(in_stream->read(&data), OLAP_SUCCESS);
    ASSERT_EQ(data, 0x5a);

    ASSERT_EQ(in_stream->read(&data), OLAP_SUCCESS);
    ASSERT_EQ(data, 0x5a);

    ASSERT_NE(in_stream->read(&data), OLAP_SUCCESS);

    SAFE_DELETE(out_stream);
}

TEST(TestStream, UncompressInStream) {
    // write data
    OutStream *out_stream =
            new(std::nothrow) OutStream(OLAP_DEFAULT_COLUMN_STREAM_BUFFER_SIZE, NULL);
    ASSERT_TRUE(out_stream != NULL);
    ASSERT_TRUE(out_stream->_compressor == NULL);

    out_stream->write(0x5a);
    out_stream->flush();

    // read data
    std::vector<ByteBuffer*> inputs;
    std::vector<ByteBuffer*>::const_iterator it = out_stream->output_buffers().begin();
    ASSERT_NE(it, out_stream->output_buffers().end());
    ByteBuffer *tmp_byte_buffer = ByteBuffer::reference_buffer(*it, 0, (*it)->capacity());
    inputs.push_back(tmp_byte_buffer);

    std::vector<uint64_t> offsets;
    offsets.assign(inputs.size(), 0);
    InStream *in_stream =
            new (std::nothrow) InStream(&inputs,
                                        offsets,
                                        out_stream->get_stream_length(),
                                        NULL,
                                        out_stream->get_total_buffer_size());
    SAFE_DELETE(out_stream);

    ASSERT_EQ(in_stream->available(), 1);
    char data;
    ASSERT_EQ(in_stream->read(&data), OLAP_SUCCESS);
    ASSERT_EQ(data, 0x5a);

    SAFE_DELETE(in_stream);
}

// the length after compress must be smaller than origal stream, then the compressor will be called.
TEST(TestStream, CompressOutStream) {
    // write data
    OutStream *out_stream =
            new(std::nothrow) OutStream(OLAP_DEFAULT_COLUMN_STREAM_BUFFER_SIZE, lzo_compress);
    ASSERT_TRUE(out_stream != NULL);
    ASSERT_TRUE(out_stream->_compressor != NULL);

    char *write_data = new char[OLAP_DEFAULT_COLUMN_STREAM_BUFFER_SIZE];
    memset(write_data, 0x5a, OLAP_DEFAULT_COLUMN_STREAM_BUFFER_SIZE);

    out_stream->write(write_data, OLAP_DEFAULT_COLUMN_STREAM_BUFFER_SIZE);
    out_stream->flush();

    //ASSERT_EQ(out_stream->get_stream_length(), sizeof(StreamHead) + 2);

    //ASSERT_EQ(out_stream->output_buffers().size(), 1);

    std::vector<ByteBuffer*>::const_iterator it = out_stream->output_buffers().begin();

    StreamHead head;
    (*it)->get((char *)&head, sizeof(head));
    ASSERT_EQ(head.type, StreamHead::COMPRESSED);
    ASSERT_EQ(head.length, 49);

    SAFE_DELETE_ARRAY(write_data);
    SAFE_DELETE(out_stream);
}

TEST(TestStream, CompressOutStream2) {
    // write data
    OutStream *out_stream =
            new(std::nothrow) OutStream(OLAP_DEFAULT_COLUMN_STREAM_BUFFER_SIZE, lzo_compress);
    ASSERT_TRUE(out_stream != NULL);
    ASSERT_TRUE(out_stream->_compressor != NULL);

    for (int32_t i = 0; i < OLAP_DEFAULT_COLUMN_STREAM_BUFFER_SIZE; i++) {
        out_stream->write(0x5a);
    }
    out_stream->write(0x5a);
    out_stream->flush();

    std::vector<ByteBuffer*> inputs;
    std::vector<ByteBuffer*>::const_iterator it = out_stream->output_buffers().begin();
    for (; it != out_stream->output_buffers().end(); ++it) {
        ByteBuffer *tmp_byte_buffer = ByteBuffer::reference_buffer(*it, 0, (*it)->limit());
        inputs.push_back(tmp_byte_buffer);
    }
    std::vector<uint64_t> offsets;
    offsets.push_back(0);
    offsets.push_back(57);
    InStream *in_stream =
            new (std::nothrow) InStream(&inputs,
                                        offsets,
                                        out_stream->get_stream_length(),
                                        lzo_decompress,
                                        out_stream->get_total_buffer_size());

    char data;
    for (int32_t i = 0; i < OLAP_DEFAULT_COLUMN_STREAM_BUFFER_SIZE; i++) {
        ASSERT_EQ(in_stream->read(&data), OLAP_SUCCESS);
        ASSERT_EQ(data, 0x5a);
    }
    ASSERT_EQ(in_stream->read(&data), OLAP_SUCCESS);
    ASSERT_EQ(data, 0x5a);

    ASSERT_NE(in_stream->read(&data), OLAP_SUCCESS);

    SAFE_DELETE(out_stream);
}

TEST(TestStream, CompressOutStream3) {
    // write data
    OutStream *out_stream =
            new(std::nothrow) OutStream(OLAP_DEFAULT_COLUMN_STREAM_BUFFER_SIZE, lzo_compress);
    ASSERT_TRUE(out_stream != NULL);
    ASSERT_TRUE(out_stream->_compressor != NULL);

    for (int32_t i = 0; i < OLAP_DEFAULT_COLUMN_STREAM_BUFFER_SIZE; i++) {
        out_stream->write(0x5a);
    }
    char write_data[100];
    for (int32_t i = 0; i < sizeof(write_data); i++) {
        write_data[i] = 0x5a;
    }
    out_stream->write(write_data, sizeof(write_data));
    out_stream->flush();

    std::vector<ByteBuffer*> inputs;
    std::vector<ByteBuffer*>::const_iterator it = out_stream->output_buffers().begin();
    for (; it != out_stream->output_buffers().end(); ++it) {
        ByteBuffer *tmp_byte_buffer = ByteBuffer::reference_buffer(*it, 0, (*it)->limit());
        inputs.push_back(tmp_byte_buffer);
    }
    std::vector<uint64_t> offsets;
    offsets.push_back(0);
    offsets.push_back(57);
    InStream *in_stream =
            new (std::nothrow) InStream(&inputs,
                                        offsets,
                                        out_stream->get_stream_length(),
                                        lzo_decompress,
                                        out_stream->get_total_buffer_size());

    char data;
    for (int32_t i = 0; i < OLAP_DEFAULT_COLUMN_STREAM_BUFFER_SIZE; i++) {
        ASSERT_EQ(in_stream->read(&data), OLAP_SUCCESS);
        ASSERT_EQ(data, 0x5a);
    }
    for (int32_t i = 0; i < sizeof(write_data); i++) {
        ASSERT_EQ(in_stream->read(&data), OLAP_SUCCESS);
        ASSERT_EQ(data, write_data[i]);
    }

    ASSERT_NE(in_stream->read(&data), OLAP_SUCCESS);

    SAFE_DELETE(out_stream);
}

//test for _slice() in [while (len > 0 && m_current_range < m_inputs.size())]
TEST(TestStream, CompressOutStream4) {
    // write data
    OutStream *out_stream =
            new(std::nothrow) OutStream(18, lzo_compress);
    ASSERT_TRUE(out_stream != NULL);
    ASSERT_TRUE(out_stream->_compressor != NULL);

    for (int32_t i = 0; i < 15; i++) {
        out_stream->write(0x5a);
    }
    out_stream->_spill();

    for (int32_t i = 0; i < 12; i++) {
        out_stream->write(0x5a);
    }
    for (int32_t i = 0; i < 6; i++) {
        out_stream->write(i);
    }
    out_stream->flush();

    std::vector<ByteBuffer*> inputs;
    std::vector<ByteBuffer*>::const_iterator it = out_stream->output_buffers().begin();
    for (; it != out_stream->output_buffers().end(); ++it) {
        ByteBuffer *tmp_byte_buffer = ByteBuffer::reference_buffer(*it, 0, (*it)->limit());
        inputs.push_back(tmp_byte_buffer);
    }
    std::vector<uint64_t> offsets;
    offsets.push_back(0);
    offsets.push_back(16);
    InStream *in_stream =
            new (std::nothrow) InStream(&inputs,
                                        offsets,
                                        out_stream->get_stream_length(),
                                        lzo_decompress,
                                        out_stream->get_total_buffer_size());

    char data;
    for (int32_t i = 0; i < 15; i++) {
        ASSERT_EQ(in_stream->read(&data), OLAP_SUCCESS);
        ASSERT_EQ(data, 0x5a);
    }

    for (int32_t i = 0; i < 12; i++) {
        ASSERT_EQ(in_stream->read(&data), OLAP_SUCCESS);
        ASSERT_EQ(data, 0x5a);
    }

    for (int32_t i = 0; i < 6; i++) {
        ASSERT_EQ(in_stream->read(&data), OLAP_SUCCESS);
        ASSERT_EQ(data, i);
    }

    ASSERT_NE(in_stream->read(&data), OLAP_SUCCESS);

    SAFE_DELETE(out_stream);
}

TEST(TestStream, CompressMassOutStream) {
    // write data
    OutStream *out_stream =
            new(std::nothrow) OutStream(100, lzo_compress);
    ASSERT_TRUE(out_stream != NULL);
    ASSERT_TRUE(out_stream->_compressor != NULL);

    for (int32_t i = 0; i < 100; i++) {
        out_stream->write(0x5a);
    }
    //out_stream->write(0);

    for (int32_t i = 0; i < 100; i++) {
        out_stream->write(i);
    }
    //out_stream->write(100);
    out_stream->flush();

    std::vector<ByteBuffer*> inputs;
    std::vector<ByteBuffer*>::const_iterator it = out_stream->output_buffers().begin();
    for (; it != out_stream->output_buffers().end(); ++it) {
        ByteBuffer *tmp_byte_buffer = ByteBuffer::reference_buffer(*it, 0, (*it)->limit());
        inputs.push_back(tmp_byte_buffer);
    }
    std::vector<uint64_t> offsets;
    offsets.push_back(0);
    offsets.push_back(17);
    InStream *in_stream =
            new (std::nothrow) InStream(&inputs,
                                        offsets,
                                        out_stream->get_stream_length(),
                                        lzo_decompress,
                                        out_stream->get_total_buffer_size());
    SAFE_DELETE(out_stream);

    char data;
    for (int32_t i = 0; i < 100; i++) {
        ASSERT_EQ(in_stream->read(&data), OLAP_SUCCESS);
        ASSERT_EQ(data, 0x5a);
    }
    for (int32_t i = 0; i < 100; i++) {
        ASSERT_EQ(in_stream->read(&data), OLAP_SUCCESS);
        ASSERT_EQ(data, i);
    }

    ASSERT_NE(in_stream->read(&data), OLAP_SUCCESS);

    SAFE_DELETE(in_stream);
}

TEST(TestStream, CompressInStream) {
    // write data
    OutStream *out_stream =
            new(std::nothrow) OutStream(OLAP_DEFAULT_COLUMN_STREAM_BUFFER_SIZE, lzo_compress);
    ASSERT_TRUE(out_stream != NULL);
    ASSERT_TRUE(out_stream->_compressor != NULL);

    char *write_data = new char[OLAP_DEFAULT_COLUMN_STREAM_BUFFER_SIZE];
    memset(write_data, 0x5a, OLAP_DEFAULT_COLUMN_STREAM_BUFFER_SIZE);

    out_stream->write(write_data, OLAP_DEFAULT_COLUMN_STREAM_BUFFER_SIZE);
    out_stream->flush();

    // read data
    std::vector<ByteBuffer*> inputs;
    std::vector<ByteBuffer*>::const_iterator it = out_stream->output_buffers().begin();
    ASSERT_NE(it, out_stream->output_buffers().end());
    ByteBuffer *tmp_byte_buffer = ByteBuffer::reference_buffer(*it, 0, (*it)->capacity());
    inputs.push_back(tmp_byte_buffer);

    std::vector<uint64_t> offsets;
    offsets.assign(inputs.size(), 0);
    InStream *in_stream = new (std::nothrow) InStream(&inputs,
                                                      offsets,
                                                      out_stream->get_stream_length(),
                                                      lzo_decompress,
                                                      out_stream->get_total_buffer_size());
    ASSERT_EQ(in_stream->available(), OLAP_DEFAULT_COLUMN_STREAM_BUFFER_SIZE);
    char data;
    for (int32_t i = 0; i < OLAP_DEFAULT_COLUMN_STREAM_BUFFER_SIZE-1; ++i) {
        ASSERT_EQ(in_stream->read(&data), OLAP_SUCCESS);
        ASSERT_EQ(data, 0x5a);
    }
    ASSERT_EQ(in_stream->read(&data), OLAP_SUCCESS);
    ASSERT_EQ(data, 0x5a);
    ASSERT_NE(in_stream->read(&data), OLAP_SUCCESS);

    SAFE_DELETE_ARRAY(write_data);
    SAFE_DELETE(out_stream);
    SAFE_DELETE(in_stream);
}

TEST(TestStream, SeekUncompress) {
    // write data
    OutStream *out_stream =
            new(std::nothrow) OutStream(OLAP_DEFAULT_COLUMN_STREAM_BUFFER_SIZE, NULL);
    ASSERT_TRUE(out_stream != NULL);
    ASSERT_TRUE(out_stream->_compressor == NULL);

    out_stream->write(0x5a);

    PositionEntryWriter index_entry;
    out_stream->get_position(&index_entry);
    out_stream->write(0x5b);
    ASSERT_EQ(index_entry.positions_count(), 2);
    ASSERT_EQ(index_entry.positions(0), 0);
    ASSERT_EQ(index_entry.positions(1), 1);
    out_stream->flush();

    // read data
    std::vector<ByteBuffer*> inputs;
    std::vector<ByteBuffer*>::const_iterator it = out_stream->output_buffers().begin();
    ASSERT_NE(it, out_stream->output_buffers().end());
    ByteBuffer *tmp_byte_buffer = ByteBuffer::reference_buffer(*it, 0, (*it)->capacity());
    inputs.push_back(tmp_byte_buffer);

    std::vector<uint64_t> offsets;
    offsets.assign(inputs.size(), 0);
    InStream *in_stream =
            new (std::nothrow) InStream(&inputs,
                                        offsets,
                                        out_stream->get_stream_length(),
                                        NULL,
                                        out_stream->get_total_buffer_size());
    ASSERT_EQ(in_stream->available(), 2);

    char buffer[256];
    index_entry.write_to_buffer(buffer);
    StreamIndexHeader header;
    header.position_format = index_entry.positions_count();
    header.statistic_format = OLAP_FIELD_TYPE_NONE;
    PositionEntryReader entry;
    entry.init(&header, OLAP_FIELD_TYPE_NONE, false);
    entry.attach(buffer);
    PositionProvider position(&entry);

    ASSERT_EQ(entry.positions_count(), 2);
    ASSERT_EQ(entry.positions(0), 0);
    ASSERT_EQ(entry.positions(1), 1);

    in_stream->seek(&position);
    char data;
    ASSERT_EQ(in_stream->read(&data), OLAP_SUCCESS);
    ASSERT_EQ(data, 0x5b);
    SAFE_DELETE(out_stream);
    SAFE_DELETE(in_stream);
}

TEST(TestStream, SkipUncompress) {
    // write data
    OutStream *out_stream =
            new(std::nothrow) OutStream(OLAP_DEFAULT_COLUMN_STREAM_BUFFER_SIZE, NULL);
    ASSERT_TRUE(out_stream != NULL);
    ASSERT_TRUE(out_stream->_compressor == NULL);

    char write_data[] = {0x5a, 0x5b, 0x5c, 0x5d};
    for (int32_t i = 0; i < sizeof(write_data); i++) {
        out_stream->write(write_data[i]);
    }
    out_stream->write(0x5e);
    out_stream->flush();

    // read data
    std::vector<ByteBuffer*> inputs;
    std::vector<ByteBuffer*>::const_iterator it = out_stream->output_buffers().begin();
    ASSERT_NE(it, out_stream->output_buffers().end());
    ByteBuffer *tmp_byte_buffer = ByteBuffer::reference_buffer(*it, 0, (*it)->capacity());
    inputs.push_back(tmp_byte_buffer);

    std::vector<uint64_t> offsets;
    offsets.assign(inputs.size(), 0);
    InStream *in_stream =
            new (std::nothrow) InStream(&inputs,
                                        offsets,
                                        out_stream->get_stream_length(),
                                        NULL,
                                        out_stream->get_total_buffer_size());
    ASSERT_EQ(in_stream->available(), sizeof(write_data)+1);
    in_stream->skip(sizeof(write_data)-1);
    char data;
    ASSERT_EQ(in_stream->read(&data), OLAP_SUCCESS);
    ASSERT_EQ(data, write_data[sizeof(write_data)-1]);
    SAFE_DELETE(out_stream);
    SAFE_DELETE(in_stream);
}

TEST(TestStream, SeekCompress) {
    // write data
    OutStream *out_stream =
            new(std::nothrow) OutStream(OLAP_DEFAULT_COLUMN_STREAM_BUFFER_SIZE, lzo_compress);
    ASSERT_TRUE(out_stream != NULL);

    for (int32_t i = 0; i < 10; i++) {
        out_stream->write(0x5a);
    }

    PositionEntryWriter index_entry;
    out_stream->get_position(&index_entry);
    out_stream->write(0x5b);
    ASSERT_EQ(index_entry.positions_count(), 2);
    ASSERT_EQ(index_entry.positions(0), 0);
    ASSERT_EQ(index_entry.positions(1), 10);
    out_stream->flush();

    // read data
    std::vector<ByteBuffer*> inputs;
    std::vector<ByteBuffer*>::const_iterator it = out_stream->output_buffers().begin();
    ASSERT_NE(it, out_stream->output_buffers().end());
    ByteBuffer *tmp_byte_buffer = ByteBuffer::reference_buffer(*it, 0, (*it)->capacity());
    inputs.push_back(tmp_byte_buffer);

    std::vector<uint64_t> offsets;
    offsets.assign(inputs.size(), 0);
    InStream *in_stream =
            new (std::nothrow) InStream(&inputs,
                                        offsets,
                                        out_stream->get_stream_length(),
                                        lzo_decompress,
                                        out_stream->get_total_buffer_size());
    //ASSERT_EQ(in_stream->available(), 2);
    char buffer[256];
    index_entry.write_to_buffer(buffer);
    StreamIndexHeader header;
    header.position_format = index_entry.positions_count();
    header.statistic_format = OLAP_FIELD_TYPE_NONE;
    PositionEntryReader entry;
    entry.init(&header, OLAP_FIELD_TYPE_NONE, false);
    entry.attach(buffer);

    PositionProvider position(&entry);
    in_stream->seek(&position);
    char data;
    ASSERT_EQ(in_stream->read(&data), OLAP_SUCCESS);
    ASSERT_EQ(data, 0x5b);
    SAFE_DELETE(out_stream);
    SAFE_DELETE(in_stream);
}

TEST(TestStream, SkipCompress) {
    // write data
    OutStream *out_stream =
            new(std::nothrow) OutStream(OLAP_DEFAULT_COLUMN_STREAM_BUFFER_SIZE, lzo_compress);
    ASSERT_TRUE(out_stream != NULL);

    for (int32_t i = 0; i < 10; i++) {
        out_stream->write(0x5a);
    }
    out_stream->write(0x5e);
    out_stream->flush();

    // read data
    std::vector<ByteBuffer*> inputs;
    std::vector<ByteBuffer*>::const_iterator it = out_stream->output_buffers().begin();
    ASSERT_NE(it, out_stream->output_buffers().end());
    ByteBuffer *tmp_byte_buffer = ByteBuffer::reference_buffer(*it, 0, (*it)->capacity());
    inputs.push_back(tmp_byte_buffer);

    std::vector<uint64_t> offsets;
    offsets.assign(inputs.size(), 0);
    InStream *in_stream =
            new (std::nothrow) InStream(&inputs,
                                        offsets,
                                        out_stream->get_stream_length(),
                                        lzo_decompress,
                                        out_stream->get_total_buffer_size());

    in_stream->skip(10);
    char data;
    ASSERT_EQ(in_stream->read(&data), OLAP_SUCCESS);
    ASSERT_EQ(data, 0x5e);

    SAFE_DELETE(out_stream);
    SAFE_DELETE(in_stream);
}

class TestRunLengthByte : public testing::Test {
public:
    TestRunLengthByte() {
    }

    virtual ~TestRunLengthByte() {
    }

    virtual void SetUp() {
        system("rm tmp_file");
        _out_stream = new (std::nothrow) OutStream(OLAP_DEFAULT_COLUMN_STREAM_BUFFER_SIZE, NULL);
        ASSERT_TRUE(_out_stream != NULL);
        _writer = new (std::nothrow) RunLengthByteWriter(_out_stream);
        ASSERT_TRUE(_writer != NULL);
    }

    virtual void TearDown() {
        SAFE_DELETE(_reader);
        SAFE_DELETE(_out_stream);
        SAFE_DELETE(_writer);
        SAFE_DELETE(_shared_buffer);
        SAFE_DELETE(_stream);
    }

    void CreateReader() {
        ASSERT_EQ(OLAP_SUCCESS, helper.open_with_mode("tmp_file",
                O_CREAT | O_EXCL | O_WRONLY, S_IRUSR | S_IWUSR));
        _out_stream->write_to_file(&helper, 0);
        helper.close();

        ASSERT_EQ(OLAP_SUCCESS, helper.open_with_mode("tmp_file",
                O_RDONLY, S_IRUSR | S_IWUSR));

        _shared_buffer = ByteBuffer::create(
                OLAP_DEFAULT_COLUMN_STREAM_BUFFER_SIZE + sizeof(StreamHead));
        ASSERT_TRUE(_shared_buffer != NULL);

        _stream = new (std::nothrow) ReadOnlyFileStream(
                &helper,
                &_shared_buffer,
                0,
                helper.length(),
                NULL,
                OLAP_DEFAULT_COLUMN_STREAM_BUFFER_SIZE);
        ASSERT_EQ(OLAP_SUCCESS, _stream->init());

        _reader = new (std::nothrow) RunLengthByteReader(_stream);
        ASSERT_TRUE(_reader != NULL);
    }

    RunLengthByteReader* _reader;
    OutStream* _out_stream;
    RunLengthByteWriter* _writer;
    FileHandler helper;
    ByteBuffer* _shared_buffer;
    ReadOnlyFileStream* _stream;
};

TEST_F(TestRunLengthByte, ReadWriteOneByte) {
    _writer->write(0x5a);
    _writer->flush();
    CreateReader();

    ASSERT_TRUE(_reader->has_next());
    char value = 0xff;
    ASSERT_EQ(OLAP_SUCCESS, _reader->next(&value));
    ASSERT_EQ(value, 0X5A);

    ASSERT_FALSE(_reader->has_next());
}

TEST_F(TestRunLengthByte, ReadWriteMultiBytes) {
    // write data
    char write_data[] = {0x5a, 0x5b, 0x5c, 0x5d};
    for (int32_t i = 0; i < sizeof(write_data); i++) {
        _writer->write(write_data[i]);
    }

    _writer->flush();

    // the stream contain head, contral byte and four byte literal
    ASSERT_EQ(_out_stream->get_stream_length(), sizeof(StreamHead) + 1 + 4);

    // read data
    CreateReader();

    for (int32_t i = 0; i < sizeof(write_data); i++) {
        ASSERT_TRUE(_reader->has_next());
        char value = 0xff;
        ASSERT_EQ(OLAP_SUCCESS, _reader->next(&value));
        ASSERT_EQ(value, write_data[i]);
    }

    ASSERT_FALSE(_reader->has_next());
}

TEST_F(TestRunLengthByte, ReadWriteSameBytes) {
    // write data
    char write_data[] = {0x5a, 0x5a, 0x5a, 0x5a};
    for (int32_t i = 0; i < sizeof(write_data); i++) {
        _writer->write(write_data[i]);
    }

    _writer->flush();

    // the stream contain head, contral byte(4-3) and one byte literal
    ASSERT_EQ(_out_stream->get_stream_length(), sizeof(StreamHead) + 1 + 1);

    // read data
    CreateReader();

    for (int32_t i = 0; i < sizeof(write_data); i++) {
        ASSERT_TRUE(_reader->has_next());
        char value = 0xff;
        ASSERT_EQ(OLAP_SUCCESS, _reader->next(&value));
        ASSERT_EQ(value, write_data[i]);
    }

    ASSERT_FALSE(_reader->has_next());
}

TEST_F(TestRunLengthByte, Seek) {
    // write data
    char write_data[] = {0x5a, 0x5b, 0x5c, 0x5d};
    for (int32_t i = 0; i < sizeof(write_data); i++) {
        _writer->write(write_data[i]);
    }

    PositionEntryWriter index_entry;
    _writer->get_position(&index_entry);
    _writer->write(0x5e);

    _writer->write(0x5f);
    _writer->write(0x60);
    _writer->write(0x61);

    _writer->flush();

    // read data
    CreateReader();

    char buffer[256];
    index_entry.write_to_buffer(buffer);
    StreamIndexHeader header;
    header.position_format = index_entry.positions_count();
    header.statistic_format = OLAP_FIELD_TYPE_NONE;
    PositionEntryReader entry;
    entry.init(&header, OLAP_FIELD_TYPE_NONE, false);
    entry.attach(buffer);

    PositionProvider position(&entry);
    _reader->seek(&position);
    char value = 0xff;
    ASSERT_EQ(OLAP_SUCCESS, _reader->next(&value));
    ASSERT_EQ(value, 0x5e);
    ASSERT_EQ(OLAP_SUCCESS, _reader->next(&value));
    ASSERT_EQ(value, 0x5f);
    ASSERT_EQ(OLAP_SUCCESS, _reader->next(&value));
    ASSERT_EQ(value, 0x60);
    ASSERT_EQ(OLAP_SUCCESS, _reader->next(&value));
    ASSERT_EQ(value, 0x61);
}

TEST_F(TestRunLengthByte, Skip) {
    // write data
    char write_data[] = {0x5a, 0x5b, 0x5c, 0x5d};
    for (int32_t i = 0; i < sizeof(write_data); i++) {
        _writer->write(write_data[i]);
    }
    _writer->write(0x5e);
    _writer->flush();

    // read data
    CreateReader();

    _reader->skip(sizeof(write_data) - 1);
    char value = 0xff;
    ASSERT_EQ(OLAP_SUCCESS, _reader->next(&value));
    ASSERT_EQ(value, write_data[sizeof(write_data) - 1]);
    ASSERT_EQ(OLAP_SUCCESS, _reader->next(&value));
    ASSERT_EQ(value, 0x5e);
}

}
}

int main(int argc, char** argv) {
    std::string conffile = std::string(getenv("PALO_HOME")) + "/conf/be.conf";
    if (!palo::config::init(conffile.c_str(), false)) {
        fprintf(stderr, "error read config file. \n");
        return -1;
    }
    palo::init_glog("be-test");
    int ret = palo::OLAP_SUCCESS;
    testing::InitGoogleTest(&argc, argv);
    ret = RUN_ALL_TESTS();
    google::protobuf::ShutdownProtobufLibrary();
    return ret;
}


text:
var WebWorkerTemplatePlugin = require('webpack/lib/webworker/WebWorkerTemplatePlugin');
var SingleEntryPlugin = require('webpack/lib/SingleEntryPlugin');
var path = require('path');

var loaderUtils = require('loader-utils');
module.exports = function() {};
module.exports.pitch = function(request) {
  if (!this.webpack)
    throw new Error('Only usable with webpack');
  var callback = this.async();
  var query = loaderUtils.parseQuery(this.query);
  var outputOptions = {
    filename: '[hash].sharedworker.js',
    chunkFilename: '[id].[hash].sharedworker.js',
    namedChunkFilename: null
  };
  if (this.options && this.options.worker && this.options.worker.output) {
    for (var name in this.options.worker.output) {
      outputOptions[name] = this.options.worker.output[name];
    }
  }
  var workerCompiler = this._compilation.createChildCompiler('sharedworker', outputOptions);
  workerCompiler.apply(new WebWorkerTemplatePlugin(outputOptions));
  workerCompiler.apply(new SingleEntryPlugin(this.context, '!!' + request, 'main'));
  if (this.options && this.options.worker && this.options.worker.plugins) {
    this.options.worker.plugins.forEach(function(plugin) {
      workerCompiler.apply(plugin);
    });
  }
  var subCache = 'subcache ' + __dirname + ' ' + request;
  workerCompiler.plugin('compilation', function(compilation) {
    if (compilation.cache) {
      if (!compilation.cache[subCache])
        compilation.cache[subCache] = {};
      compilation.cache = compilation.cache[subCache];
    }
  });
  workerCompiler.runAsChild(function(err, entries, compilation) {
    if (err) return callback(err);
    if (entries[0]) {
      var workerFile = entries[0].files[0];
      var constructor = 'new SharedWorker(__webpack_public_path__ + ' + JSON.stringify(workerFile) + ', name)';
      if (query.inline) {
        constructor = 'require(' + JSON.stringify('!!' + path.join(__dirname, 'createInlineWorker.js')) + ')(' +
          JSON.stringify(compilation.assets[workerFile].source()) + ', __webpack_public_path__ + ' + JSON.stringify(workerFile) + ', name)';
      }
      return callback(null, 'module.exports = function(name) {\n\treturn ' + constructor + ';\n};');
    } else {
      return callback(null, null);
    }
  });
};

redpajama_set_name: RedPajamaGithub


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 org.deephacks.tools4j.support.conversion;

public class ConversionException extends RuntimeException {
    private static final long serialVersionUID = 3116958531528669531L;

    public ConversionException(String msg) {
        super(msg);
    }

    public ConversionException(Throwable e) {
        super(e);
    }

    public ConversionException(String msg, Exception e) {
        super(msg, e);
    }
}


text:
#include "H5IMcc.h"

#include <string.h>
#include <stdlib.h>

/*-------------------------------------------------------------------------
 * private functions
 *-------------------------------------------------------------------------
 */
herr_t H5IM_get_palette(hid_t loc_id,
                         const char *image_name,
                         int pal_number,
                         hid_t tid,
                         void *pal_data);

/*-------------------------------------------------------------------------
 * Function: H5IMmake_image_8bitf
 *
 * Purpose: Creates and writes an image an 8 bit image
 *
 * Return: Success: 0, Failure: -1
 *
 * Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu
 *
 * Date: May 10, 2005
 *
 * Comments:
 *  This function allows the creation and writing of an 8bit image on disk.
 *  The memory datatype is H5T_NATIVE_INT. It is supposed to be called from
 *  the FORTRAN interface where the image buffer is defined as type "integer"
 *
 * Modifications:
 *
 *-------------------------------------------------------------------------
 */

herr_t H5IMmake_image_8bitf(hid_t loc_id,
                             const char *dset_name,
                             hsize_t width,
                             hsize_t height,
                             int_f *buf)
{
 hid_t    did;                  /* dataset ID */
 hid_t    sid;                  /* space ID */
 hsize_t  dims[IMAGE8_RANK];  /* dimensions */

 /* initialize the image dimensions */
 dims[0] = height;
 dims[1] = width;

/*-------------------------------------------------------------------------
 * create and write the dataset
 *-------------------------------------------------------------------------
 */

 /* create the data space for the dataset. */
 if((sid = H5Screate_simple(IMAGE8_RANK, dims, NULL)) < 0)
  return -1;

 /* create the dataset as H5T_NATIVE_UCHAR */
 if((did = H5Dcreate2(loc_id, dset_name, H5T_NATIVE_UINT8, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
  return -1;

 /* write with memory type H5T_NATIVE_INT */
 /* Use long type if Fortran integer is 8 bytes and C long long is also 8 bytes*/
 /* Fail if otherwise */
 if(buf) {
  if(sizeof(int_f) == sizeof(int)) {
      if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0)
       return -1;
  } else if(sizeof(int_f) == sizeof(long)) {
      if(H5Dwrite(did, H5T_NATIVE_LONG, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0)
       return -1;
  } else if(sizeof(int_f) == sizeof(long long)) {
      if(H5Dwrite(did, H5T_NATIVE_LLONG, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0)
       return -1;
  } else
       return -1;
 }

 /* close */
 if(H5Dclose(did) < 0)
  return -1;
 if(H5Sclose(sid) < 0)
  return -1;

/*-------------------------------------------------------------------------
 * attach the specification attributes
 *-------------------------------------------------------------------------
 */

 /* attach the CLASS attribute */
 if(H5LTset_attribute_string(loc_id, dset_name, "CLASS", IMAGE_CLASS) < 0)
  return -1;

 /* attach the VERSION attribute */
 if(H5LTset_attribute_string(loc_id, dset_name, "IMAGE_VERSION", IMAGE_VERSION) < 0)
  return -1;

 /* attach the IMAGE_SUBCLASS attribute */
 if(H5LTset_attribute_string(loc_id, dset_name, "IMAGE_SUBCLASS", "IMAGE_INDEXED") < 0)
  return -1;

 return 0;
}

/*-------------------------------------------------------------------------
 * Function: H5IMmake_image_24bitf
 *
 * Purpose:
 *
 * Return: Success: 0, Failure: -1
 *
 * Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu
 *
 * Date: May 10, 2005
 *
 * Comments:
 *  This function allows the creation and writing of an 8bit image on disk.
 *  The memory datatype is H5T_NATIVE_INT. It is supposed to be called from
 *  the FORTRAN interface where the image buffer is defined as type "integer"
 *
 * Interlace Mode Dimensions in the Dataspace
 * INTERLACE_PIXEL [height][width][pixel components]
 * INTERLACE_PLANE [pixel components][height][width]
 *
 *
 * Modifications:
 *
 *-------------------------------------------------------------------------
 */

herr_t H5IMmake_image_24bitf(hid_t loc_id,
                              const char *dset_name,
                              hsize_t width,
                              hsize_t height,
                              const char *interlace,
                              int_f *buf)
{
 hid_t    did;                /* dataset ID */
 hid_t    sid;                /* space ID */
 hsize_t  dims[IMAGE24_RANK]; /* dimensions */

/*-------------------------------------------------------------------------
 * attach the image dimensions according to the interlace mode
 *-------------------------------------------------------------------------
 */
 if(strcmp(interlace, "INTERLACE_PIXEL") == 0) {
  /* Number of color planes is defined as the third dimension */
  dims[0] = height;
  dims[1] = width;
  dims[2] = IMAGE24_RANK;
 }
 else
 if(strcmp(interlace, "INTERLACE_PLANE") == 0) {
  /* Number of color planes is defined as the first dimension */
  dims[0] = IMAGE24_RANK;
  dims[1] = height;
  dims[2] = width;
 }
 else
  return -1;

/*-------------------------------------------------------------------------
 * create and write the dataset
 *-------------------------------------------------------------------------
 */

 /* create the data space for the dataset. */
 if((sid = H5Screate_simple(IMAGE24_RANK, dims, NULL)) < 0)
  return -1;

 /* create the dataset as H5T_NATIVE_UCHAR */
 if((did = H5Dcreate2(loc_id, dset_name, H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
  return -1;

 /* write with memory type H5T_NATIVE_INT */
 if(buf) {
  if(sizeof(int_f) == sizeof(int)) {
      if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0)
       return -1;
  } else if(sizeof(int_f) == sizeof(long)) {
      if(H5Dwrite(did, H5T_NATIVE_LONG, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0)
       return -1;
  } else if(sizeof(int_f) == sizeof(long long)) {
      if(H5Dwrite(did, H5T_NATIVE_LLONG, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0)
       return -1;
  } else
   return -1;
 }

 /* close */
 if(H5Dclose(did) < 0)
  return -1;
 if(H5Sclose(sid) < 0)
  return -1;

/*-------------------------------------------------------------------------
 * attach the specification attributes
 *-------------------------------------------------------------------------
 */

 /* Attach the CLASS attribute */
 if(H5LTset_attribute_string(loc_id, dset_name, "CLASS", IMAGE_CLASS) < 0)
  return -1;

 /* Attach the VERSION attribute */
 if(H5LTset_attribute_string(loc_id, dset_name, "IMAGE_VERSION", IMAGE_VERSION) < 0)
  return -1;

 /* Attach the IMAGE_SUBCLASS attribute */
 if(H5LTset_attribute_string(loc_id, dset_name, "IMAGE_SUBCLASS", "IMAGE_TRUECOLOR") < 0)
  return -1;

 /* Attach the INTERLACE_MODE attribute. This attributes is only for true color images */
 if(H5LTset_attribute_string(loc_id, dset_name, "INTERLACE_MODE", interlace) < 0)
  return -1;

 return 0;

}

/*-------------------------------------------------------------------------
 * Function: H5IMread_imagef
 *
 * Purpose: Reads image data from disk.
 *
 * Return: Success: 0, Failure: -1
 *
 * Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu
 *
 * Date: May 10, 2005
 *
 * Comments:
 *  This function allows reading of an 8bit image on disk.
 *  The memory datatype is H5T_NATIVE_INT. It is supposed to be called from
 *  the FORTRAN interface where the image buffer is defined as type "integer"
 *
 * Modifications:
 *
 *-------------------------------------------------------------------------
 */

herr_t H5IMread_imagef(hid_t loc_id,
                        const char *dset_name,
                        int_f *buf)
{
    hid_t   did;
    hid_t   tid;

    /* open the dataset */
    if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0)
        return -1;

    /* determine appropriate datatype to use */
    if(sizeof(int_f) == sizeof(int))
        tid = H5T_NATIVE_INT;
    else if(sizeof(int_f) == sizeof(long))
        tid = H5T_NATIVE_LONG;
    else if(sizeof(int_f) == sizeof(long long))
        tid = H5T_NATIVE_LLONG;
    else
        goto out;

    /* read to memory */
    if(H5Dread(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0)
        goto out;

    /* close */
    if(H5Dclose(did))
        return -1;

    return 0;

out:
    H5Dclose(did);
    return -1;
}

/*-------------------------------------------------------------------------
 * Function: H5IMmake_palettef
 *
 * Purpose: Creates and writes a palette.
 *
 * Return: Success: 0, Failure: -1
 *
 * Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu
 *
 * Date: May 10, 2005
 *
 * Comments:
 *  This function allows writing of an 8bit palette to disk.
 *  The memory datatype is H5T_NATIVE_INT. It is supposed to be called from
 *  the FORTRAN interface where the image buffer is defined as type "integer"
 *
 *  based on HDF5 Image and Palette Specification
 *  http://hdf.ncsa.uiuc.edu/HDF5/H5Image/ImageSpec.html
 *
 * Modifications:
 *
 *-------------------------------------------------------------------------
 */

herr_t H5IMmake_palettef(hid_t loc_id,
                          const char *pal_name,
                          const hsize_t *pal_dims,
                          int_f *pal_data)

{

 hid_t did;                /* dataset ID */
 hid_t sid;                /* space ID */
 int   has_pal;

 /* Check if the dataset already exists */
 has_pal = H5LTfind_dataset(loc_id, pal_name);

 /* It exists. Return */
 if(has_pal == 1)
  return 0;

/*-------------------------------------------------------------------------
 * create and write the dataset
 *-------------------------------------------------------------------------
 */

 /* create the data space for the dataset. */
 if((sid = H5Screate_simple(2, pal_dims, NULL)) < 0)
  return -1;

 /* create the dataset as H5T_NATIVE_UCHAR */
 if((did = H5Dcreate2(loc_id, pal_name, H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
  return -1;

 /* write with memory type H5T_NATIVE_INT */
 if(pal_data) {
  if(sizeof(int_f) == sizeof(int)) {
      if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, pal_data) < 0)
       return -1;
  } else if(sizeof(int_f) == sizeof(long)) {
      if(H5Dwrite(did, H5T_NATIVE_LONG, H5S_ALL, H5S_ALL, H5P_DEFAULT, pal_data) < 0)
       return -1;
  } else if(sizeof(int_f) == sizeof(long long)) {
      if(H5Dwrite(did, H5T_NATIVE_LLONG, H5S_ALL, H5S_ALL, H5P_DEFAULT, pal_data) < 0)
       return -1;
  } else
      return -1;
 }

 /* close */
 if(H5Dclose(did) < 0)
  return -1;
 if(H5Sclose(sid) < 0)
  return -1;

/*-------------------------------------------------------------------------
 * attach the specification attributes
 *-------------------------------------------------------------------------
 */

 /* Attach the attribute "CLASS" to the >>palette<< dataset*/
 if(H5LTset_attribute_string(loc_id, pal_name, "CLASS", PALETTE_CLASS) < 0)
  return -1;

 /* Attach the attribute "PAL_VERSION" to the >>palette<< dataset*/
 if(H5LTset_attribute_string(loc_id, pal_name, "PAL_VERSION", "1.2") < 0)
  return -1;

 return 0;

}

/*-------------------------------------------------------------------------
 * Function: H5IMget_palettef
 *
 * Purpose: Read palette
 *
 * Return: Success: 0, Failure: -1
 *
 * Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu
 *
 * Date: May 10, 2005
 *
 * Comments:
 *  This function allows reading of an 8bit palette from disk.
 *  The memory datatype is H5T_NATIVE_INT. It is supposed to be called from
 *  the FORTRAN interface where the image buffer is defined as type "integer"
 *
 *  based on HDF5 Image and Palette Specification
 *  http://hdf.ncsa.uiuc.edu/HDF5/H5Image/ImageSpec.html
 *
 * Modifications:
 *
 *-------------------------------------------------------------------------
 */

herr_t H5IMget_palettef(hid_t loc_id,
                         const char *image_name,
                         int pal_number,
                         int_f *pal_data)
{
 if(sizeof(int_f) == sizeof(int))
  return H5IM_get_palette(loc_id,image_name,pal_number,H5T_NATIVE_INT,pal_data);
 else if(sizeof(int_f) == sizeof(long))
  return H5IM_get_palette(loc_id,image_name,pal_number,H5T_NATIVE_LONG,pal_data);
 else if(sizeof(int_f) == sizeof(long long))
  return H5IM_get_palette(loc_id,image_name,pal_number,H5T_NATIVE_LLONG,pal_data);
 else
  return -1;

}

/*-------------------------------------------------------------------------
 * Function: H5IM_get_palette
 *
 * Purpose: private function that reads a palette to memory type TID
 *
 * Return: Success: 0, Failure: -1
 *
 * Programmer: Pedro Vicente Nunes, pvn@ncsa.uiuc.edu
 *
 * Date: May 10, 2005
 *
 * Comments:
 *  This function allows reading of an 8bit palette from disk disk
 *   to memory type TID
 *  The memory datatype can be H5T_NATIVE_INT or H5T_NATIVE_UCHAR currently.
 *   the H5T_NATIVE_INT is supposed to be called from
 *   the FORTRAN interface where the image buffer is defined as type "integer"
 *
 * Comments:
 *  based on HDF5 Image and Palette Specification
 *  http://hdf.ncsa.uiuc.edu/HDF5/H5Image/ImageSpec.html
 *
 * Modifications:
 *
 *-------------------------------------------------------------------------
 */
herr_t H5IM_get_palette(hid_t loc_id,
                         const char *image_name,
                         int pal_number,
                         hid_t tid,
                         void *pal_data)
{
 hid_t      image_id;
 int        has_pal;
 hid_t      attr_type;
 hid_t      attr_id;
 hid_t      attr_space_id;
 hid_t      attr_class;
 hssize_t   n_refs;
 size_t    dim_ref;
 hobj_ref_t *refbuf;     /* buffer to read references */
 hid_t      pal_id;

 /* Open the dataset. */
 if((image_id = H5Dopen2(loc_id, image_name, H5P_DEFAULT)) < 0)
  return -1;

 /* Try to find the attribute "PALETTE" on the >>image<< dataset */
 has_pal = H5IM_find_palette(image_id);

 if(has_pal ==  1)
 {

  if((attr_id = H5Aopen(image_id, "PALETTE", H5P_DEFAULT)) < 0)
   goto out;

  if((attr_type = H5Aget_type(attr_id)) < 0)
   goto out;

  if((attr_class = H5Tget_class(attr_type)) < 0)
   goto out;

  /* Check if it is really a reference */
  if(attr_class == H5T_REFERENCE)
  {

   /* Get the reference(s) */
   if((attr_space_id = H5Aget_space(attr_id)) < 0)
    goto out;

   n_refs = H5Sget_simple_extent_npoints(attr_space_id);

   dim_ref = (size_t)n_refs;

   refbuf = (hobj_ref_t *)HDmalloc(sizeof(hobj_ref_t) * dim_ref);

   if(H5Aread(attr_id, attr_type, refbuf) < 0)
    goto out;

   /* Get the palette id */
   if((pal_id = H5Rdereference2(image_id, H5P_DEFAULT, H5R_OBJECT, &refbuf[pal_number])) < 0)
    goto out;

   /* Read the palette dataset using the memory type TID */
   if(H5Dread(pal_id, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, pal_data) < 0)
    goto out;

   if(H5Sclose(attr_space_id) < 0)
    goto out;

   /* close the dereferenced dataset */
   if(H5Dclose(pal_id) < 0)
    goto out;

   HDfree(refbuf);

  } /* H5T_REFERENCE */

  if(H5Tclose(attr_type) < 0)
   goto out;

  /* Close the attribute. */
  if(H5Aclose(attr_id) < 0)
   goto out;

 }

 /* Close the image dataset. */
 if(H5Dclose(image_id) < 0)
  return -1;

 return 0;

out:
 H5Dclose(image_id);
 return -1;

}


text:
package com.a21vianet.wallet.vport.dao.entity;

import com.a21vianet.wallet.vport.dao.bean.OperationStateEnum;
import com.a21vianet.wallet.vport.dao.bean.OperationTypeEnum;
import com.a21vianet.wallet.vport.dao.gen.DaoSession;
import com.a21vianet.wallet.vport.dao.gen.OperatingDataDao;
import com.a21vianet.wallet.vport.dao.gen.OperationTypeDao;

import org.greenrobot.greendao.DaoException;
import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Generated;
import org.greenrobot.greendao.annotation.Id;
import org.greenrobot.greendao.annotation.NotNull;
import org.greenrobot.greendao.annotation.ToOne;
import org.greenrobot.greendao.annotation.Transient;

import java.util.Date;
import java.util.List;

/**
 * Created by wang.rongqiang on 2017/6/27.
 */

@Entity
public class OperatingData {
    @Id(autoincrement = true)
    private Long id;

    private String username;
    private String userimg;
    private String appname;
    private String appimg;
    private String appurl;
    private int operationState;
    private String operationmsg;
    private long operationtypeId;
    private Date operationtime;
    //以 1_2_3 的方式隔开身份证id
    private String identityCards;

    @Transient
    private List<IdentityCard> IdentityCardBeans;

    @ToOne(joinProperty = "operationtypeId")
    private OperationType operationtype;

    /** Used to resolve relations */
    @Generated(hash = 2040040024)
    private transient DaoSession daoSession;

    /** Used for active entity operations. */
    @Generated(hash = 1778719501)
    private transient OperatingDataDao myDao;

    @Generated(hash = 993601222)
    private transient Long operationtype__resolvedKey;

    public OperatingData(String username, String userimg, String appname,
                         String appimg, String appurl, OperationStateEnum stateEnum, String
                                 operationmsg, OperationTypeEnum
                                 anEnum, String identityCards) {
        this.username = username;
        this.userimg = userimg;
        this.appname = appname;
        this.appimg = appimg;
        this.operationState = stateEnum.state;
        this.appurl = appurl;
        this.operationmsg = operationmsg;
        this.operationtypeId = anEnum.typeId;
        this.identityCards = identityCards;
        this.operationtime = new Date();
    }

    @Generated(hash = 681330660)
    public OperatingData(Long id, String username, String userimg, String appname,
            String appimg, String appurl, int operationState, String operationmsg,
            long operationtypeId, Date operationtime, String identityCards) {
        this.id = id;
        this.username = username;
        this.userimg = userimg;
        this.appname = appname;
        this.appimg = appimg;
        this.appurl = appurl;
        this.operationState = operationState;
        this.operationmsg = operationmsg;
        this.operationtypeId = operationtypeId;
        this.operationtime = operationtime;
        this.identityCards = identityCards;
    }

    @Generated(hash = 1127590806)
    public OperatingData() {
    }

    public List<IdentityCard> getIdentityCardBeans() {
        return IdentityCardBeans;
    }

    public void setIdentityCardBeans(List<IdentityCard> identityCardBeans) {
        IdentityCardBeans = identityCardBeans;
    }

    public Long getId() {
        return this.id;
    }

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

    public String getUsername() {
        return this.username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getUserimg() {
        return this.userimg;
    }

    public void setUserimg(String userimg) {
        this.userimg = userimg;
    }

    public String getAppname() {
        return this.appname;
    }

    public void setAppname(String appname) {
        this.appname = appname;
    }

    public String getAppimg() {
        return this.appimg;
    }

    public void setAppimg(String appimg) {
        this.appimg = appimg;
    }

    public String getAppurl() {
        return this.appurl;
    }

    public void setAppurl(String appurl) {
        this.appurl = appurl;
    }

    public int getOperationState() {
        return this.operationState;
    }

    public void setOperationState(int operationState) {
        this.operationState = operationState;
    }

    public String getOperationmsg() {
        return this.operationmsg;
    }

    public void setOperationmsg(String operationmsg) {
        this.operationmsg = operationmsg;
    }

    public long getOperationtypeId() {
        return this.operationtypeId;
    }

    public void setOperationtypeId(long operationtypeId) {
        this.operationtypeId = operationtypeId;
    }

    public Date getOperationtime() {
        return this.operationtime;
    }

    public void setOperationtime(Date operationtime) {
        this.operationtime = operationtime;
    }

    public String getIdentityCards() {
        return this.identityCards;
    }

    public void setIdentityCards(String identityCards) {
        this.identityCards = identityCards;
    }

    /** To-one relationship, resolved on first access. */
    @Generated(hash = 1074589290)
    public OperationType getOperationtype() {
        long __key = this.operationtypeId;
        if (operationtype__resolvedKey == null || !operationtype__resolvedKey.equals(__key)) {
            final DaoSession daoSession = this.daoSession;
            if (daoSession == null) {
                throw new DaoException("Entity is detached from DAO context");
            }
            OperationTypeDao targetDao = daoSession.getOperationTypeDao();
            OperationType operationtypeNew = targetDao.load(__key);
            synchronized (this) {
                operationtype = operationtypeNew;
                operationtype__resolvedKey = __key;
            }
        }
        return operationtype;
    }

    /** called by internal mechanisms, do not call yourself. */
    @Generated(hash = 174810892)
    public void setOperationtype(@NotNull OperationType operationtype) {
        if (operationtype == null) {
            throw new DaoException(
                    "To-one property 'operationtypeId' has not-null constraint; cannot set to-one to null");
        }
        synchronized (this) {
            this.operationtype = operationtype;
            operationtypeId = operationtype.getId();
            operationtype__resolvedKey = operationtypeId;
        }
    }

    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#delete(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 128553479)
    public void delete() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.delete(this);
    }

    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#refresh(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 1942392019)
    public void refresh() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.refresh(this);
    }

    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#update(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 713229351)
    public void update() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.update(this);
    }

    /** called by internal mechanisms, do not call yourself. */
    @Generated(hash = 1421340031)
    public void __setDaoSession(DaoSession daoSession) {
        this.daoSession = daoSession;
        myDao = daoSession != null ? daoSession.getOperatingDataDao() : null;
    }

}


text:
namespace mumble {

X509Certificate X509Certificate::FromRawDERData(const ByteArray &cert, const ByteArray &pkey) {
	X509Certificate tmp;
	tmp.dptr_->cert_der_ = cert;
	tmp.dptr_->priv_der_ = pkey;
	tmp.dptr_->ExtractCertificateInfo();
	return tmp;
}

X509Certificate X509Certificate::GenerateSelfSignedCertificate(const std::string &name, const std::string &email) {
	return X509CertificatePrivate::GenerateSelfSignedCertificate(name, email);
}

std::vector<X509Certificate> X509Certificate::FromPKCS12(const ByteArray &pkcs12, const std::string &password) {
	return X509CertificatePrivate::FromPKCS12(pkcs12, password);
}

ByteArray X509Certificate::ExportCertificateChainAsPKCS12(std::vector<X509Certificate> chain, const std::string &password) {
	return X509CertificatePrivate::ExportCertificateChainAsPKCS12(chain, password);
}

X509Certificate::X509Certificate() : dptr_(new X509CertificatePrivate) {
}

X509Certificate::~X509Certificate() {
}

X509Certificate::X509Certificate(const X509Certificate &cert) : dptr_(new X509CertificatePrivate) {
	dptr_->cert_der_ = cert.dptr_->cert_der_;
	dptr_->priv_der_ = cert.dptr_->priv_der_;
	dptr_->ExtractCertificateInfo();
}

X509Certificate& X509Certificate::operator=(X509Certificate cert) {
	std::swap((*this).dptr_, cert.dptr_);
	return *this;
}

bool X509Certificate::HasCertificate() const {
	return !dptr_->cert_der_.IsNull();
}

bool X509Certificate::HasPrivateKey() const {
	return !dptr_->priv_der_.IsNull();
}

ByteArray X509Certificate::SHA1Digest() const {
	return dptr_->Digest(std::string("sha1"));
}

ByteArray X509Certificate::SHA256Digest() const {
	return dptr_->Digest(std::string("sha256"));
}

std::time_t X509Certificate::NotBeforeTime() const {
	return dptr_->NotBeforeTime();
}

std::time_t X509Certificate::NotAfterTime() const {
	return dptr_->NotAfterTime();
}

bool X509Certificate::IsSignedBy(const X509Certificate &parent) const {
	return dptr_->IsSignedBy(parent);
}

bool X509Certificate::IsValidAtTime(std::time_t time) const {
	return time >= NotBeforeTime() && time <= NotAfterTime();
}

std::string X509Certificate::SubjectName() const {
	return dptr_->SubjectName();
}

std::string X509Certificate::CommonName() const {
	return dptr_->CommonName();
}

std::string X509Certificate::EmailAddress() const {
	return dptr_->EmailAddress();
}

std::vector<std::string> X509Certificate::DNSNames() const {
	return dptr_->DNSNames();
}

std::string X509Certificate::IssuerName() const {
	return dptr_->IssuerName();
}

std::string X509Certificate::LookupIssuerItem(const std::string &item) const{
	return dptr_->LookupIssuerItem(item);
}

std::string X509Certificate::LookupSubjectItem(const std::string &item) const {
	return dptr_->LookupSubjectItem(item);
}

}


text:
<!DOCTYPE html>

    <title>Prints all the numbers from 1 to N</title>
    <link href="styles/js-console.css" rel="stylesheet" />

    <button id="number" onclick="showNumbers()">Show numbers</button>


text:
    <button class="close" type="button" aria-label="close" ng-click="ctrl.cancel()">x</button>

 Eliminar Serie

¿Realmente desea eliminar la serie?

Serie: {{ ctrl.VelocidadSubida }} {{ ctrl.UnidadMedidaSubida }}

    <button class="btn btn-danger btn-sm" type="button" ng-click="ctrl.DeleteVelocidadInternet()" title="Eliminar Vendedor"> Eliminar</button>
    <button class="btn bnt-default btn-sm" type="button" ng-click="ctrl.cancel()" title="Salir"> Cancelar</button>


text:
package com.hazelcast.map.impl.mapstore;

import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.map.MapLoaderLifecycleSupport;
import com.hazelcast.map.MapStore;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.atomic.AtomicInteger;

public class EventBasedMapStore<K, V> implements MapLoaderLifecycleSupport, MapStore<K, V> {

    public enum STORE_EVENTS {
        STORE, STORE_ALL, DELETE, DELETE_ALL, LOAD, LOAD_ALL, LOAD_ALL_KEYS
    }

    public final Map<K, V> store = new ConcurrentHashMap<K, V>();

    public final BlockingQueue<STORE_EVENTS> events = new LinkedBlockingQueue<STORE_EVENTS>();
    public final AtomicInteger storeCount = new AtomicInteger();
    public final AtomicInteger storeAllCount = new AtomicInteger();
    public final AtomicInteger loadCount = new AtomicInteger();
    public final AtomicInteger callCount = new AtomicInteger();
    public final AtomicInteger initCount = new AtomicInteger();
    public HazelcastInstance hazelcastInstance;
    public Properties properties;
    public String mapName;
    public boolean loadAllKeys = true;
    public CountDownLatch storeLatch;
    public CountDownLatch deleteLatch;
    public CountDownLatch loadAllLatch;

    public void init(HazelcastInstance hazelcastInstance, Properties properties, String mapName) {
        this.hazelcastInstance = hazelcastInstance;
        this.properties = properties;
        this.mapName = mapName;
        initCount.incrementAndGet();
    }

    public BlockingQueue getEvents() {
        return events;
    }

    public void destroy() {
    }

    public int getEventCount() {
        return events.size();
    }

    public int getInitCount() {
        return initCount.get();
    }

    public boolean isLoadAllKeys() {
        return loadAllKeys;
    }

    public void setLoadAllKeys(boolean loadAllKeys) {
        this.loadAllKeys = loadAllKeys;
    }

    public HazelcastInstance getHazelcastInstance() {
        return hazelcastInstance;
    }

    public String getMapName() {
        return mapName;
    }

    public Properties getProperties() {
        return properties;
    }

    public Map<K, V> getStore() {
        return store;
    }

    public EventBasedMapStore<K, V> insert(K key, V value) {
        store.put(key, value);
        return this;
    }

    public void store(K key, V value) {
        store.put(key, value);
        callCount.incrementAndGet();
        storeCount.incrementAndGet();
        if (storeLatch != null) {
            storeLatch.countDown();
        }
        events.offer(STORE_EVENTS.STORE);
    }

    public V load(K key) {
        callCount.incrementAndGet();
        loadCount.incrementAndGet();
        events.offer(STORE_EVENTS.LOAD);
        return store.get(key);
    }

    public void storeAll(Map<K, V> map) {
        store.putAll(map);
        callCount.incrementAndGet();
        storeAllCount.incrementAndGet();
        final int size = map.size();
        if (storeLatch != null) {
            for (int i = 0; i < size; i++) {
                storeLatch.countDown();
            }
        }
        events.offer(STORE_EVENTS.STORE_ALL);
    }

    public void delete(K key) {
        store.remove(key);
        callCount.incrementAndGet();
        if (deleteLatch != null) {
            deleteLatch.countDown();
        }
        events.offer(STORE_EVENTS.DELETE);
    }

    public Set<K> loadAllKeys() {
        if (loadAllLatch != null) {
            loadAllLatch.countDown();
        }
        callCount.incrementAndGet();
        events.offer(STORE_EVENTS.LOAD_ALL_KEYS);
        if (!loadAllKeys) {
            return null;
        }
        return store.keySet();
    }

    public Map<K, V> loadAll(Collection<K> keys) {
        Map<K, V> map = new HashMap<K, V>(keys.size());
        for (K key : keys) {
            V value = store.get(key);
            if (value != null) {
                map.put(key, value);
            }
        }
        callCount.incrementAndGet();
        events.offer(STORE_EVENTS.LOAD_ALL);
        return map;
    }

    public void deleteAll(Collection<K> keys) {
        for (K key : keys) {
            store.remove(key);
        }
        callCount.incrementAndGet();

        if (deleteLatch != null) {
            for (int i = 0; i < keys.size(); i++) {
                deleteLatch.countDown();
            }
        }
        events.offer(STORE_EVENTS.DELETE_ALL);
    }
}


text:
package app.com.lsl.imagelabelerapp.lsl.activity;

import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import app.com.lsl.imagelabelerapp.R;
import app.com.lsl.imagelabelerapp.lsl.activity.menu.TopMenuHeader;

/** 显示积分情况
 * Created by M1308_000 on 2017/6/23.
 */

public class MyIntegralActivity extends AppCompatActivity implements View.OnClickListener{

    private TextView tv_integral;
    private Button but_gift;
    private LinearLayout ll_record;
    private View v_line;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_my_integral);
        initMenu();
        initViews();

    }

    private void initViews() {
        tv_integral = (TextView) findViewById(R.id.tv_my_integral);
        but_gift = (Button) findViewById(R.id.but_gift);
        ll_record = (LinearLayout) findViewById(R.id.ll_record);
        v_line = findViewById(R.id.v_line);
        but_gift.setOnClickListener(this);

        Intent intent = getIntent();
        String integral = intent.getStringExtra("integral");
        tv_integral.setText(integral);
        if (integral.equals("0")) {
            ll_record.setVisibility(View.GONE);
            v_line.setVisibility(View.GONE);
        }
    }

    private void initMenu() {
        TopMenuHeader topMenu = new TopMenuHeader(getWindow().getDecorView());
        topMenu.topMenuTitle.setText("我的积分");
        topMenu.topMenuTitle.setTextSize(20);
        topMenu.topMenuTitle.setTextColor(Color.parseColor("#33CCB6"));
        topMenu.topMenuLeft.setText("返回");
        topMenu.topMenuLeft.setTextColor(Color.parseColor("#33CCB6"));
        topMenu.topMenuRight.setVisibility(View.GONE);
        topMenu.topMenuLeft.setOnClickListener(this);
        topMenu.ivTopMenuLeft.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.top_menu_left:
                finish();
                break;
            case R.id.iv_icon:
                finish();
                break;
            case R.id.but_gift:
                Toast.makeText(MyIntegralActivity.this, "暂不支持兑换", Toast.LENGTH_SHORT).show();
                break;
        }
    }
}


text:
.. _getting-started:

Getting Started
===============

*Getting Started* will guide you through creating your first achievements an introducing you to
the pieces of the system. From there, visit the :doc:`reference` for in-depth information.

Installing Pychievements
------------------------

Pychievements can be installed with ``pip``:
 ::

    $ pip install pychievements

.. note:
    There are no required dependencies for pychievements. If you would like to the ``cli`` tools,
    then then you will have to install the *clint* library. You can use pip to install the
    optional ``cli`` dependencies like so: ``pip install pychievements[cli]``

Introduction to Pychievments
----------------------------

Pychievements has a number of modules that you'll need to be at least familiar with:

    tracker
        The default achievement tracker for pychievements is instantiated at import and is used to
        track all registered achievements for specific *tracked_ids*.

    Achievement
        Base Achievment class.

    icons.Icon
        Base Icon class. Icons are used to know what to display for a given goal within an
        achievement and have two states, achieved and unachieved.

    backends.AchievementBackend
        Pychievements have pluggable backends for storing tracked achievement data. The default
        ``AchievementBackend`` simply keeps everyting in memory, meaning it will be lost when the
        application is closed. The backend the tracker is using can be updated with the
        ``set_backend`` method.

    signals
        You can register functions as callbacks that can *recieve* Pychievement signals. Signals can
        be generated when a level is changed, when a new goal is reached, or when all goals have
        been achieved for a given achievement.

Achievements
^^^^^^^^^^^^

At the core of Pychievements is the ``Achievement`` class. It is used to define goals that are
obtained at specified *levels*. Levels are simply an integer. At a minimum, achievements must have
the following attributes defined:

* name : Display name of your achievement
* category : Defaults to "achievements"
* goals : A tuple of *goals*. A *goal* is a dictionary with the following keys: *["level", "name",
  "icon", "description"]*

An example Achievement class: ::

    class MyAchievement(Achievement):
        name = "My Achievement"
        category = "achievements"
        keywords = ("my", "achievement")
        goals = (
            {"level": 10, "name": "Level 1", "icon": icons.star, "description": "Level One" },
            {"level": 20, "name": "Level 2", "icon": icons.star, "description": "Level Two" },
            {"level": 30, "name": "Level 3", "icon": icons.star, "description": "Level Three" },
        )

An achievements current level for an id can tracked with either the ``increment`` or ``evaluate``
functions, which the achievment can override to provide custom level manipulation.

The Tracker
^^^^^^^^^^^

A singleton ``tracker`` is created on import that is available as ``pychievements.tracker``. The
tracker provides an interface for interacting with registered achievements for a given
``tracked_id``. The tracker lets you:

* increment level of an achievement for a tracked_id
* evaluate level of an achievement for a tracked_id
* query all achievements by category or keywords
* query all achieved goals of an achievement for a tracked_id
* query all unachieved goals of an achievement for a tracked_id
* query the current goal being worked towards of an achievement for a tracked_id

The tracker works with the configured backend to store and retrieve all of the tracked levels.

Icons
^^^^^

Icons are simple classes that provide the "icon" (or what is displayed) for an achievment goal. It
must define what to display for when the goal has been achieved (``achieved``) or not
(``unachieved``)

Examples
--------

The easiest way to get started to check out the examples in the `examples`_ folder in the
`the repository`_. Then check out the :doc:`reference` for more information.

.. _examples: https://github.com/PacketPerception/pychievements/tree/master/examples
.. _`the repository`: https://github.com/PacketPerception/pychievements


text:
from __future__ import division
from os import path
from deap import creator, base
from deap.tools.emo import sortNondominated
import glob
import sys
import pdb

sys.dont_write_btyecode = True

"""
get the optimal in objectives among all repetitions and runnings.
"""

PROJECT_PATH, _ = [i for i in sys.path if i.endswith('SPL')][0], \
                  sys.path.append(path.dirname(path.dirname(path.abspath(__file__))))

folders = [PROJECT_PATH+'/j_res',
           '/Users/jianfeng/Desktop/hpc_jres',
           '/Users/jianfeng/Desktop/j_res_sat',
           PROJECT_PATH+'/j_res/seeding']

def _get_frontier(pop):
    """
    return the pareto frontier of the given pop. No duplicate individuals in the returns
    :param pop:
    :return:
    """
    front = sortNondominated(pop, len(pop), True)[0]
    uniques = []
    for f in front:
        if f.fitness.values not in uniques:
            uniques.append(f.fitness.values)
    return uniques

def print_out_optimals(model_name):
    files = []
    for fd in folders:
        files.extend(glob.glob(fd + '/*.txt'))
    files = filter(lambda f: model_name in f, files)

    valid_objs = set()
    for records in files:
        with open(records, 'r') as f:
            lines = f.readlines()
            lines = map(lambda x: x.rstrip(), lines)
            start = lines.index("~~~")
            fits = lines[start + 1:-2]
            for fit in fits:
                if fit.startswith('0.0'):
                    valid_objs.add(fit)

    valid_objs = map(lambda x: map(float, x.split(' ')), valid_objs)

    creator.create("FitnessMin", base.Fitness, weights=[-1.0] * 5)
    creator.create("Individual", list, fitness=creator.FitnessMin)

    pop = list()
    for i in valid_objs:
        ind = creator.Individual([])
        ind.fitness = creator.FitnessMin(i)
        pop.append(ind)
    frontier = _get_frontier(pop)

    with open(PROJECT_PATH+'/optimal_in_his/'+model_name+'.txt', 'w') as f:
        f.write('~~~\n')
        for fer in frontier:
            f.write(' '.join(map(str, fer)))
            f.write('\n')
try:
    model = sys.argv[1]
except:
    model = 'linux'
print_out_optimals(model)


text:
package nl.ctrlaltdev.json.transform.java.pojo;

import nl.ctrlaltdev.json.transform.java.DocumentToJavaMapper;
import nl.ctrlaltdev.json.transform.java.pojo.deserializers.DefaultDeserializer;
import nl.ctrlaltdev.json.transform.java.pojo.deserializers.Deserializer;

public class PojoFromDocumentMapper implements DocumentToJavaMapper, FromDocumentMapper {

    public static class NoDeserializerFoundException extends RuntimeException {
        public NoDeserializerFoundException(Class<?> type) {
            super(type.getName());
        }
    }

    private final Deserializer[] deserializers;

    public PojoFromDocumentMapper() {
        this(new DefaultDeserializer());
    }

    public PojoFromDocumentMapper(boolean strict) {
        this(new DefaultDeserializer(strict));
    }

    public PojoFromDocumentMapper(Deserializer... deserializers) {
        this.deserializers = deserializers;
    }

    @SuppressWarnings("unchecked")
    @Override
    public <A> A toJava(Class<A> type, Object document) {
        return (A) this.toJava(type, null, document);
    }

    @Override
    public Object toJava(Class<?> type, Class<?> genericType, Object document) {
        for (Deserializer d : deserializers) {
            if (d.supports(type)) {
                return d.toObject(this, type, genericType, document);
            }
        }
        throw new NoDeserializerFoundException(type);
    }

}


text:
ManagementBS::ManagementBS()
{

	for( int bsIdx=0; bsIdx<BSTypes_CNT; bsIdx++ ) {
		m_blendStates[bsIdx] = NULL;
	}
}
ManagementBS::~ManagementBS()
{

	for( int bsIdx=0; bsIdx<BSTypes_CNT; bsIdx++ ) {
		SAFE_RELEASE( m_blendStates[bsIdx] );
	}
}

void ManagementBS::setBlendState(ID3D11DeviceContext* p_devcon, BSTypes p_type)
{
	FLOAT blendFactor[4] = {0.0f, 0.0f, 0.0f, 0.0f};
	UINT  sampleMask	 = 0xffffffff;

	p_devcon->OMSetBlendState( m_blendStates[p_type], blendFactor, sampleMask );
}

HRESULT ManagementBS::init(ID3D11Device* p_device)
{
	HRESULT hr = S_OK;

	hr = initBSDefault(p_device);
	if(SUCCEEDED(hr))
		hr = initBSTransparency(p_device);

	if(SUCCEEDED(hr))
		hr = initBSAdditive(p_device);

	return hr;
}
HRESULT ManagementBS::initBSDefault(ID3D11Device* p_device)
{
	HRESULT hr = S_OK;

	D3D11_BLEND_DESC blendDesc;
	ZeroMemory(&blendDesc, sizeof(blendDesc));

	blendDesc.RenderTarget[0].BlendEnable = FALSE;
	blendDesc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL;

	hr = p_device->CreateBlendState(&blendDesc, &m_blendStates[BSTypes_DEFAULT]);

	if(FAILED(hr))
		MessageBox(NULL, L"ManagmenetBS::initBSDefault() | CreateBlendState() | Failed", L"Blend State Default", MB_OK | MB_ICONEXCLAMATION);

	return hr;
}
HRESULT ManagementBS::initBSTransparency(ID3D11Device* p_device)
{
	HRESULT hr = S_OK;

	D3D11_BLEND_DESC blendDesc;
	ZeroMemory(&blendDesc, sizeof(blendDesc));

	blendDesc.RenderTarget[0].BlendEnable			= true;
	blendDesc.RenderTarget[0].SrcBlend				= D3D11_BLEND_SRC_ALPHA;
	blendDesc.RenderTarget[0].DestBlend				= D3D11_BLEND_INV_SRC_ALPHA;
	blendDesc.RenderTarget[0].BlendOp				= D3D11_BLEND_OP_ADD;
	blendDesc.RenderTarget[0].SrcBlendAlpha			= D3D11_BLEND_ONE;
	blendDesc.RenderTarget[0].DestBlendAlpha		= D3D11_BLEND_ZERO;
	blendDesc.RenderTarget[0].BlendOpAlpha			= D3D11_BLEND_OP_ADD;
	blendDesc.RenderTarget[0].RenderTargetWriteMask = 0x0f;

	hr = p_device->CreateBlendState(&blendDesc, &m_blendStates[BSTypes_TRANSPARENCY]);

	if(FAILED(hr))
		MessageBox(NULL, L"ManagmenetBS::initBSTransparency() | CreateBlendState() | Failed", L"Blend State Transparency", MB_OK | MB_ICONEXCLAMATION);

	return hr;
}

HRESULT ManagementBS::initBSAdditive(ID3D11Device* p_device)
{
	HRESULT hr = S_OK;

	D3D11_BLEND_DESC blendDesc;
	ZeroMemory(&blendDesc, sizeof(blendDesc));

	blendDesc.RenderTarget[0].BlendEnable			= true;
	blendDesc.RenderTarget[0].SrcBlend				= D3D11_BLEND_SRC_ALPHA;
	blendDesc.RenderTarget[0].DestBlend				= D3D11_BLEND_ONE;
	blendDesc.RenderTarget[0].BlendOp				= D3D11_BLEND_OP_ADD;

	blendDesc.RenderTarget[0].SrcBlendAlpha			= D3D11_BLEND_SRC_ALPHA;
	blendDesc.RenderTarget[0].DestBlendAlpha		= D3D11_BLEND_ONE;
	blendDesc.RenderTarget[0].BlendOpAlpha			= D3D11_BLEND_OP_ADD;
	blendDesc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL;

	hr = p_device->CreateBlendState(&blendDesc, &m_blendStates[BSTypes_ADDITIVE]);

	if(FAILED(hr))
		MessageBox(NULL, L"ManagmenetBS::initBSAdditive() | CreateBlendState() | Failed", L"Blend State Additive", MB_OK | MB_ICONEXCLAMATION);

	return hr;
}


text:
import { css, cx } from '@emotion/css';
import * as React from 'react';
import { isDnDComponent } from '../../Editor/Components/Page/ComponentPalette';
import { pageCTX } from '../../Editor/Components/Page/PageEditor';
import { isPageComponentNode } from '../../Editor/Components/Page/PagesLayout';
import { classNameOrEmpty } from '../../Helper/className';
import { wwarn } from '../../Helper/wegaslog';
import {
  OnVariableChange,
  useOnVariableChange,
} from '../PageComponents/Inputs/tools';
import {
  sanitizeExtraAttributes,
  WegasComponentItemProps,
  WegasComponentProps,
} from '../PageComponents/tools/EditableComponent';
import { schemaProps } from '../PageComponents/tools/schemaProps';

const absoluteLayoutDefaultStyle = css({
  width: '100%',
  height: '100%',
});

const highlightBorders = css({
  borderStyle: 'solid',
  borderWidth: '2px',
});

export interface AbsoluteLayoutProps extends WegasComponentProps {
  onAbsoluteClick?: OnVariableChange;
}

type AbsoluteClickFn = (coord: { x: number; y: number }) => void;

export function AbsoluteLayout({
  className,
  style,
  children,
  path,
  id,
  onAbsoluteClick,
  context,
}: AbsoluteLayoutProps) {
  const container = React.useRef<HTMLDivElement>(null);
  const [isOverCurrent, setIsOverCurrent] = React.useState(false);

  const { onDrop } = React.useContext(pageCTX);

  const { handleOnChange } = useOnVariableChange(onAbsoluteClick, context);

  const absClickRef = React.useRef<AbsoluteClickFn | undefined>(undefined);
  absClickRef.current = handleOnChange;

  const cb = React.useCallback((event: React.MouseEvent) => {
    if (absClickRef.current != null && container.current != null) {
      const bbox = container.current.getBoundingClientRect();
      absClickRef.current({
        x: event.clientX - bbox.left,
        y: event.clientY - bbox.top,
      });
    }
  }, []);

  const absClickCb = React.useMemo(() => {
    if (handleOnChange != null) {
      return cb;
    } else {
      return undefined;
    }
  }, [handleOnChange, cb]);

  return (
    <div
      ref={container}
      id={id}
      onClick={absClickCb}
      className={
        classNameOrEmpty(className) +
        cx({ [highlightBorders]: isOverCurrent }, absoluteLayoutDefaultStyle)
      }
      style={style}
      onDragOver={e => {
        e.stopPropagation();
        e.preventDefault();
        setIsOverCurrent(true);
      }}
      onDragLeave={_e => {
        setIsOverCurrent(false);
      }}
      onDrop={e => {
        e.preventDefault();
        e.stopPropagation();
        let fromData;
        try {
          fromData = JSON.parse(e.dataTransfer.getData('data'));
        } catch (_e) {
          fromData = undefined;
        }

        if (
          fromData != null &&
          (isDnDComponent(fromData) || isPageComponentNode(fromData))
        ) {
          if (container.current) {
            // Get the bounding rectangle of target
            const rect = e.currentTarget.getBoundingClientRect();

            // Mouse position
            const x = e.clientX - rect.left;
            const y = e.clientY - rect.top;

            onDrop(fromData, path, undefined, {
              position: { left: x, top: y },
            });
          }
        } else {
          wwarn('Unmanaged component dropped');
        }
      }}
    >
      {children}
    </div>
  );
}

export interface AbsoluteItemLayoutProps {
  position?: {
    left?: string;
    right?: string;
    top?: string;
    bottom?: string;
  };
  size?: {
    width?: string;
    height?: string;
  };
}

export const defaultAbsoluteLayoutProps: AbsoluteItemLayoutProps = {
  position: undefined,
  size: undefined,
};
export const defaultAbsoluteLayoutPropsKeys = Object.keys(
  defaultAbsoluteLayoutProps,
) as (keyof AbsoluteItemLayoutProps)[];

type AbsoluteItemProps = React.PropsWithChildren<
  WegasComponentItemProps & AbsoluteItemLayoutProps
>;

export const AbsoluteItem = React.forwardRef<HTMLDivElement, AbsoluteItemProps>(
  (
    {
      tooltip,
      style,
      className,
      onClick,
      onMouseOver,
      onMouseLeave,
      onDragEnter,
      onDragLeave,
      onDragEnd,
      children,
      extraAttributes,
      ...layout
    },
    ref,
  ) => {
    const { position = {}, size = {} } = layout || {};
    return (
      <div
        ref={ref}
        style={{ position: 'absolute', ...position, ...size, ...style }}
        title={tooltip}
        onClick={onClick}
        onMouseOver={onMouseOver}
        onMouseLeave={onMouseLeave}
        onDragEnter={onDragEnter}
        onDragLeave={onDragLeave}
        onDragEnd={onDragEnd}
        className={className}
        {...sanitizeExtraAttributes(extraAttributes)}
      >
        {children}
      </div>
    );
  },
);

export const absolutelayoutChoices: HashListChoices = [
  {
    label: 'Position',
    value: { prop: 'position' },
    items: [
      {
        label: 'Left',
        value: { prop: 'left', schema: schemaProps.number({ label: 'Left' }) },
      },
      {
        label: 'Right',
        value: {
          prop: 'right',
          schema: schemaProps.number({ label: 'Right' }),
        },
      },
      {
        label: 'Top',
        value: { prop: 'top', schema: schemaProps.number({ label: 'Top' }) },
      },
      {
        label: 'Bottom',
        value: {
          prop: 'bottom',
          schema: schemaProps.number({ label: 'Bottom' }),
        },
      },
      {
        label: 'Foreground index',
        value: {
          prop: 'zIndex',
          schema: schemaProps.number({ label: 'Foreground index' }),
        },
      },
    ],
  },
  {
    label: 'Size',
    value: { prop: 'size' },
    items: [
      {
        label: 'Width',
        value: {
          prop: 'width',
          schema: schemaProps.number({ label: 'Width' }),
        },
      },
      {
        label: 'Height',
        value: {
          prop: 'height',
          schema: schemaProps.number({ label: 'Height' }),
        },
      },
    ],
  },
];


text:
//
//  GB2ShapeCache.h
//
//  Loads physics sprites created with http://www.PhysicsEditor.de
//
//  Generic Shape Cache for box2d
//
//  Copyright by Andreas Loew
//      http://www.PhysicsEditor.de
//      http://texturepacker.com
//      http://www.code-and-web.de
//
//  All rights reserved.
//
//  Permission is hereby granted, free of charge, to any person obtaining a copy
//  of this software and associated documentation files (the "Software"), to deal
//  in the Software without restriction, including without limitation the rights
//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
//  copies of the Software, and to permit persons to whom the Software is
//  furnished to do so, subject to the following conditions:
//
//  The above copyright notice and this permission notice shall be included in
//  all copies or substantial portions of the Software.
//
//  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
//  THE SOFTWARE.
//

#import <Foundation/Foundation.h>
#import "Box2D.h"

/**
 * Shape cache
 * This class holds the shapes and makes them accessible
 * The format can be used on any MacOS/iOS system
 */
@interface GB2ShapeCache : NSObject
{
    NSMutableDictionary *shapeObjects_;
    float ptmRatio_;
}

+ (GB2ShapeCache *)sharedShapeCache;

/**
 * Adds shapes to the shape cache
 * @param plist name of the plist file to load
 */
-(void) addShapesWithFile:(NSString*)plist;

/**
 * Adds fixture data to a body
 * @param body body to add the fixture to
 * @param shape name of the shape
 */
-(void) addFixturesToBody:(b2Body*)body forShapeName:(NSString*)shape;

/**
 * Returns the anchor point of the given sprite
 * @param shape name of the shape to get the anchorpoint for
 * @return anchorpoint
 */
-(CGPoint) anchorPointForShape:(NSString*)shape;

/**
 * Returns the ptm ratio
 */
-(float) ptmRatio;

@end


text:
ACCEPTED

#### According to
Index Fungorum

#### Published in
null

#### Original name
Hysterium lineare var. corticola Fr.

### Remarks
null


text:
/**
 * Loads the library.  Chooses compiled or debug version of the library based
 * on the presence or absence of the URL parameter "compiled".
 *
 * This dynamic loading process is not necessary in a production environment,
 * but greatly simplifies the process of switching between compiled and
 * uncompiled mode during development.
 *
 * This is used in the provided test app, but can also be used to load the
 * uncompiled version of the library into your own application environment.
 */
(function() {  // anonymous namespace
  // The sources may be in a different folder from the test app.
  // Compute the base URL for all library sources.
  var currentScript = document.currentScript ||
                      document.scripts[document.scripts.length - 1];
  var loaderSrc = currentScript.src;
  var baseUrl = loaderSrc.split('/').slice(0, -1).join('/') + '/';

  function loadScript(src) {
    // This does not seem like it would be the best way to do this, but the
    // timing is different than creating a new script element and appending
    // it to the head element.  This way, all script loading happens before
    // DOMContentLoaded.  This is also compatible with goog.require's loading
    // mechanism, whereas appending an element to head isn't.
    document.write('<script src="' + baseUrl + src + '"></script>');
  }

  var fields = location.search.split('?').slice(1).join('?');
  fields = fields ? fields.split(';') : [];

  var compiledMode = (fields.indexOf('compiled') >= 0);

  if (compiledMode) {
    // This contains the entire library, compiled in debug mode.
    loadScript('shaka-player.compiled.debug.js');
  } else {
    // In non-compiled mode, loading the closure library is enough to bootstrap
    // the system.  goog.require will load additional dependencies at runtime.
    loadScript('third_party/closure/goog/base.js');
    // This file contains goog.require calls for all exported classes.
    loadScript('shaka-player.uncompiled.js');
  }
})();  // anonymous namespace


text:
<?php

namespace App\Providers;

use Dingo\Api\Facade\API;
use Illuminate\Auth\Access\AuthorizationException;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Support\ServiceProvider;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;

class DingoServiceProvider extends ServiceProvider
{
    public function boot()
    {
        API::error(function (ModelNotFoundException $e) {
            throw new NotFoundHttpException(null, $e);
        });

        API::error(function (AuthorizationException $e) {
            throw new AccessDeniedHttpException($e->getMessage(), $e);
        });
    }

    public function register()
    {
    }
}


text:
#import "FirebaseAuthVersion.h"

// Convert the macro to a string
#define STR(x) STR_EXPAND(x)
#define STR_EXPAND(x) #x

const double FirebaseAuthVersionNum = FIRAuth_MINOR_VERSION;

const unsigned char *const FirebaseAuthVersionStr =
    (const unsigned char *const)STR(FIRAuth_VERSION);


text:
<?xml version="1.0"?>
<Document>

	<Sentence>
		<value>All content below is taken in its entirety from the CDC Serogroup B Meningococcal Vaccine Information Statement (VIS): www.cdc.gov/vaccines/hcp/vis/vis-statements/mening-serogroup.html  CDC review information for Serogroup B Meningococcal Vaccine (MenB):  - Page last reviewed: August 14, 2015  - Page last updated: August 14, 2015  - Issue date of VIS: August 14, 2015    Content source: National Center for Immunization and Respiratory Diseases</value>
		<pattern_crowdsource> All content below is taken in its entirety from the CDC Serogroup B Meningococcal Vaccine Information Statement (VIS): www.cdc.gov/vaccines/hcp/vis/vis-statements/mening-serogroup.html  CDC review information for Serogroup B [[Meningococcal Vaccine|C0700144]] (MenB):  - Page last reviewed: August 14, 2015  - Page last updated: August 14, 2015  - Issue date of VIS: August 14, 2015    Content source: National Center for [[Immunization|C0496628]] and [[Respiratory Diseases|C0035204]]		</pattern_crowdsource>
		<annotations>
			<annotation>
				<surface-form>below</surface-form>
				<RDF-ID>C0542339</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>entirety</surface-form>
				<RDF-ID>C0439751</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>CDC</surface-form>
				<RDF-ID>C0007670</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>Serogroup</surface-form>
				<RDF-ID>C0449543</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>Meningococcal</surface-form>
				<RDF-ID>C0521018</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>Vaccine Information Statement</surface-form>
				<RDF-ID>C1441316</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>www</surface-form>
				<RDF-ID>C0282111</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>cdc</surface-form>
				<RDF-ID>C0007670</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>gov</surface-form>
				<RDF-ID></RDF-ID>
			</annotation>
			<annotation>
				<surface-form>hcp</surface-form>
				<RDF-ID>C1335283</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>mening</surface-form>
				<RDF-ID>C1235735</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>serogroup</surface-form>
				<RDF-ID>C0449543</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>vaccines/hcp/vis/vis-statements/mening-serogroup.html  CDC review information</surface-form>
				<RDF-ID>C1546482</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>Serogroup</surface-form>
				<RDF-ID>C0449543</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>Meningococcal Vaccine</surface-form>
				<RDF-ID>C0700144</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>Page</surface-form>
				<RDF-ID>C0013862</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>last</surface-form>
				<RDF-ID>C1517741</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>Page</surface-form>
				<RDF-ID>C0013862</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>last</surface-form>
				<RDF-ID>C1517741</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>VIS</surface-form>
				<RDF-ID>C1441316</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>National</surface-form>
				<RDF-ID>C0015737</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>Center</surface-form>
				<RDF-ID>C0205099</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>Immunization</surface-form>
				<RDF-ID>C0496628</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>Respiratory Diseases</surface-form>
				<RDF-ID>C0035204</RDF-ID>
			</annotation>
		</annotations>
		<triples>
			<triple>C0700144 TREATS C0496628</triple>
			<triple>C0700144 TREATS C0035204</triple>
		</triples>
	</Sentence>

</Document>


text:
<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    tools:context="schstat.helpinghands.com.schoolstatsinindia.building">
    <item android:id="@+id/action_settings" android:title="@string/action_settings"
        android:orderInCategory="100" app:showAsAction="never" />
</menu>