text:
SELECT
  listing_changes_mview.id,
  event_id,
  taxon_concept_id,
  original_taxon_concept_id,
  CASE
    WHEN listing_changes_mview.change_type_name = 'DELETION'
      OR listing_changes_mview.change_type_name = 'RESERVATION_WITHDRAWAL'
    THEN FALSE
    ELSE listing_changes_mview.is_current
  END AS is_current,
  listing_changes_mview.effective_at::DATE,
  listing_changes_mview.species_listing_name,
  listing_changes_mview.change_type_name,
  CASE
    WHEN listing_changes_mview.change_type_name = 'ADDITION' THEN '+'
    WHEN listing_changes_mview.change_type_name = 'DELETION' THEN '-'
    WHEN listing_changes_mview.change_type_name = 'RESERVATION' THEN 'R+'
    WHEN listing_changes_mview.change_type_name = 'RESERVATION_WITHDRAWAL' THEN 'R-'
    ELSE ''
  END AS change_type,
  listing_changes_mview.inclusion_taxon_concept_id,
  listing_changes_mview.party_id,
  CASE
    WHEN party_id IS NULL THEN NULL::JSON
    ELSE
      ROW_TO_JSON(
        ROW(
          party_iso_code,
          party_full_name_en,
          geo_entity_type
        )::api_geo_entity
      )
  END AS party_en,
  CASE
    WHEN party_id IS NULL THEN NULL::JSON
    ELSE
      ROW_TO_JSON(
        ROW(
          party_iso_code,
          party_full_name_es,
          geo_entity_type
        )::api_geo_entity
      )
  END AS party_es,
  CASE
    WHEN party_id IS NULL THEN NULL::JSON
    ELSE
      ROW_TO_JSON(
        ROW(
          party_iso_code,
          party_full_name_fr,
          geo_entity_type
        )::api_geo_entity
      )
  END AS party_fr,
  CASE
    WHEN listing_changes_mview.auto_note_en IS NULL
      AND listing_changes_mview.inherited_full_note_en IS NULL
      AND listing_changes_mview.inherited_short_note_en IS NULL
      AND listing_changes_mview.full_note_en IS NULL
      AND listing_changes_mview.short_note_en IS NULL
      AND listing_changes_mview.nomenclature_note_en IS NULL
    THEN NULL
    ELSE
      CASE
        WHEN LENGTH(listing_changes_mview.auto_note_en) > 0 THEN '[' || listing_changes_mview.auto_note_en || '] '
        ELSE ''
      END
      || CASE
        WHEN LENGTH(listing_changes_mview.inherited_full_note_en) > 0 THEN strip_tags(listing_changes_mview.inherited_full_note_en)
        WHEN LENGTH(listing_changes_mview.inherited_short_note_en) > 0 THEN strip_tags(listing_changes_mview.inherited_short_note_en)
        WHEN LENGTH(listing_changes_mview.full_note_en) > 0 THEN strip_tags(listing_changes_mview.full_note_en)
        WHEN LENGTH(listing_changes_mview.short_note_en) > 0 THEN strip_tags(listing_changes_mview.short_note_en)
        ELSE ''
      END
      || CASE
        WHEN LENGTH(listing_changes_mview.nomenclature_note_en) > 0 THEN strip_tags(listing_changes_mview.nomenclature_note_en)
        ELSE ''
      END
  END AS annotation_en,
  CASE
    WHEN listing_changes_mview.auto_note_es IS NULL
      AND listing_changes_mview.inherited_full_note_es IS NULL
      AND listing_changes_mview.inherited_short_note_es IS NULL
      AND listing_changes_mview.full_note_es IS NULL
      AND listing_changes_mview.short_note_es IS NULL
      AND listing_changes_mview.nomenclature_note_es IS NULL
    THEN NULL
    ELSE
      CASE
        WHEN LENGTH(listing_changes_mview.auto_note_es) > 0 THEN '[' || listing_changes_mview.auto_note_es || '] '
        ELSE ''
      END
      || CASE
        WHEN LENGTH(listing_changes_mview.inherited_full_note_es) > 0 THEN strip_tags(listing_changes_mview.inherited_full_note_es)
        WHEN LENGTH(listing_changes_mview.inherited_short_note_es) > 0 THEN strip_tags(listing_changes_mview.inherited_short_note_es)
        WHEN LENGTH(listing_changes_mview.full_note_es) > 0 THEN strip_tags(listing_changes_mview.full_note_es)
        WHEN LENGTH(listing_changes_mview.short_note_es) > 0 THEN strip_tags(listing_changes_mview.short_note_es)
        ELSE ''
      END
      || CASE
        WHEN LENGTH(listing_changes_mview.nomenclature_note_en) > 0 THEN strip_tags(listing_changes_mview.nomenclature_note_en)
        ELSE ''
      END
  END AS annotation_es,
  CASE
    WHEN listing_changes_mview.auto_note_fr IS NULL
      AND listing_changes_mview.inherited_full_note_fr IS NULL
      AND listing_changes_mview.inherited_short_note_fr IS NULL
      AND listing_changes_mview.full_note_fr IS NULL
      AND listing_changes_mview.short_note_fr IS NULL
      AND listing_changes_mview.nomenclature_note_fr IS NULL
    THEN NULL
    ELSE
      CASE
        WHEN LENGTH(listing_changes_mview.auto_note_fr) > 0 THEN '[' || listing_changes_mview.auto_note_fr || '] '
        ELSE ''
      END
      || CASE
        WHEN LENGTH(listing_changes_mview.inherited_full_note_fr) > 0 THEN strip_tags(listing_changes_mview.inherited_full_note_fr)
        WHEN LENGTH(listing_changes_mview.inherited_short_note_fr) > 0 THEN strip_tags(listing_changes_mview.inherited_short_note_fr)
        WHEN LENGTH(listing_changes_mview.full_note_fr) > 0 THEN strip_tags(listing_changes_mview.full_note_fr)
        WHEN LENGTH(listing_changes_mview.short_note_fr) > 0 THEN strip_tags(listing_changes_mview.short_note_fr)
        ELSE ''
      END
      || CASE
        WHEN LENGTH(listing_changes_mview.nomenclature_note_fr) > 0 THEN strip_tags(listing_changes_mview.nomenclature_note_fr)
        ELSE ''
      END
  END AS annotation_fr,
  CASE
    WHEN listing_changes_mview.hash_ann_symbol IS NULL
      AND listing_changes_mview.hash_full_note_en IS NULL
    THEN NULL::JSON
    ELSE
      ROW_TO_JSON(
        ROW(
          listing_changes_mview.hash_ann_symbol,
          strip_tags(listing_changes_mview.hash_full_note_en)
        )::api_annotation
      )
  END AS hash_annotation_en,
  CASE
    WHEN listing_changes_mview.hash_ann_symbol IS NULL
      AND listing_changes_mview.hash_full_note_es IS NULL
    THEN NULL::JSON
    ELSE
      ROW_TO_JSON(
        ROW(
          listing_changes_mview.hash_ann_parent_symbol || ' ' || listing_changes_mview.hash_ann_symbol,
          strip_tags(listing_changes_mview.hash_full_note_es)
        )::api_annotation
      )
  END AS hash_annotation_es,
  CASE
    WHEN listing_changes_mview.hash_ann_symbol IS NULL
      AND listing_changes_mview.hash_full_note_fr IS NULL
    THEN NULL::JSON
    ELSE
      ROW_TO_JSON(
        ROW(
          listing_changes_mview.hash_ann_symbol,
          strip_tags(listing_changes_mview.hash_full_note_fr)
        )::api_annotation
      )
  END AS hash_annotation_fr,
  listing_changes_mview.show_in_history,
  listing_changes_mview.full_note_en,
  listing_changes_mview.short_note_en,
  listing_changes_mview.auto_note_en,
  listing_changes_mview.hash_full_note_en,
  listing_changes_mview.hash_ann_parent_symbol,
  listing_changes_mview.hash_ann_symbol,
  listing_changes_mview.inherited_full_note_en,
  listing_changes_mview.inherited_short_note_en,
  listing_changes_mview.nomenclature_note_en,
  listing_changes_mview.nomenclature_note_fr,
  listing_changes_mview.nomenclature_note_es,
  CASE
    WHEN change_type_name = 'ADDITION' THEN 0
    WHEN change_type_name = 'RESERVATION' THEN 1
    WHEN change_type_name = 'RESERVATION_WITHDRAWAL' THEN 2
    WHEN change_type_name = 'DELETION' THEN 3
  END AS change_type_order
FROM cites_listing_changes_mview listing_changes_mview
WHERE "listing_changes_mview"."show_in_history";


text:
use anyhow::Result;
use clap::{Arg, ArgMatches, Command};

use crate::api::Api;
use crate::config::Config;
use crate::utils::formatting::Table;

pub fn make_command(command: Command) -> Command {
    command
        .about("List all events in your organization.")
        .arg(
            Arg::with_name("show_user")
                .long("show-user")
                .short('U')
                .help("Display the Users column."),
        )
        .arg(
            Arg::with_name("show_tags")
                .long("show-tags")
                .short('T')
                .help("Display the Tags column."),
        )
        .arg(
            Arg::new("max_rows")
                .long("max-rows")
                .value_name("MAX_ROWS")
                .value_parser(clap::value_parser!(usize))
                .help("Maximum number of rows to print."),
        )
        .arg(
            Arg::new("pages")
                .long("pages")
                .value_name("PAGES")
                .default_value("5")
                .value_parser(clap::value_parser!(usize))
                .help("Maximum number of pages to fetch (100 events/page)."),
        )
}

pub fn execute(matches: &ArgMatches) -> Result<()> {
    let config = Config::current();
    let org = config.get_org(matches)?;
    let project = config.get_project(matches)?;
    let pages = *matches.get_one("pages").unwrap();
    let api = Api::current();

    let events = api.list_organization_project_events(&org, &project, pages)?;

    let mut table = Table::new();
    let title_row = table.title_row().add("Event ID").add("Date").add("Title");

    if matches.is_present("show_user") {
        title_row.add("User");
    }

    if matches.is_present("show_tags") {
        title_row.add("Tags");
    }

    let max_rows = std::cmp::min(
        events.len(),
        *matches.get_one("max_rows").unwrap_or(&std::usize::MAX),
    );

    if let Some(events) = events.get(..max_rows) {
        for event in events {
            let row = table.add_row();
            row.add(event.event_id)
                .add(&event.date_created)
                .add(&event.title);

            if matches.is_present("show_user") {
                if let Some(user) = &event.user {
                    row.add(user);
                } else {
                    row.add("-");
                }
            }

            if matches.is_present("show_tags") {
                if let Some(tags) = &event.tags {
                    row.add(
                        tags.iter()
                            .map(|t| t.to_string())
                            .collect::<Vec<_>>()
                            .join("\n"),
                    );
                } else {
                    row.add("-");
                }
            }
        }
    }

    if table.is_empty() {
        println!("No events found");
    } else {
        table.print();
    }

    Ok(())
}

redpajama_set_name: RedPajamaGithub


text:
<!doctype html>

  <meta charset="utf-8">
  <link rel="canonical" href="./regular-html-version.html">
  <meta name="viewport" content="width=device-width,minimum-scale=1">

  <amp-animation layout="nodisplay">

  </amp-animation>

    <amp-animation layout="nodisplay">

    </amp-animation>

  <amp-animation layout="nodisplay" trigger="display">

  </amp-animation>

  <amp-animation layout="nodisplay">
  </amp-animation>


text:
"""This can be run as a script to setup a database for the application
"""
print('The db_setup script ran!')


text:
[![Build Status][travis-img]][travis-repo]
[travis-img]:  https://travis-ci.org/micropython/micropython.png?branch=master
[travis-repo]: https://travis-ci.org/micropython/micropython

The Micro Python project
========================

This is the Micro Python project, which aims to put an implementation
of Python 3.x on microcontrollers and small embedded systems.

WARNING: this project is in beta stage and is subject to changes of the
code-base, including project-wide name changes and API changes.

Micro Python implements the entire Python 3.4 syntax (including exceptions,
"with", "yield from", etc.).  The following core datatypes are provided:
str (including basic Unicode support), bytes, bytearray, tuple, list, dict,
set, frozenset, array.array, collections.namedtuple, classes and instances.
Builtin modules include sys, time, and struct.  Note that only subset of
Python 3.4 functionality implemented for the data types and modules.

See the repository www.github.com/micropython/pyboard for the Micro
Python board, the officially supported reference electronic circuit board.

Major components in this repository:
- py/ -- the core Python implementation, including compiler and runtime.
- unix/ -- a version of Micro Python that runs on Unix.
- stmhal/ -- a version of Micro Python that runs on the Micro Python board
  with an STM32F405RG (using ST's Cube HAL drivers).
- teensy/ -- a version of Micro Python that runs on the Teensy 3.1
  (preliminary but functional).

Additional components:
- bare-arm/ -- a bare minimum version of Micro Python for ARM MCUs.  Start
  with this if you want to port Micro Python to another microcontroller.
- unix-cpy/ -- a version of Micro Python that outputs bytecode (for testing).
- tests/ -- test framework and test scripts.
- tools/ -- various tools, including the pyboard.py module.
- examples/ -- a few example Python scripts.

"make" is used to build the components, or "gmake" on BSD-based systems.
You will also need bash and Python (at least 2.7 or 3.3).

The Unix version
----------------

The "unix" port requires a standard Unix environment with gcc and GNU make.
x86 and x64 architectures are supported (i.e. x86 32- and 64-bit), as well
as ARM and MIPS. Making full-featured port to another architecture requires
writing some assembly code for the exception handling and garbage collection.
Alternatively, fallback implementation based on setjmp/longjmp can be used.

To build:

    $ cd unix
    $ make

Then to give it a try:

    $ ./micropython
    >>> list(5 * x + y for x in range(10) for y in [4, 2, 1])

Run complete testsuite:

    $ make test

Debian/Ubuntu/Mint derivative Linux distros will require build-essentials and
libreadline-dev packages installed. To build FFI (Foreign Function Interface)
module, libffi-dev and pkg-config packages are required. If you have problems
with some dependencies, they can be disabled in unix/mpconfigport.mk .

The STM version
---------------

The "stmhal" port requires an ARM compiler, arm-none-eabi-gcc, and associated
bin-utils.  For those using Arch Linux, you need arm-none-eabi-binutils and
arm-none-eabi-gcc packages from the AUR.  Otherwise, try here:
https://launchpad.net/gcc-arm-embedded

To build:

    $ cd stmhal
    $ make

You then need to get your board into DFU mode.  On the pyboard, connect the
3V3 pin to the P1/DFU pin with a wire (on PYBv1.0 they are next to each other
on the bottom left of the board, second row from the bottom).

Then to flash the code via USB DFU to your device:

    $ make deploy

You will need the dfu-util program, on Arch Linux it's dfu-util-git in the
AUR.  If the above does not work it may be because you don't have the
correct permissions.  Try then:

    $ sudo dfu-util -a 0 -d 0483:df11 -D build-PYBV10/firmware.dfu

Building the documentation locally
----------------------------------

Install Sphinx, and optionally (for the RTD-styling), sphinx_rtd_theme,
preferably in a virtualenv:

     pip install sphinx
     pip install sphinx_rtd_theme

In `micropython/docs`, build the docs:

    make html

You'll find the index page at `micropython/docs/build/html/index.html`.


text:
package topology;

import ParseOfSQL.ParsingSQL;
import bolts.JoinBolt;
import bolts.PrinterBolt;
import definetable.Global;
import definetable.MField;
import definetable.MTable;
import domain.BinaryTreeAndOr;
import domain.ProjectConfig;
import operation.*;
import org.apache.storm.Config;
import org.apache.storm.LocalCluster;
import org.apache.storm.topology.TopologyBuilder;
import org.apache.storm.topology.base.BaseWindowedBolt;
import spouts.JoinSpouttest_1;
import spouts.JoinSpouttest_2;

import java.io.BufferedReader;
import java.io.FileReader;
import java.util.*;
import java.util.concurrent.TimeUnit;

/**
 *
 * Created by yao on 5/16/17.
 */
public class JoinTopology {
    private static HashMap<String, MTable> dataBase;
    private static ParsingSQL parsingSQL;
    private static FileReader fileReader;

    public static void main(String[] args) throws Exception {
        //region   载入表结构
        Global.loadingDataStructure(ProjectConfig.res_createTab_path);
        //测试是否载入成功,并获取表的列名
        dataBase = Global.DataBase;
        //endregion
        fileReader = new FileReader(ProjectConfig.res_inputSQL_path);
        BufferedReader bufferedReader = new BufferedReader(fileReader);
        String sql = "";
        parsingSQL = new ParsingSQL();
        boolean flag = true;
        while (flag && (sql = bufferedReader.readLine()) != null) {
            // 读取sql ,解析sql
            System.out.println(sql);
            parsingSQL.testparsingTheSQL(sql);

            //region 测试SQL 语义是否解析成功
            System.out.println(Selection.binaryTreeAndOr == null);
            BinaryTreeAndOr binaryTreeAndOr = Selection.binaryTreeAndOr;
            System.out.println(Projection.proList.size());
            List<TCItem> tp = Projection.proList;
            System.out.println(Selection.fromTableList.size());
            List<String> ft = Selection.fromTableList;
            System.out.println(JoinCondition.linkTablemap.size());
            Map<String, JoinTwoTable> tj = JoinCondition.linkTablemap;
            System.out.print(GroupBy.groupList.size());
            List<TCItem> tg = GroupBy.groupList;
            System.out.println(AggregationStream.agreFunList.size());
            List<AgregationFunFactor> ag = AggregationStream.agreFunList;
            System.out.println(AggregationStream.havingList.size());
            List<TCItem> th = AggregationStream.havingList;
            // endregion
            //只读取一条sql语句
            flag = false;
        }
        bufferedReader.close();
        fileReader.close();
        TopologyBuilder builder = new TopologyBuilder();
        builder.setSpout("data_reader_1",new JoinSpouttest_1());
        builder.setSpout("data_reader_2",new JoinSpouttest_2());
        JoinBolt bolt = (JoinBolt) new JoinBolt().withTumblingWindow(new BaseWindowedBolt.Duration(5, TimeUnit.SECONDS));
        PrinterBolt bolt2 = new PrinterBolt();

        List<String> JoinOutputField = JoinDataStruct();

        bolt.setDescOfOutputFileds(JoinOutputField);

        builder.setBolt("join_bolt",bolt,1).shuffleGrouping("data_reader_1").shuffleGrouping("data_reader_2");
        builder.setBolt("print_bolt",bolt2,1).shuffleGrouping("join_bolt");

        Config conf = new Config();
        conf.put("InputSQL", args[0]);
        conf.setDebug(false);

        //Topology run
        conf.put(Config.TOPOLOGY_MAX_SPOUT_PENDING, 1);
        LocalCluster cluster = new LocalCluster();
        cluster.submitTopology("Getting-Started-Toplogie", conf, builder.createTopology());
        Thread.sleep(8000);
        cluster.shutdown();
    }

    private static List<String> JoinDataStruct(){
        List<String> JoinOutputField = new ArrayList<String>();
        JoinOutputField.add("Table");

        String JoinTabName = "";  // 获取连接表表名
        Iterator<String> iterator = JoinCondition.linkTablemap.keySet().iterator();
        String JoinOP = "";  // join的方式,是Left,Right或者Inner
        String compareCol = ""; // 获取连接的条件,如JData_Action_201602.sku_id = JData_Action_201603.sku_id,则该项为sku_id
        while (iterator.hasNext()){
            String A = iterator.next();
            JoinTabName = A.split("\\|")[0];
            JoinOP = A.split("\\|")[1];
            compareCol = JoinCondition.linkTablemap.get(A).getTcItemRight().getColName();
        }
        MTable mTable_1 = dataBase.get(JoinCondition.originTabName);
        MTable mTable_2 = dataBase.get(JoinTabName);

        if(JoinOP.equals("Left") || JoinOP.equals("Inner")){
            for(MField mField:mTable_1.getField()){
                JoinOutputField.add(JoinCondition.originTabName + "." + mField.getName());
            }
            for(MField mField:mTable_2.getField()){
                if(mField.getName().equals(compareCol))
                    continue;
                JoinOutputField.add(JoinTabName + "." + mField.getName());
            }
        }
        else if(JoinOP.equals("Right")){
            for(MField mField:mTable_2.getField()){
                JoinOutputField.add(JoinTabName + "." + mField.getName());
            }
            for(MField mField:mTable_1.getField()){
                if(mField.getName().equals(compareCol))
                    continue;
                JoinOutputField.add(JoinCondition.originTabName + "." + mField.getName());
            }
        }
        return JoinOutputField;
    }

}


text:
daeElementRef
domCommon_param::create(DAE& dae)
{
	domCommon_paramRef ref = new domCommon_param(dae);
	return ref;
}

daeMetaElement *
domCommon_param::registerElement(DAE& dae)
{
	daeMetaElement* meta = dae.getMeta(ID());
	if ( meta != NULL ) return meta;

	meta = new daeMetaElement(dae);
	dae.setMeta(ID(), *meta);
	meta->setName( "common_param" );
	meta->registerClass(domCommon_param::create);

	//	Add attribute: _value
	{
		daeMetaAttribute *ma = new daeMetaAttribute;
		ma->setName( "_value" );
		ma->setType( dae.getAtomicTypes().get("xsToken"));
		ma->setOffset( daeOffsetOf( domCommon_param , _value ));
		ma->setContainer( meta );
		meta->appendAttribute(ma);
	}

	meta->setElementSize(sizeof(domCommon_param));
	meta->validate();

	return meta;
}


text:
from grafanalib.core import Dashboard, Graph, Row, Target, YAxes, YAxis, SECONDS_FORMAT
from grr_grafanalib_dashboards.util import add_data_source
from grr_grafanalib_dashboards.reusable_panels import GENERAL_PANELS
from grr_grafanalib_dashboards.config import GRAFANA_DATA_SOURCE

GRR_COMPONENT = "frontend"

dashboard = Dashboard(
  title="{}s Dashboard".format(GRR_COMPONENT).title(),
  rows=[
    Row(panels=[panel(GRR_COMPONENT) for panel in row])
    for row in GENERAL_PANELS
    ] +
    [
      Row(panels=[
      Graph(
        title="QPS",
        targets=[
          Target(
            expr='sum(rate(frontend_request_count_total[1m]))',
            legendFormat="Requests",
          ),
        ],
        yAxes=YAxes(
          left=YAxis(format="reqps")
        ),
      ),
      Graph(
        title="Request Latency",
        targets=[
          Target(
            expr='sum(rate(frontend_request_latency_sum[10m])) / sum(rate(frontend_request_latency_count[10m]))',
            legendFormat="Latency",
          ),
        ],
        yAxes=YAxes(
          left=YAxis(format=SECONDS_FORMAT)
        ),
      ),
      Graph(
        title="Well Known Flows Requests Rate by Flow",
        targets=[
          Target(
            expr='sum by (flow) (rate(well_known_flow_requests_total[10m]))',
            legendFormat="{{flow}}",
          ),
        ],
      ),
      Graph(
        title="GRR Client Crashes",
        targets=[
          Target(
            expr='sum(rate(grr_client_crashes_total{job="grr_frontend"}[10m]))',
            legendFormat="Rate of Client crashes",
          ),
        ],
      )
    ]
    ),
  ]
).auto_panel_ids()

dashboard = add_data_source(dashboard, GRAFANA_DATA_SOURCE)


text:
"""Helper module to handle time related stuff"""
from random import gauss
from time import sleep as original_sleep

# Amount of variance to be introduced
# i.e. random time will be in the range: TIME +/- STDEV %
STDEV = 0.5

def randomize_time(mean):
    allowed_range = mean * STDEV
    stdev = allowed_range / 3  # 99.73% chance to be in the allowed range

    t = 0
    while abs(mean - t) > allowed_range:
        t = gauss(mean, stdev)

    return t

def sleep(t):
    original_sleep(randomize_time(t))


text:
package net.ripe.db.whois.api.search;

import com.google.common.base.Stopwatch;
import org.apache.commons.io.IOUtils;
import org.apache.lucene.facet.taxonomy.TaxonomyWriter;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.search.Query;
import org.slf4j.Logger;

import java.io.IOException;
import java.util.concurrent.Semaphore;

public abstract class RebuildableIndex {
    private final Logger logger;

    private final Semaphore updateLock = new Semaphore(1);

    protected final String indexDir;
    protected IndexTemplate index;

    protected RebuildableIndex(final Logger logger, final String indexDir) {
        this.logger = logger;
        this.indexDir = indexDir;
    }

    protected void init(final IndexWriterConfig config, final IndexTemplate.WriteCallback initializer) {
        if (!updateLock.tryAcquire()) {
            throw new IllegalStateException("Unable to acquire update lock");
        }

        try {
            index = new IndexTemplate(indexDir, config);
            index.write(initializer);
        } catch (IOException e) {
            throw new IllegalStateException(String.format("Initializing index in %s", indexDir), e);
        } finally {
            updateLock.release();
        }
    }

    protected void cleanup() {
        IOUtils.closeQuietly(index);
    }

    public final void rebuild() {
        try {
            updateLock.acquireUninterruptibly();
            logger.info("Rebuilding index {}", indexDir);
            final Stopwatch stopwatch = Stopwatch.createStarted();
            index.write(new IndexTemplate.WriteCallback() {
                @Override
                public void write(final IndexWriter indexWriter, final TaxonomyWriter taxonomyWriter) throws IOException {
                    rebuild(indexWriter, taxonomyWriter);
                }
            });
            logger.info("Rebuilt index {} in {}", indexDir, stopwatch.stop());
        } catch (IOException e) {
            logger.error("Rebuilding index: {}", indexDir, e);
        } finally {
            updateLock.release();
        }
    }

    public final void update() {
        update(new IndexTemplate.WriteCallback() {
                    @Override
                    public void write(final IndexWriter indexWriter, final TaxonomyWriter taxonomyWriter) throws IOException {
                        update(indexWriter, taxonomyWriter);
                    }
        });
    }

    public final void update(IndexTemplate.WriteCallback writeCallback) {
        if (!updateLock.tryAcquire()) {
            logger.warn("Indexing in progress, skipping update for {}", indexDir);
            return;
        }

        try {
            index.write(writeCallback);
        } catch (IOException e) {
            logger.error("Updating index: {}", indexDir, e);
        } finally {
            updateLock.release();
        }
    }

    public void delete(final Query query) {
        if (!updateLock.tryAcquire()) {
            logger.warn("Indexing in progress, skipping delete for {}", query.toString());
            return;
        }

        try {
            index.write(new IndexTemplate.WriteCallback() {
                @Override
                public void write(final IndexWriter indexWriter, final TaxonomyWriter taxonomyWriter) throws IOException {
                    indexWriter.deleteDocuments(query);
                }
            });
        } catch (IOException e) {
            logger.error("Updating index: {}", indexDir, e);
        } finally {
            updateLock.release();
        }
    }

    public <T> T search(IndexTemplate.SearchCallback<T> searchCallback) throws IOException {
        if (index == null) {
            throw new IllegalStateException("Index not found.");
        }

        return index.search(searchCallback);
    }

    protected abstract void update(final IndexWriter indexWriter, final TaxonomyWriter taxonomyWriter) throws IOException;

    protected abstract void rebuild(final IndexWriter indexWriter, final TaxonomyWriter taxonomyWriter) throws IOException;
}


text:
<object-schema>
  <name>institute</name>
  <record>
    <name>com.krishagni.catissueplus.core.administrative.events.InstituteDetail</name>

    <field>

Name

      <attribute>name</attribute>
    </field>

    <record>
      <attribute>departments</attribute>
      <multiple>true</multiple>

Department

      <field>

Name

        <attribute>name</attribute>
      </field>
    </record>
  </record>
</object-schema>


text:
Sign Up

<form ng-submit="vm.signup(vm.credentials)">

    <md-input-container flex>
      Email
      <input type="text" ng-model="vm.credentials.email">
    </md-input-container>

    <md-input-container flex>
      Password
      <input type="password" ng-model="vm.credentials.password">
    </md-input-container>

    <md-button type="submit" class="md-primary md-raised">
      Sign up
    </md-button>

    <md-button class="md-primary md-warn md-raised" ng-click="vm.googleSignup()">
      <md-icon md-svg-icon="language"></md-icon>
      Sign up with Google
    </md-button>

</form>

  Have an account? Login now!