text:
package com.palantir.atlasdb.timelock.lock.watch;

import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.palantir.atlasdb.encoding.PtBytes;
import com.palantir.atlasdb.keyvalue.api.Cell;
import com.palantir.atlasdb.keyvalue.api.TableReference;
import com.palantir.atlasdb.keyvalue.api.watch.LockWatchReferenceUtils;
import com.palantir.atlasdb.timelock.api.LockWatchRequest;
import com.palantir.atlasdb.timelock.lock.AsyncLock;
import com.palantir.atlasdb.timelock.lock.ExclusiveLock;
import com.palantir.atlasdb.timelock.lock.HeldLocks;
import com.palantir.atlasdb.timelock.lock.HeldLocksCollection;
import com.palantir.lock.AtlasCellLockDescriptor;
import com.palantir.lock.AtlasRowLockDescriptor;
import com.palantir.lock.LockDescriptor;
import com.palantir.lock.v2.LockToken;
import com.palantir.lock.watch.LockEvent;
import com.palantir.lock.watch.LockWatchCreatedEvent;
import com.palantir.lock.watch.LockWatchEvent;
import com.palantir.lock.watch.LockWatchReferences.LockWatchReference;
import com.palantir.lock.watch.LockWatchStateUpdate;
import com.palantir.lock.watch.LockWatchVersion;
import com.palantir.lock.watch.UnlockEvent;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.UUID;
import org.junit.Before;
import org.junit.Test;

public class LockWatchingServiceImplTest {
    private static final UUID LOG_ID = UUID.randomUUID();
    private static final TableReference TABLE = TableReference.createFromFullyQualifiedName("test.table");
    private static final TableReference TABLE_2 = TableReference.createFromFullyQualifiedName("prod.table");
    private static final LockToken TOKEN = LockToken.of(UUID.randomUUID());

    private static final byte[] ROW = PtBytes.toBytes("row");
    private static final Cell CELL = Cell.create(ROW, PtBytes.toBytes("col"));
    private static final LockDescriptor CELL_DESCRIPTOR =
            AtlasCellLockDescriptor.of(TABLE.getQualifiedName(), CELL.getRowName(), CELL.getColumnName());
    private static final LockDescriptor ROW_DESCRIPTOR = AtlasRowLockDescriptor.of(TABLE.getQualifiedName(), ROW);
    private static final AsyncLock LOCK = new ExclusiveLock(ROW_DESCRIPTOR);
    private static final AsyncLock LOCK_2 = new ExclusiveLock(descriptorForOtherTable());

    private final HeldLocksCollection locks = mock(HeldLocksCollection.class);
    private final LockWatchingService lockWatcher = new LockWatchingServiceImpl(LOG_ID, locks);

    private final HeldLocks heldLocks = mock(HeldLocks.class);

    private int sequenceCounter = 0;

    @Before
    public void setup() {
        when(heldLocks.getLocks()).thenReturn(ImmutableList.of(LOCK, LOCK_2));
        when(heldLocks.getToken()).thenReturn(TOKEN);
        when(locks.locksHeld()).thenReturn(ImmutableSet.of(heldLocks));
    }

    @Test
    public void watchNewLockWatchLogsHeldLocksInRange() {
        LockWatchRequest request = tableRequest();
        lockWatcher.startWatching(request);

        List<LockWatchEvent> expectedEvents =
                ImmutableList.of(createdEvent(request.getReferences(), ImmutableSet.of(ROW_DESCRIPTOR)));
        assertLoggedEvents(expectedEvents);
    }

    @Test
    public void registeringWatchWithWiderScopeLogsAlreadyWatchedLocksAgain() {
        LockDescriptor secondRow = AtlasRowLockDescriptor.of(TABLE.getQualifiedName(), PtBytes.toBytes("other_row"));
        when(heldLocks.getLocks()).thenReturn(ImmutableList.of(LOCK, new ExclusiveLock(secondRow)));

        LockWatchRequest prefixRequest = prefixRequest(ROW);
        lockWatcher.startWatching(prefixRequest);

        LockWatchRequest entireTableRequest = tableRequest();
        lockWatcher.startWatching(entireTableRequest);

        List<LockWatchEvent> expectedEvents = ImmutableList.of(
                createdEvent(prefixRequest.getReferences(), ImmutableSet.of(ROW_DESCRIPTOR)),
                createdEvent(entireTableRequest.getReferences(), ImmutableSet.of(ROW_DESCRIPTOR, secondRow)));
        assertLoggedEvents(expectedEvents);
    }

    @Test
    public void registeringWatchWithOverlappingScopeLogsAlreadyWatchedLocksInScopeAgain() {
        LockDescriptor ab = AtlasRowLockDescriptor.of(TABLE.getQualifiedName(), PtBytes.toBytes("ab"));
        LockDescriptor bc = AtlasRowLockDescriptor.of(TABLE.getQualifiedName(), PtBytes.toBytes("bc"));
        LockDescriptor cd = AtlasRowLockDescriptor.of(TABLE.getQualifiedName(), PtBytes.toBytes("cd"));
        when(heldLocks.getLocks())
                .thenReturn(
                        ImmutableList.of(LOCK, new ExclusiveLock(ab), new ExclusiveLock(bc), new ExclusiveLock(cd)));

        LockWatchReference acRange =
                LockWatchReferenceUtils.rowRange(TABLE, PtBytes.toBytes("a"), PtBytes.toBytes("c"));
        LockWatchReference bdRange =
                LockWatchReferenceUtils.rowRange(TABLE, PtBytes.toBytes("b"), PtBytes.toBytes("d"));

        lockWatcher.startWatching(LockWatchRequest.of(ImmutableSet.of(acRange)));
        lockWatcher.startWatching(LockWatchRequest.of(ImmutableSet.of(bdRange)));

        List<LockWatchEvent> expectedEvents = ImmutableList.of(
                createdEvent(ImmutableSet.of(acRange), ImmutableSet.of(ab, bc)),
                createdEvent(ImmutableSet.of(bdRange), ImmutableSet.of(bc, cd)));
        assertLoggedEvents(expectedEvents);
    }

    @Test
    public void registeringWatchWithNarrowerScopeIsNoop() {
        LockWatchRequest request = tableRequest();
        lockWatcher.startWatching(request);

        LockWatchRequest prefixRequest = prefixRequest(ROW);
        lockWatcher.startWatching(prefixRequest);

        List<LockWatchEvent> expectedEvents =
                ImmutableList.of(createdEvent(request.getReferences(), ImmutableSet.of(ROW_DESCRIPTOR)));
        assertLoggedEvents(expectedEvents);
    }

    @Test
    public void onlyAlreadyWatchedRangesAreIgnoredOnRegistration() {
        LockWatchRequest request = tableRequest();
        lockWatcher.startWatching(request);

        LockWatchReference newWatch = LockWatchReferenceUtils.entireTable(TABLE_2);
        LockWatchRequest prefixAndOtherTableRequest =
                LockWatchRequest.of(ImmutableSet.of(LockWatchReferenceUtils.rowPrefix(TABLE, ROW), newWatch));
        lockWatcher.startWatching(prefixAndOtherTableRequest);

        List<LockWatchEvent> expectedEvents = ImmutableList.of(
                createdEvent(request.getReferences(), ImmutableSet.of(ROW_DESCRIPTOR)),
                createdEvent(ImmutableSet.of(newWatch), ImmutableSet.of(descriptorForOtherTable())));
        assertLoggedEvents(expectedEvents);
    }

    @Test
    public void exactCellWatchMatchesExactDescriptorOnly() {
        LockDescriptor cellSuffixDescriptor =
                AtlasCellLockDescriptor.of(TABLE.getQualifiedName(), CELL.getRowName(), PtBytes.toBytes("col2"));

        LockWatchRequest request = LockWatchRequest.of(ImmutableSet.of(LockWatchReferenceUtils.exactCell(TABLE, CELL)));
        lockWatcher.startWatching(request);

        ImmutableSet<LockDescriptor> locks = ImmutableSet.of(CELL_DESCRIPTOR, cellSuffixDescriptor);
        lockWatcher.registerLock(locks, TOKEN);

        List<LockWatchEvent> expectedEvents = ImmutableList.of(
                createdEvent(request.getReferences(), ImmutableSet.of()), lockEvent(ImmutableSet.of(CELL_DESCRIPTOR)));
        assertLoggedEvents(expectedEvents);
    }

    @Test
    public void exactRowWatchMatchesExactDescriptorOnly() {
        LockWatchRequest rowRequest =
                LockWatchRequest.of(ImmutableSet.of(LockWatchReferenceUtils.exactRow(TABLE, ROW)));
        lockWatcher.startWatching(rowRequest);

        ImmutableSet<LockDescriptor> locks = ImmutableSet.of(CELL_DESCRIPTOR, ROW_DESCRIPTOR);
        lockWatcher.registerLock(locks, TOKEN);

        List<LockWatchEvent> expectedEvents = ImmutableList.of(
                createdEvent(rowRequest.getReferences(), ImmutableSet.of(ROW_DESCRIPTOR)),
                lockEvent(ImmutableSet.of(ROW_DESCRIPTOR)));
        assertLoggedEvents(expectedEvents);
    }

    @Test
    public void rowPrefixWatchMatchesSuffixes() {
        byte[] rowPrefix = PtBytes.toBytes("ro");
        LockDescriptor notPrefixDescriptor = AtlasRowLockDescriptor.of(TABLE.getQualifiedName(), PtBytes.toBytes("r"));

        LockWatchRequest prefixRequest = prefixRequest(rowPrefix);
        lockWatcher.startWatching(prefixRequest);

        ImmutableSet<LockDescriptor> locks = ImmutableSet.of(CELL_DESCRIPTOR, ROW_DESCRIPTOR, notPrefixDescriptor);
        lockWatcher.registerLock(locks, TOKEN);

        List<LockWatchEvent> expectedEvents = ImmutableList.of(
                createdEvent(prefixRequest.getReferences(), ImmutableSet.of(ROW_DESCRIPTOR)),
                lockEvent(ImmutableSet.of(CELL_DESCRIPTOR, ROW_DESCRIPTOR)));
        assertLoggedEvents(expectedEvents);
    }

    @Test
    public void rowRangeWatchTest() {
        byte[] startOfRange = PtBytes.toBytes("aaz");
        byte[] endOfRange = PtBytes.toBytes("cca");

        LockDescriptor cellInRange = AtlasCellLockDescriptor.of(TABLE.getQualifiedName(), startOfRange, ROW);
        LockDescriptor cellOutOfRange = AtlasCellLockDescriptor.of(TABLE.getQualifiedName(), endOfRange, ROW);

        LockDescriptor rowInRange = AtlasRowLockDescriptor.of(TABLE.getQualifiedName(), PtBytes.toBytes("b"));
        LockDescriptor rowInRange2 = AtlasRowLockDescriptor.of(TABLE.getQualifiedName(), PtBytes.toBytes("cc"));
        LockDescriptor rowOutOfRange = AtlasRowLockDescriptor.of(TABLE.getQualifiedName(), PtBytes.toBytes("cca"));

        LockWatchRequest rangeRequest =
                LockWatchRequest.of(ImmutableSet.of(LockWatchReferenceUtils.rowRange(TABLE, startOfRange, endOfRange)));
        lockWatcher.startWatching(rangeRequest);

        ImmutableSet<LockDescriptor> locks =
                ImmutableSet.of(cellInRange, cellOutOfRange, rowInRange, rowInRange2, rowOutOfRange);
        lockWatcher.registerLock(locks, TOKEN);

        List<LockWatchEvent> expectedEvents = ImmutableList.of(
                createdEvent(rangeRequest.getReferences(), ImmutableSet.of()),
                lockEvent(ImmutableSet.of(cellInRange, rowInRange, rowInRange2)));
        assertLoggedEvents(expectedEvents);
    }

    @Test
    public void entireTableWatchTest() {
        LockDescriptor cellOutOfRange = AtlasCellLockDescriptor.of(TABLE_2.getQualifiedName(), ROW, ROW);
        LockDescriptor rowInRange = AtlasRowLockDescriptor.of(TABLE.getQualifiedName(), ROW);
        LockDescriptor rowOutOfRange = AtlasRowLockDescriptor.of(TABLE_2.getQualifiedName(), ROW);

        LockWatchRequest tableRequest = tableRequest();
        lockWatcher.startWatching(tableRequest);

        ImmutableSet<LockDescriptor> locks =
                ImmutableSet.of(CELL_DESCRIPTOR, cellOutOfRange, rowInRange, rowOutOfRange);
        lockWatcher.registerLock(locks, TOKEN);

        List<LockWatchEvent> expectedEvents = ImmutableList.of(
                createdEvent(tableRequest.getReferences(), ImmutableSet.of(ROW_DESCRIPTOR)),
                lockEvent(ImmutableSet.of(ROW_DESCRIPTOR, CELL_DESCRIPTOR, rowInRange)));
        assertLoggedEvents(expectedEvents);
    }

    @Test
    public void unlockWithoutLockTest() {
        LockWatchRequest tableRequest = tableRequest();
        lockWatcher.startWatching(tableRequest);

        lockWatcher.registerUnlock(ImmutableSet.of(CELL_DESCRIPTOR));

        List<LockWatchEvent> expectedEvents = ImmutableList.of(
                createdEvent(tableRequest.getReferences(), ImmutableSet.of(ROW_DESCRIPTOR)),
                unlockEvent(ImmutableSet.of(CELL_DESCRIPTOR)));
        assertLoggedEvents(expectedEvents);
    }

    private LockWatchEvent createdEvent(Set<LockWatchReference> references, Set<LockDescriptor> descriptors) {
        return LockWatchCreatedEvent.builder(references, descriptors).build(sequenceCounter++);
    }

    private LockWatchEvent lockEvent(Set<LockDescriptor> lockDescriptors) {
        return LockEvent.builder(lockDescriptors, TOKEN).build(sequenceCounter++);
    }

    private LockWatchEvent unlockEvent(Set<LockDescriptor> lockDescriptors) {
        return UnlockEvent.builder(lockDescriptors).build(sequenceCounter++);
    }

    private static LockWatchRequest tableRequest() {
        return LockWatchRequest.of(ImmutableSet.of(LockWatchReferenceUtils.entireTable(TABLE)));
    }

    private static LockWatchRequest prefixRequest(byte[] prefix) {
        return LockWatchRequest.of(ImmutableSet.of(LockWatchReferenceUtils.rowPrefix(TABLE, prefix)));
    }

    private static LockDescriptor descriptorForOtherTable() {
        return AtlasRowLockDescriptor.of(TABLE_2.getQualifiedName(), ROW);
    }

    private void assertLoggedEvents(List<LockWatchEvent> expectedEvents) {
        LockWatchStateUpdate update = lockWatcher.getWatchStateUpdate(Optional.of(LockWatchVersion.of(LOG_ID, -1L)));
        List<LockWatchEvent> events = UpdateVisitors.assertSuccess(update).events();
        assertThat(events).isEqualTo(expectedEvents);
    }
}


text:
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) > [puppeteer](./puppeteer.md) > [Protocol](./puppeteer.protocol.md) > [SystemInfo](./puppeteer.protocol.systeminfo.md) > [GPUInfo](./puppeteer.protocol.systeminfo.gpuinfo.md) > [devices](./puppeteer.protocol.systeminfo.gpuinfo.devices.md)

## Protocol.SystemInfo.GPUInfo.devices property

The graphics devices on the system. Element 0 is the primary GPU.

<b>Signature:</b>

```typescript
devices: GPUDevice[];
```

redpajama_set_name: RedPajamaGithub


text:
package org.apache.phoenix.compile;

import static org.apache.phoenix.util.EncodedColumnsUtil.isPossibleToUseEncodedCQFilter;

import java.sql.SQLException;
import java.sql.SQLFeatureNotSupportedException;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Set;

import org.apache.hadoop.hbase.client.Scan;
import org.apache.hadoop.hbase.filter.Filter;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.phoenix.exception.SQLExceptionCode;
import org.apache.phoenix.exception.SQLExceptionInfo;
import org.apache.phoenix.expression.AndExpression;
import org.apache.phoenix.expression.Determinism;
import org.apache.phoenix.expression.Expression;
import org.apache.phoenix.expression.KeyValueColumnExpression;
import org.apache.phoenix.expression.LiteralExpression;
import org.apache.phoenix.expression.visitor.KeyValueExpressionVisitor;
import org.apache.phoenix.filter.MultiCFCQKeyValueComparisonFilter;
import org.apache.phoenix.filter.MultiCQKeyValueComparisonFilter;
import org.apache.phoenix.filter.MultiEncodedCQKeyValueComparisonFilter;
import org.apache.phoenix.filter.RowKeyComparisonFilter;
import org.apache.phoenix.filter.SingleCFCQKeyValueComparisonFilter;
import org.apache.phoenix.filter.SingleCQKeyValueComparisonFilter;
import org.apache.phoenix.parse.ColumnParseNode;
import org.apache.phoenix.parse.FilterableStatement;
import org.apache.phoenix.parse.ParseNode;
import org.apache.phoenix.parse.ParseNodeFactory;
import org.apache.phoenix.parse.SelectStatement;
import org.apache.phoenix.parse.StatelessTraverseAllParseNodeVisitor;
import org.apache.phoenix.parse.SubqueryParseNode;
import org.apache.phoenix.query.QueryConstants;
import org.apache.phoenix.schema.AmbiguousColumnException;
import org.apache.phoenix.schema.ColumnNotFoundException;
import org.apache.phoenix.schema.ColumnRef;
import org.apache.phoenix.schema.PTable;
import org.apache.phoenix.schema.PTable.ImmutableStorageScheme;
import org.apache.phoenix.schema.PTable.IndexType;
import org.apache.phoenix.schema.PTable.QualifierEncodingScheme;
import org.apache.phoenix.schema.PTable.ViewType;
import org.apache.phoenix.schema.PTableType;
import org.apache.phoenix.schema.TableRef;
import org.apache.phoenix.schema.TypeMismatchException;
import org.apache.phoenix.schema.types.PBoolean;
import org.apache.phoenix.util.ByteUtil;
import org.apache.phoenix.util.ExpressionUtil;
import org.apache.phoenix.util.ScanUtil;
import org.apache.phoenix.util.SchemaUtil;

import com.google.common.collect.Lists;
import com.google.common.collect.Sets;

/**
 *
 * Class to build the filter of a scan
 *
 *
 * @since 0.1
 */
public class WhereCompiler {
    protected static final ParseNodeFactory NODE_FACTORY = new ParseNodeFactory();

    private WhereCompiler() {
    }

    public static Expression compile(StatementContext context, FilterableStatement statement) throws SQLException {
        return compile(context, statement, null, null);
    }

    public static Expression compile(StatementContext context, ParseNode whereNode) throws SQLException {
        WhereExpressionCompiler viewWhereCompiler = new WhereExpressionCompiler(context, true);
        return whereNode.accept(viewWhereCompiler);
    }

    /**
     * Pushes where clause filter expressions into scan by building and setting a filter.
     * @param context the shared context during query compilation
     * @param statement TODO
     * @throws SQLException if mismatched types are found, bind value do not match binds,
     * or invalid function arguments are encountered.
     * @throws SQLFeatureNotSupportedException if an unsupported expression is encountered.
     * @throws ColumnNotFoundException if column name could not be resolved
     * @throws AmbiguousColumnException if an unaliased column name is ambiguous across multiple tables
     */
    public static Expression compile(StatementContext context, FilterableStatement statement, ParseNode viewWhere, Set<SubqueryParseNode> subqueryNodes) throws SQLException {
        return compile(context, statement, viewWhere, Collections.<Expression>emptyList(), subqueryNodes);
    }

    /**
     * Optimize scan ranges by applying dynamically generated filter expressions.
     * @param context the shared context during query compilation
     * @param statement TODO
     * @throws SQLException if mismatched types are found, bind value do not match binds,
     * or invalid function arguments are encountered.
     * @throws SQLFeatureNotSupportedException if an unsupported expression is encountered.
     * @throws ColumnNotFoundException if column name could not be resolved
     * @throws AmbiguousColumnException if an unaliased column name is ambiguous across multiple tables
     */
    public static Expression compile(StatementContext context, FilterableStatement statement, ParseNode viewWhere, List<Expression> dynamicFilters, Set<SubqueryParseNode> subqueryNodes) throws SQLException {
        ParseNode where = statement.getWhere();
        if (subqueryNodes != null) { // if the subqueryNodes passed in is null, we assume there will be no sub-queries in the WHERE clause.
            SubqueryParseNodeVisitor subqueryVisitor = new SubqueryParseNodeVisitor(context, subqueryNodes);
            if (where != null) {
                where.accept(subqueryVisitor);
            }
            if (viewWhere != null) {
                viewWhere.accept(subqueryVisitor);
            }
            if (!subqueryNodes.isEmpty()) {
                return null;
            }
        }

        Set<Expression> extractedNodes = Sets.<Expression>newHashSet();
        WhereExpressionCompiler whereCompiler = new WhereExpressionCompiler(context);
        Expression expression = where == null ? LiteralExpression.newConstant(true, PBoolean.INSTANCE,Determinism.ALWAYS) : where.accept(whereCompiler);
        if (whereCompiler.isAggregate()) {
            throw new SQLExceptionInfo.Builder(SQLExceptionCode.AGGREGATE_IN_WHERE).build().buildException();
        }
        if (expression.getDataType() != PBoolean.INSTANCE) {
            throw TypeMismatchException.newException(PBoolean.INSTANCE, expression.getDataType(), expression.toString());
        }
        if (viewWhere != null) {
            WhereExpressionCompiler viewWhereCompiler = new WhereExpressionCompiler(context, true);
            Expression viewExpression = viewWhere.accept(viewWhereCompiler);
            expression = AndExpression.create(Lists.newArrayList(expression, viewExpression));
        }
        if (!dynamicFilters.isEmpty()) {
            List<Expression> filters = Lists.newArrayList(expression);
            filters.addAll(dynamicFilters);
            expression = AndExpression.create(filters);
        }

        if (context.getCurrentTable().getTable().getType() != PTableType.PROJECTED && context.getCurrentTable().getTable().getType() != PTableType.SUBQUERY) {
            expression = WhereOptimizer.pushKeyExpressionsToScan(context, statement, expression, extractedNodes);
        }
        setScanFilter(context, statement, expression, whereCompiler.disambiguateWithFamily);

        return expression;
    }

    private static class WhereExpressionCompiler extends ExpressionCompiler {
        private boolean disambiguateWithFamily;

        WhereExpressionCompiler(StatementContext context) {
            super(context, true);
        }

        WhereExpressionCompiler(StatementContext context, boolean resolveViewConstants) {
            super(context, resolveViewConstants);
        }

        @Override
        public Expression visit(ColumnParseNode node) throws SQLException {
            ColumnRef ref = resolveColumn(node);
            TableRef tableRef = ref.getTableRef();
            Expression newColumnExpression = ref.newColumnExpression(node.isTableNameCaseSensitive(), node.isCaseSensitive());
            if (tableRef.equals(context.getCurrentTable()) && !SchemaUtil.isPKColumn(ref.getColumn())) {
                byte[] cq = tableRef.getTable().getImmutableStorageScheme() == ImmutableStorageScheme.SINGLE_CELL_ARRAY_WITH_OFFSETS
                		? QueryConstants.SINGLE_KEYVALUE_COLUMN_QUALIFIER_BYTES : ref.getColumn().getColumnQualifierBytes();
                // track the where condition columns. Later we need to ensure the Scan in HRS scans these column CFs
                context.addWhereConditionColumn(ref.getColumn().getFamilyName().getBytes(), cq);
            }
			return newColumnExpression;
        }

        @Override
        protected ColumnRef resolveColumn(ColumnParseNode node) throws SQLException {
            ColumnRef ref = super.resolveColumn(node);
            PTable table = ref.getTable();
            // if current table in the context is local index and table in column reference is global means
            // the column is not present in the local index. If where condition contains the column
            // not present in the index then we need to go through main table for each row in index and get the
            // missing column which is like full scan of index table and data table. Which is
            // inefficient. Then we can skip this plan.
            if (context.getCurrentTable().getTable().getIndexType() == IndexType.LOCAL
                    && (table.getIndexType() == null || table.getIndexType() == IndexType.GLOBAL)) {
                String schemaNameStr = table.getSchemaName()==null?null:table.getSchemaName().getString();
                String tableNameStr = table.getTableName()==null?null:table.getTableName().getString();
                throw new ColumnNotFoundException(schemaNameStr, tableNameStr, null, ref.getColumn().getName().getString());
            }
            // Track if we need to compare KeyValue during filter evaluation
            // using column family. If the column qualifier is enough, we
            // just use that.
            try {
                if (!SchemaUtil.isPKColumn(ref.getColumn())) {
                    table.getColumnForColumnName(ref.getColumn().getName().getString());
                }
            } catch (AmbiguousColumnException e) {
                disambiguateWithFamily = true;
            }
            return ref;
         }
    }

    private static final class Counter {
        public enum Count {NONE, SINGLE, MULTIPLE};
        private Count count = Count.NONE;
        private KeyValueColumnExpression column;

        public void increment(KeyValueColumnExpression column) {
            switch (count) {
                case NONE:
                    count = Count.SINGLE;
                    this.column = column;
                    break;
                case SINGLE:
                    count = column.equals(this.column) ? Count.SINGLE : Count.MULTIPLE;
                    break;
                case MULTIPLE:
                    break;

            }
        }

        public Count getCount() {
            return count;
        }

        public KeyValueColumnExpression getColumn() {
            return column;
        }
    }

    /**
     * Sets the start/stop key range based on the whereClause expression.
     * @param context the shared context during query compilation
     * @param whereClause the final where clause expression.
     */
    private static void setScanFilter(StatementContext context, FilterableStatement statement, Expression whereClause, boolean disambiguateWithFamily) {
        Scan scan = context.getScan();

        if (LiteralExpression.isBooleanFalseOrNull(whereClause)) {
            context.setScanRanges(ScanRanges.NOTHING);
        } else if (whereClause != null && !ExpressionUtil.evaluatesToTrue(whereClause)) {
            Filter filter = null;
            final Counter counter = new Counter();
            whereClause.accept(new KeyValueExpressionVisitor() {

                @Override
                public Iterator<Expression> defaultIterator(Expression node) {
                    // Stop traversal once we've found multiple KeyValue columns
                    if (counter.getCount() == Counter.Count.MULTIPLE) {
                        return Collections.emptyIterator();
                    }
                    return super.defaultIterator(node);
                }

                @Override
                public Void visit(KeyValueColumnExpression expression) {
                    counter.increment(expression);
                    return null;
                }
            });
            PTable table = context.getCurrentTable().getTable();
            QualifierEncodingScheme encodingScheme = table.getEncodingScheme();
            ImmutableStorageScheme storageScheme = table.getImmutableStorageScheme();
            Counter.Count count = counter.getCount();
            boolean allCFs = false;
            byte[] essentialCF = null;
            if (counter.getCount() == Counter.Count.SINGLE && whereClause.requiresFinalEvaluation() ) {
                if (table.getViewType() == ViewType.MAPPED) {
                    allCFs = true;
                } else {
                    byte[] emptyCF = SchemaUtil.getEmptyColumnFamily(table);
                    if (Bytes.compareTo(emptyCF, counter.getColumn().getColumnFamily()) != 0) {
                        essentialCF = emptyCF;
                        count = Counter.Count.MULTIPLE;
                    }
                }
            }
            switch (count) {
            case NONE:
                essentialCF = table.getType() == PTableType.VIEW
                        ? ByteUtil.EMPTY_BYTE_ARRAY
                        : SchemaUtil.getEmptyColumnFamily(table);
                filter = new RowKeyComparisonFilter(whereClause, essentialCF);
                break;
            case SINGLE:
                filter = disambiguateWithFamily
                    ? new SingleCFCQKeyValueComparisonFilter(whereClause)
                    : new SingleCQKeyValueComparisonFilter(whereClause);
                break;
            case MULTIPLE:
                filter = isPossibleToUseEncodedCQFilter(encodingScheme, storageScheme)
                    ? new MultiEncodedCQKeyValueComparisonFilter(whereClause, encodingScheme, allCFs, essentialCF)
                    : (disambiguateWithFamily
                        ? new MultiCFCQKeyValueComparisonFilter( whereClause, allCFs, essentialCF)
                        : new MultiCQKeyValueComparisonFilter(whereClause, allCFs, essentialCF));
                break;
            }
            scan.setFilter(filter);
        }

        ScanRanges scanRanges = context.getScanRanges();
        if (scanRanges.useSkipScanFilter()) {
            ScanUtil.andFilterAtBeginning(scan, scanRanges.getSkipScanFilter());
        }
    }

    private static class SubqueryParseNodeVisitor extends StatelessTraverseAllParseNodeVisitor {
        private final StatementContext context;
        private final Set<SubqueryParseNode> subqueryNodes;

        SubqueryParseNodeVisitor(StatementContext context, Set<SubqueryParseNode> subqueryNodes) {
            this.context = context;
            this.subqueryNodes = subqueryNodes;
        }

        @Override
        public Void visit(SubqueryParseNode node) throws SQLException {
            SelectStatement select = node.getSelectNode();
            if (!context.isSubqueryResultAvailable(select)) {
                this.subqueryNodes.add(node);
            }
            return null;
        }

    }
}


text:
[Text corpus](https://en.wikipedia.org/wiki/Text_corpus) calculation in Javascript.
Supports Chinese, English.
See [demo](http://timdream.org/wordfreq/).

This library is a spin-off project from [HTML5 Word Cloud](https://github.com/timdream/wordcloud).

## Simple usage

Load `wordfreq.js` script to the web page, and run:

    // Create an options object for initialization
    var options = {
      workerUrl: 'path/to/wordfreq.worker.js' };
    // Initialize and run process() function
    var wordfreq = WordFreq(options).process(text, function (list) {
      // console.log the list returned in this callback.
      console.log(list);
    });

`WordFreq()` methods are chainable, for example,

    // Process 3 strings and get corpus of all the texts.
    WordFreq(options)
      .process(text).process(text2).process(text3)
      .getList(function (list) {
        console.log(list);
      });

To use this library synchronously, load `wordfreq.worker.js` and use the `WordFreqSync` interface. Check `API.md` for available options and methods.

### Command-line interface

Command-line interface is available, powered by [Node.js](http://nodejs.org/). To install globally, run

    npm install -g wordfreq

Example usage:

    wordfreq ~/mypost.txt | less
    cat ~/mypost.txt | wordfreq - | less

## Algorithm

Corpus is calculated with a simple N-gram algorithm and sub-string filter.
Here is [an article](http://www.openfoundry.org/tw/foss-forum/8339--open-web-html5-) in Traditional Chinese on how HTML5 Word Cloud is being done.

[Porter Stemming Algorithm](http://tartarus.org/~martin/PorterStemmer/) is included for processing English.

## Testing

To run tests, first you would need to pull the required QUnit library by running

    git submodule init
    git submodule update

Then, start a localhost HTTP server, for example,

    python -m SimpleHTTPServer 8009

Point your browser to [http://localhost:8009/test/](http://localhost:8009/test/) to start testing.

You may also run the tests with PhantomJS by running

    phantomjs test/qunit/addons/phantomjs/runner.js http://localhost:8009/test/

You will find all the information you need to write testcases on the [QUnit](http://qunitjs.com) website.
All non-trivial code submission are expected to accompany with testcases.

**Known IE10 issue**: Looks like IE10 suffers from [the same issue](https://bugzilla.mozilla.org/show_bug.cgi?id=785248) with Firefox <= 17, where Web Worker will choke and couldn't finish the entire test suite.


text:
import sqlite3

class db():
	'''
	Maneja las conexiones con la base de datos.
	'''

	def __init__(self,db_path):
		'''
		Crea la conexión con la base de datos.
		'''
		self.cnx=sqlite3.connect(db_path)
		self.cur=self.cnx.cursor()

	def consultaSimp(self,sql):
		'''
		Consulta de datos simple
		'''
		self.cur.execute(sql)
		return self.cur.fetchall()

	def consultaDat(self,sql,datos):
		'''
		Consulta con varios parámetros.
		'''
		self.cur.execute(sql,datos)
		return self.cur.fetchall()

	def insertarDatos(self,sql,datos):
		'''
		Inserta datos en la base de datos.
		'''
		self.cur.executemany(sql,datos)
		self.cnx.commit()

	def cnxClose(self):
		'''
		Cierra la conexión con la base de datos.
		'''
		self.cnx.close()


text:
class Property < ActiveRecord::Base
	include Identifier

	belongs_to :game_object_class
	belongs_to :game

	validates :name, :presence => true
	validates :category, :presence => true
	validates :game_id, :presence => true

	around_save :flush_redis_writes
	before_save :set_property_klazz, :on => :create
	around_destroy :flush_redis_destroy

	# Assign a new default value to this property. Typing is not enforced until save.
	def value=(value)
		self.updated_at = Time.now
		if is_multi_object?
			(@value ||= []) << value
		else
			@value = value
		end
	end

	# Get the default value of this property.
	def value
		# This bizarre construct is done in order to not be reliant
		# on the inherent assignment-order when using Property.new({...})
		# since that hash can be ordered anywhich way .daniel
		if value_id
			value_object.value
		else
			@value
		end
	end

	def add(v)
		value_object.add(v)
	end

	# Assign a new default value to this property. Typing is not enforced until save.
	def default_value=(value)
		@default_value = value
	end

	# Get the default value of this property.
	def default_value
		# This bizarre construct is done in order to not be reliant
		# on the inherent assignment-order when using Property.new({...})
		# since that hash can be ordered anywhich way .daniel
		if value_id
			value_object.default_value
		else
			@default_value
		end
	end

	def value_description(regular = true)
		value_object.value_description(regular)
	end

	def clone
		raise ArgumentError.new("You can't clone an unsaved property") unless self.persisted?
		return Property.new(:parent_id => self.id, :name => self.name, :property_klazz => self.property_klazz, :category => self.category, :default_value => self.value, :game_id => self.game_id)
	end

	def type
		value_object.type
	end

	def reload
		value_object.reload
	end

	# Identifier methods

	def is_object_property?
		is_multi_object? || is_single_object?
	end

	def is_multi_object?
		return category.to_s.eql?('multi_object')
	end

	def is_single_object?
		return category.to_s.eql?('object')
	end

	def is_string?
		return category.to_s.eql?('string')
	end

	def is_numeric?
		return category.to_s.eql?('numeric')
	end

	def handle_removal(scope)
		res = value_object.handle_removal(scope)
		save
		res
	end

	private

	def value_object
		@value_object ||= load_value_object
	end

	def available_subclasses
		{
			"string" 				=> StringProperty,
			"object" 				=> SingleObjectProperty,
			"multi_object" 			=> MultiObjectProperty,
			"numeric"				=> NumericProperty
		}
	end

	def load_value_object
		value_instance = value_klazz.fetch(self.value_id)
		self.value_id = value_instance.id
		value_instance
	end

	def value_klazz
		available_subclasses[category.to_s]
	end

	def flush_redis_writes
		value_object.value = @value
		value_object.default_value = @default_value
		value_object.save
		yield
		value_object.commit
	end

	def set_property_klazz
		if value_klazz.can_set_property_klazz? && self.property_klazz.blank?
			self.property_klazz = value_klazz.definition_class.to_s
		end
	end

	def flush_redis_destroy
		value_object.destroy
		yield
		if self.persisted?
			value_object.commit
		else
			value_object.discard
		end
	end

end


text:
  Correo

A menubar/taskbar Gmail App based on Electron.

|  Windows            |    |
|---------------------|----------------------|
|![sreenshot1](https://raw.githubusercontent.com/amitmerchant1990/correo/master/res/screenshot.png) |  ![screenshot2](https://raw.githubusercontent.com/amitmerchant1990/correo/master/res/screenshot2.png) |

## Features

* Runs Gmail right from the Taskbar (in Windows) or from the Menubar (in macOS).
* Remains active in the tray for quick usage.
* Uses Gmail's UI for mobile so it's best to use within menubar/taskbar.
* Cross platform
  - Windows and macOS. On Linux, menubar [isn't working correctly](https://github.com/electron/electron/issues/6773).

## How To Use

To clone and run this application, you'll need [Git](https://git-scm.com) and [Node.js](https://nodejs.org/en/download/) (which comes with [npm](http://npmjs.com)) installed on your computer. From your command line:

```bash
# Clone this repository
$ git clone https://github.com/amitmerchant1990/correo

# Go into the repository
$ cd correo

# Install dependencies
$ npm install

# Run the app
$ npm start
```

Note: If you're using Linux Bash for Windows, [see this guide](https://www.howtogeek.com/261575/how-to-run-graphical-linux-desktop-applications-from-windows-10s-bash-shell/) or use `node` from the command prompt.

## Download

Download the portable version of Correo for Windows, macOS and Linux from [here](https://github.com/amitmerchant1990/correo/releases/latest).

## Correo?

[Correo](http://www.spanishdict.com/translate/correo) means "mail" in Spanish.

## Credits

This software uses code from several open source packages.

- [Electron](http://electron.atom.io/)
- [Node.js](https://nodejs.org/)
- [menubar](https://github.com/maxogden/menubar)

### License

>The [MIT license](https://opensource.org/licenses/MIT) (MIT)
>
>Copyright (c) [Amit Merchant](https://www.amitmerchant.com/)
>
>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.

---

> [amitmerchant.com](https://www.amitmerchant.com)  ·
> GitHub [@amitmerchant1990](https://github.com/amitmerchant1990)  ·
> Twitter [@amit_merchant](https://twitter.com/amit_merchant)


text:
[//]: # (GENERATED FILE -- DO NOT EDIT!)
[//]: # (See scripts/release_notes.py for more details.)

## 1.4.2

- [#1289](https://github.com/grpc/grpc-web/pull/1289) Expose getName() in MethodDescriptor and fix TS definitions.
- [#1230](https://github.com/grpc/grpc-web/pull/1230) GrpcWebClientReadableStream: keep falsy data @pro-wh

## 1.4.1

- [#1286](https://github.com/grpc/grpc-web/pull/1286) Fix duplicate dot in enum name (when "package" is specified)

## 1.4.0

### Major Features

- [#1249](https://github.com/grpc/grpc-web/pull/1249) Use Zig to build aarch64 binaries @hronro
- [#1203](https://github.com/grpc/grpc-web/pull/1203) Github Actions (workflows) for building `protoc-gen-grpc-web` plugins

### Other Changes

- [#1279](https://github.com/grpc/grpc-web/pull/1279) Fixes the status codes ordering in typescript definitions @chandraaditya
- [#1278](https://github.com/grpc/grpc-web/pull/1278) Fix Enum with module in generated TS interface.
- [#1254](https://github.com/grpc/grpc-web/pull/1254) Remove Trailing Slashes from Hostname @jkjk822
- [#1252](https://github.com/grpc/grpc-web/pull/1252) Fix Zig setup step in CI @hronro
- [#1231](https://github.com/grpc/grpc-web/pull/1231) Add version flag and version info in generated code @meling
- [#1225](https://github.com/grpc/grpc-web/pull/1225) Improve error message & Internal code sync
- [#1222](https://github.com/grpc/grpc-web/pull/1222) Update envoy version to 1.22 (with config updates) @tomk9
- [#1211](https://github.com/grpc/grpc-web/pull/1211) Upgrade protobuf and grpc deps @aapeliv
- [#1199](https://github.com/grpc/grpc-web/pull/1199) Revert "Expose MethodDescriptor's public methods"

## 1.3.1

- [#1184](https://github.com/grpc/grpc-web/pull/1184) Correctly support proto3 optional fields in commonjs+dts .d.ts output @mattnathan
- [#1173](https://github.com/grpc/grpc-web/pull/1173) Update envoy version to 1.20
- [#1172](https://github.com/grpc/grpc-web/pull/1172) Fix issue where **no RPC is issued when `deadline` is specified.**
- [#1167](https://github.com/grpc/grpc-web/pull/1167) Fix missing TypeScript return type for `serverStreaming` calls. @lukasmoellerch
- [#1166](https://github.com/grpc/grpc-web/pull/1166) Add missing exports from `RpcError` and add test.
- [#1164](https://github.com/grpc/grpc-web/pull/1164) Add missing class exports @tinrab
- [#1160](https://github.com/grpc/grpc-web/pull/1160) Expose MethodDescriptor's public methods @tomferreira

## 1.3.0

### Major Features

- [#1139](https://github.com/grpc/grpc-web/pull/1139) Improve error type with `RpcError` & internal code sync (contributor: @TomiBelan)
  + (experimental) Typescript users need to update type references from `Error` -> `RpcError`

### Other Changes

- [#1140](https://github.com/grpc/grpc-web/pull/1140) Improve `RpcError.code` typing & internal code sync (contributor:  @richieforeman)
- [#1138](https://github.com/grpc/grpc-web/pull/1138) Remove Bazel in Javascript toolchain
- [#1137](https://github.com/grpc/grpc-web/pull/1137) Revamp Closure JsUnit tests runtime and optimize test/build flows.
- [#1115](https://github.com/grpc/grpc-web/pull/1115) Bump Bazel version -> 4.1.0 and Protobuf version -> 3.17.3
- [#1107](https://github.com/grpc/grpc-web/pull/1107) Allow for custom install prefix @06kellyjac
- [#1063](https://github.com/grpc/grpc-web/pull/1063) Also set timeout on HTTP request if deadline for grpc call is set @Yannic
- [#1004](https://github.com/grpc/grpc-web/pull/1004) Bump closure library version to v20201102
- [#1002](https://github.com/grpc/grpc-web/pull/1002) Bump Envoy version to 1.16.1
- [#998](https://github.com/grpc/grpc-web/pull/998) Fix GrpcWebClientBaseOptions types in index.d.ts @acalvo
- [#971](https://github.com/grpc/grpc-web/pull/971) Add grpc.web.ClientOptions to better document options and add type res... @jennnnny
- [#969](https://github.com/grpc/grpc-web/pull/969) Fix non-determinism in code generator
- [#941](https://github.com/grpc/grpc-web/pull/941) Fix Protobuf .d.ts typings for .proto files without package @Yannic

## 1.2.1

- [#910](https://github.com/grpc/grpc-web/pull/910) Add test to show how to access metadata in interceptor
- [#903](https://github.com/grpc/grpc-web/pull/903) Add error handling to a few error conditions
- [#886](https://github.com/grpc/grpc-web/pull/886) Add missing types definitions
- [#885](https://github.com/grpc/grpc-web/pull/885) Bump Envoy to 1.15.0
- [#884](https://github.com/grpc/grpc-web/pull/884) Update protoc plugin to support Proto3 optional
- [#882](https://github.com/grpc/grpc-web/pull/882) Add @interface MethodDescroptorInterface [@Jennnnny](https://github.com/Jennnnny)
- [#880](https://github.com/grpc/grpc-web/pull/880) Update Bazel to 3.3.1 [@Yannic](https://github.com/Yannic)
- [#874](https://github.com/grpc/grpc-web/pull/874) Add removeListener and missing metadata event types [@danielthank](https://github.com/danielthank)
- [#872](https://github.com/grpc/grpc-web/pull/872) [bazel] Introduce grpc_web_toolchain [@Yannic](https://github.com/Yannic)
- [#871](https://github.com/grpc/grpc-web/pull/871) [generator] Refactor dependency management [@Yannic](https://github.com/Yannic)
- [#869](https://github.com/grpc/grpc-web/pull/869) Add scripts to run interop-tests on grpc-web Java connector

## 1.2.0

### Major Features

- [#847](https://github.com/grpc/grpc-web/pull/847) Allow multiple .on() callbacks and fix issue with non-OK status

### Other Changes

- [#859](https://github.com/grpc/grpc-web/pull/859) Fix envoy.yaml deprecated fields [@dmaixner](https://github.com/dmaixner)
- [#858](https://github.com/grpc/grpc-web/pull/858) Refactor error handling in grpcwebclientbase
- [#857](https://github.com/grpc/grpc-web/pull/857) Migrate to ES6 classes
- [#852](https://github.com/grpc/grpc-web/pull/852) Update to use @grpc/grpc-js node package, and update helloworld exampl...
- [#851](https://github.com/grpc/grpc-web/pull/851) Add a ThenableCall base class for the promise-based unaryCall function [@Jennnnny](https://github.com/Jennnnny)
- [#844](https://github.com/grpc/grpc-web/pull/844) Fix code generator bug and add tests
- [#833](https://github.com/grpc/grpc-web/pull/833) Add proper author attribution to release notes / changelog
- [#827](https://github.com/grpc/grpc-web/pull/827) Splitting callback based client and Promise based client into multiple... [@Jennnnny](https://github.com/Jennnnny)
- [#822](https://github.com/grpc/grpc-web/pull/822) use explicit envoy release tag [@xsbchen](https://github.com/xsbchen)
- [#821](https://github.com/grpc/grpc-web/pull/821) Experimental Feature: Add ES6 import style [@Yannic](https://github.com/Yannic)
- [#738](https://github.com/grpc/grpc-web/pull/738) Avoid double slash in url when client hostname has tailing slash [@hanabi1224](https://github.com/hanabi1224)

## 1.1.0

### Major Features

- [#785](https://github.com/grpc/grpc-web/pull/785) grpc-web interceptors implementation [@Jennnnny](https://github.com/Jennnnny)
- [#772](https://github.com/grpc/grpc-web/pull/772) Add interop test spec and interop tests

### Other Changes

- [#818](https://github.com/grpc/grpc-web/pull/818) All java connector interop tests are passing now
- [#804](https://github.com/grpc/grpc-web/pull/804) Fix a bug in test: callback not properly intercepted
- [#801](https://github.com/grpc/grpc-web/pull/801) Trying to speed up tests
- [#797](https://github.com/grpc/grpc-web/pull/797) Split basic tests with interop tests
- [#780](https://github.com/grpc/grpc-web/pull/780) Add missing separator to imports from external files [@tomiaijo](https://github.com/tomiaijo)
- [#777](https://github.com/grpc/grpc-web/pull/777) Add .on(metadata,...) callback to distinguish initial metadata
- [#764](https://github.com/grpc/grpc-web/pull/764) [generator] Move options parsing into dedicated class [@Yannic](https://github.com/Yannic)
- [#761](https://github.com/grpc/grpc-web/pull/761) Update generic client [@Jennnnny](https://github.com/Jennnnny)
- [#756](https://github.com/grpc/grpc-web/pull/756) Add eval test for TypeScript generated code
- [#752](https://github.com/grpc/grpc-web/pull/752) Disable static checkers on generated js files [@IagoLast](https://github.com/IagoLast)
- [#747](https://github.com/grpc/grpc-web/pull/747) Enable builder pattern in Typescript protobuf messages. [@Orphis](https://github.com/Orphis)
- [#746](https://github.com/grpc/grpc-web/pull/746) Generate Promise based overloads for unary calls in Typescript [@Orphis](https://github.com/Orphis)
- [#745](https://github.com/grpc/grpc-web/pull/745) [bazel] Update rules_closure + fix linter warnings [@Yannic](https://github.com/Yannic)
- [#734](https://github.com/grpc/grpc-web/pull/734) Allow GrpcWebStreamParser to accept Uint8Array [@travikk](https://github.com/travikk)
- [#723](https://github.com/grpc/grpc-web/pull/723) Update bazel version
- [#720](https://github.com/grpc/grpc-web/pull/720) Fix grpcwebproxy interop
- [#716](https://github.com/grpc/grpc-web/pull/716) allow_origin is deprecated in latest envoy server [@noconnor](https://github.com/noconnor)
- [#695](https://github.com/grpc/grpc-web/pull/695) Fix issue 632 (double execution of callback) [@hfinger](https://github.com/hfinger)
- [#692](https://github.com/grpc/grpc-web/pull/692) Do not hardcode CXX to g++

## 1.0.7

- [#671](https://github.com/grpc/grpc-web/pull/671) Add metadata to error callback
- [#668](https://github.com/grpc/grpc-web/pull/668) Remove stream_body.proto
- [#665](https://github.com/grpc/grpc-web/pull/665) Add config for Bazel CI [@Yannic](https://github.com/Yannic)
- [#663](https://github.com/grpc/grpc-web/pull/663) nginx example Expose-Headers add Grpc-Message,Grpc-Status [@zsluedem](https://github.com/zsluedem)
- [#657](https://github.com/grpc/grpc-web/pull/657) Ensure that the end callback is called [@vbfox](https://github.com/vbfox)
- [#655](https://github.com/grpc/grpc-web/pull/655) Use closure compiler from npm in build.js [@vbfox](https://github.com/vbfox)
- [#654](https://github.com/grpc/grpc-web/pull/654) Ignore MacOS .DS_Store files [@vbfox](https://github.com/vbfox)
- [#652](https://github.com/grpc/grpc-web/pull/652) Fix error callback
- [#644](https://github.com/grpc/grpc-web/pull/644) Add CallOptions class [@Jennnnny](https://github.com/Jennnnny)
- [#641](https://github.com/grpc/grpc-web/pull/641) Add/update GOVERNANCE.md and CONTRIBUTING.md
- [#635](https://github.com/grpc/grpc-web/pull/635) Fix generated code return type, and remove unused var
- [#628](https://github.com/grpc/grpc-web/pull/628) Added API for simple unary call [@Jennnnny](https://github.com/Jennnnny)
- [#621](https://github.com/grpc/grpc-web/pull/621) Fix output directory name when using import_style=typescript [@asv](https://github.com/asv)
- [#619](https://github.com/grpc/grpc-web/pull/619) Return specific grpc status code on http error [@harmangakhal](https://github.com/harmangakhal)
- [#618](https://github.com/grpc/grpc-web/pull/618) Generate method descriptors into multiple files [@Jennnnny](https://github.com/Jennnnny)
- [#617](https://github.com/grpc/grpc-web/pull/617) Remove `enabled` deprecated field [@gsalisi](https://github.com/gsalisi)
- [#615](https://github.com/grpc/grpc-web/pull/615) Add support in code generator for printing only method descriptors [@Jennnnny](https://github.com/Jennnnny)
- [#608](https://github.com/grpc/grpc-web/pull/608) Fix status and error callbacks

## 1.0.6

- [#604](https://github.com/grpc/grpc-web/pull/604) Add option to set withCredentials to true
- [#603](https://github.com/grpc/grpc-web/pull/603) Adding some groundwork for generic client [@Jennnnny](https://github.com/Jennnnny)
- [#600](https://github.com/grpc/grpc-web/pull/600) Add generated code eval test
- [#599](https://github.com/grpc/grpc-web/pull/599) fix wrong package name of input type [@lqs](https://github.com/lqs)
- [#593](https://github.com/grpc/grpc-web/pull/593) Fix: Helloworld Example - Enabled Deprecation [@gary-lo](https://github.com/gary-lo)

## 1.0.5

- [#582](https://github.com/grpc/grpc-web/pull/582) Ensure credentials are not undefined in typescript [@Globegitter](https://github.com/Globegitter)
- [#579](https://github.com/grpc/grpc-web/pull/579) Uppercase enum keys in TypeScript definitions [@benfoxbotica](https://github.com/benfoxbotica)
- [#578](https://github.com/grpc/grpc-web/pull/578) Fix depset issues with/upgrade to Bazel 0.27.1 [@factuno-db](https://github.com/factuno-db)
- [#567](https://github.com/grpc/grpc-web/pull/567) Introducing MethodDescriptor [@Jennnnny](https://github.com/Jennnnny)
- [#559](https://github.com/grpc/grpc-web/pull/559) Adding new fields to MethodInfo [@Jennnnny](https://github.com/Jennnnny)
- [#556](https://github.com/grpc/grpc-web/pull/556) Add fix for deadline of strings, NaN, Infinity and -Infinity [@CatEars](https://github.com/CatEars)
- [#546](https://github.com/grpc/grpc-web/pull/546) Changes to deserializeBinary API
- [#540](https://github.com/grpc/grpc-web/pull/540) Method Derserializer should take Uint8Array [@pnegahdar](https://github.com/pnegahdar)
- [#519](https://github.com/grpc/grpc-web/pull/519) remove duplicated has$field$ method for oneof [@yangjian](https://github.com/yangjian)
- [#512](https://github.com/grpc/grpc-web/pull/512) Make client args `credentials` and `options` optional [@jonahbron](https://github.com/jonahbron)

## 1.0.4

- [#502](https://github.com/grpc/grpc-web/pull/502) Attempt to fix flakiness of 'bazel test' [@Yannic](https://github.com/Yannic)
- [#497](https://github.com/grpc/grpc-web/pull/497) Remove a return that skip emission of end callback [@tinou98](https://github.com/tinou98)
- [#494](https://github.com/grpc/grpc-web/pull/494) [bazel] Migrate protobuf info provider to new-style one [@Yannic](https://github.com/Yannic)
- [#482](https://github.com/grpc/grpc-web/pull/482) feature: Typings codegen for bytes field type [@shaxbee](https://github.com/shaxbee)
- [#481](https://github.com/grpc/grpc-web/pull/481) Add module alias to enums for Typescript [@rogchap](https://github.com/rogchap)
- [#460](https://github.com/grpc/grpc-web/pull/460) add typescript definition for Oneof fields [@yangjian](https://github.com/yangjian)
- [#452](https://github.com/grpc/grpc-web/pull/452) fix: exclude map entry message from typings, fix optional values [@shaxbee](https://github.com/shaxbee)
- [#448](https://github.com/grpc/grpc-web/pull/448) Export Map types correctly, optional getter/setters for message types [@shaxbee](https://github.com/shaxbee)
- [#444](https://github.com/grpc/grpc-web/pull/444) feature: Messages in typings extending jspb.Message [@shaxbee](https://github.com/shaxbee)
- [#433](https://github.com/grpc/grpc-web/pull/433) Match name nesting and imports in .d.ts with .js files [@shaxbee](https://github.com/shaxbee)
- [#430](https://github.com/grpc/grpc-web/pull/430) Use camelCase in AsObject definition [@johanbrandhorst](https://github.com/johanbrandhorst)
- [#429](https://github.com/grpc/grpc-web/pull/429) Fix type error in serverStreaming method [@johanbrandhorst](https://github.com/johanbrandhorst)
- [#427](https://github.com/grpc/grpc-web/pull/427) Promise function should use ES5 functions rather than fat arrows (IE b... [@rogchap](https://github.com/rogchap)
- [#422](https://github.com/grpc/grpc-web/pull/422) Enable ADVANCED_OPTIMIZATIONS in Closure Compiler [@jjbubudi](https://github.com/jjbubudi)
- [#421](https://github.com/grpc/grpc-web/pull/421) [bazel] Upgrade to 0.22.0 [@Yannic](https://github.com/Yannic)
- [#413](https://github.com/grpc/grpc-web/pull/413) Emit status event on empty stream response [@shaxbee](https://github.com/shaxbee)
- [#409](https://github.com/grpc/grpc-web/pull/409) Fix metadata typings for TS client [@bpicolo](https://github.com/bpicolo)
- [#404](https://github.com/grpc/grpc-web/pull/404) Generate Typescript definition for top level Enums [@rogchap](https://github.com/rogchap)

## 1.0.3

- [#391](https://github.com/grpc/grpc-web/pull/391) A script to compile protoc plugin
- [#385](https://github.com/grpc/grpc-web/pull/385) Codegen: Support nested types and enums [@shaxbee](https://github.com/shaxbee)
- [#368](https://github.com/grpc/grpc-web/pull/368) Make the bazel rules work with current rules_closure. [@factuno-db](https://github.com/factuno-db)
- [#367](https://github.com/grpc/grpc-web/pull/367) update examples to use addService [@mitchdraft](https://github.com/mitchdraft)
- [#365](https://github.com/grpc/grpc-web/pull/365) Fix response header value with colon
- [#362](https://github.com/grpc/grpc-web/pull/362) Fix the method name clashes for generated commonjs files  [@weilip1803](https://github.com/weilip1803)
- [#360](https://github.com/grpc/grpc-web/pull/360) Fix the import path for generated typescript files [@at-ishikawa](https://github.com/at-ishikawa)

## 1.0.2

## 1.0.1

- [#354](https://github.com/grpc/grpc-web/pull/354) [dts] Generate PromiseClient type definitions in d.ts file [@at-ishikawa](https://github.com/at-ishikawa)
- [#352](https://github.com/grpc/grpc-web/pull/352)  Add a max grpc timeout to the echo example.  [@mjduijn](https://github.com/mjduijn)
- [#348](https://github.com/grpc/grpc-web/pull/348) Fix output dts about 'repeated' for --grpc-web_out=import_style=common... [@rybbchao](https://github.com/rybbchao)
- [#345](https://github.com/grpc/grpc-web/pull/345) update typescript generation to work in strict mode [@henriiik](https://github.com/henriiik)
- [#330](https://github.com/grpc/grpc-web/pull/330) Use official rules_closure repository [@Yannic](https://github.com/Yannic)

## 1.0.0

- [#314](https://github.com/grpc/grpc-web/pull/314) Add a unit test for proto with no package
- [#313](https://github.com/grpc/grpc-web/pull/313) Show how deadline can be set
- [#311](https://github.com/grpc/grpc-web/pull/311) Document how to prevent Envoy to timeout streaming [@mitar](https://github.com/mitar)
- [#310](https://github.com/grpc/grpc-web/pull/310) Correctly generate code if package name is empty [@mitar](https://github.com/mitar)
- [#304](https://github.com/grpc/grpc-web/pull/304) Add a simple Hello World Guide
- [#303](https://github.com/grpc/grpc-web/pull/303) Error code should be number
- [#276](https://github.com/grpc/grpc-web/pull/276) Fix plugin compile error
- [#272](https://github.com/grpc/grpc-web/pull/272) Fix cpp warnings

## 0.4.0

- [#263](https://github.com/grpc/grpc-web/pull/263) Make "Quick" start quicker
- [#258](https://github.com/grpc/grpc-web/pull/258) Experimental Typescript support
- [#257](https://github.com/grpc/grpc-web/pull/257) Fix bug with button in example

## 0.3.0

- [#249](https://github.com/grpc/grpc-web/pull/249) Various fixes to codegen plugin
- [#247](https://github.com/grpc/grpc-web/pull/247) Add generated code unit test
- [#240](https://github.com/grpc/grpc-web/pull/240) webpack demo
- [#239](https://github.com/grpc/grpc-web/pull/239) Expose response metadata for unary calls
- [#219](https://github.com/grpc/grpc-web/pull/219) Add bazel rule closure_grpc_web_library [@Yannic](https://github.com/Yannic)
- [#217](https://github.com/grpc/grpc-web/pull/217) Added multiple proxies interoperability

## 0.2.0

- [#212](https://github.com/grpc/grpc-web/pull/212) Added commonjs-example Dockerfile
- [#211](https://github.com/grpc/grpc-web/pull/211) commonjs support with import_style option [@zaucy](https://github.com/zaucy)
- [#210](https://github.com/grpc/grpc-web/pull/210) grpcweb npm runtime module [@zaucy](https://github.com/zaucy)
- [#209](https://github.com/grpc/grpc-web/pull/209) Add bazel integration and tests
- [#206](https://github.com/grpc/grpc-web/pull/206) Surface underlying XHR errors better
- [#185](https://github.com/grpc/grpc-web/pull/185) Support for proto files without packages [@zaucy](https://github.com/zaucy)


text:
#include <aws/ecs/model/ListTasksResult.h>
#include <aws/core/utils/json/JsonSerializer.h>
#include <aws/core/AmazonWebServiceResult.h>
#include <aws/core/utils/StringUtils.h>
#include <aws/core/utils/UnreferencedParam.h>

#include <utility>

using namespace Aws::ECS::Model;
using namespace Aws::Utils::Json;
using namespace Aws::Utils;
using namespace Aws;

ListTasksResult::ListTasksResult()
{
}

ListTasksResult::ListTasksResult(const Aws::AmazonWebServiceResult<JsonValue>& result)
{
  *this = result;
}

ListTasksResult& ListTasksResult::operator =(const Aws::AmazonWebServiceResult<JsonValue>& result)
{
  JsonView jsonValue = result.GetPayload().View();
  if(jsonValue.ValueExists("taskArns"))
  {
    Array<JsonView> taskArnsJsonList = jsonValue.GetArray("taskArns");
    for(unsigned taskArnsIndex = 0; taskArnsIndex < taskArnsJsonList.GetLength(); ++taskArnsIndex)
    {
      m_taskArns.push_back(taskArnsJsonList[taskArnsIndex].AsString());
    }
  }

  if(jsonValue.ValueExists("nextToken"))
  {
    m_nextToken = jsonValue.GetString("nextToken");

  }

  return *this;
}


text:
@implementation NKWActivityIndicatorTwoDotsAnimation

- (UIImage *)drawImageWithSize:(CGSize)size center:(CGPoint)center tintColor:(UIColor *)tintColor
{
    CGFloat scale = [WKInterfaceDevice currentDevice].screenScale;

    UIGraphicsBeginImageContextWithOptions(size, false, scale);

    UIBezierPath *circlePath = [UIBezierPath bezierPath];
    CGFloat radius = MIN(size.width/2.0, size.height/2.0) / 2.0;
    [circlePath addArcWithCenter:center radius:radius startAngle:0 endAngle:2 * M_PI clockwise:YES];

    circlePath.lineWidth = 2.0;

    [tintColor setFill];
    [circlePath fill];
    [tintColor setStroke];
    [circlePath stroke];

    UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();

    return img;

}

- (void)setupAnimationInController:(WKInterfaceController*)controller Images:(NSArray*)images withSize:(CGSize)size tintColor:(UIColor *)tintColor duration:(CGFloat)duration
{

    NSAssert([images count] == 2, @"Two dots animation needs two images.");

    WKInterfaceImage *leftDotImage = (WKInterfaceImage *)[images objectAtIndex:0];
    WKInterfaceImage *rightDotImage = (WKInterfaceImage *)[images objectAtIndex:1];

    UIImage *leftDot = [self drawImageWithSize:size center:CGPointMake(size.width/2.0+14, size.height/2) tintColor:tintColor];
    UIImage *rightDot = [self drawImageWithSize:size center:CGPointMake(size.width/2.0-14, size.height/2) tintColor:tintColor];

    [leftDotImage setImage:leftDot];
    [rightDotImage setImage:rightDot];

    [leftDotImage setAlpha:0.0];
    [leftDotImage setWidth:0.0];
    [leftDotImage setHeight:0.0];
    [leftDotImage setVerticalAlignment:WKInterfaceObjectVerticalAlignmentCenter];
    [leftDotImage setHorizontalAlignment:WKInterfaceObjectHorizontalAlignmentRight];

    [rightDotImage setAlpha:1];
    [rightDotImage setWidth:size.width];
    [rightDotImage setHeight:size.height];
    [rightDotImage setVerticalAlignment:WKInterfaceObjectVerticalAlignmentCenter];
    [rightDotImage setHorizontalAlignment:WKInterfaceObjectHorizontalAlignmentLeft];

    [controller animateWithDuration:duration/2.0 animations:^{
        [leftDotImage setWidth:size.width];
        [leftDotImage setHeight:size.height];
        [leftDotImage setAlpha:1];

        [rightDotImage setAlpha:0.0];
        [rightDotImage setWidth:0.0];
        [rightDotImage setHeight:0.0];

        dispatch_time_t completionDelay = dispatch_time(DISPATCH_TIME_NOW, duration/2.0 *NSEC_PER_SEC);
        dispatch_after(completionDelay, dispatch_get_main_queue(), ^{

            [controller animateWithDuration:duration/2.0 animations:^{
                [leftDotImage setAlpha:0.0];
                [leftDotImage setWidth:0.0];
                [leftDotImage setHeight:0.0];

                [rightDotImage setAlpha:1];
                [rightDotImage setWidth:size.width];
                [rightDotImage setHeight:size.height];

            }];

        });

    }];
}

@end


text:
package org.wikipedia.dataclient.retrofit;

import android.support.annotation.NonNull;

import org.wikipedia.WikipediaApp;
import org.wikipedia.dataclient.WikiSite;
import org.wikipedia.dataclient.okhttp.OkHttpConnectionFactory;
import org.wikipedia.json.GsonUtil;

import java.io.IOException;

import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;

public final class RetrofitFactory {
    public static Retrofit newInstance(@NonNull WikiSite wiki) {
        return newInstance(wiki.url() + "/", wiki);
    }

    public static Retrofit newInstance(@NonNull String endpoint, @NonNull WikiSite wiki) {
        return new Retrofit.Builder()
                .client(OkHttpConnectionFactory.getClient().newBuilder()
                        .addInterceptor(new LanguageVariantHeaderInterceptor(wiki)).build())
                .baseUrl(endpoint)
                .addConverterFactory(GsonConverterFactory.create(GsonUtil.getDefaultGson()))
                .build();
    }

    private RetrofitFactory() { }

    private static class LanguageVariantHeaderInterceptor implements Interceptor {
        @NonNull private final WikiSite wiki;

        LanguageVariantHeaderInterceptor(@NonNull WikiSite wiki) {
            this.wiki = wiki;
        }

        @Override
        public Response intercept(Interceptor.Chain chain) throws IOException {
            Request request = chain.request();
            request = request.newBuilder()
                    .header("Accept-Language", WikipediaApp.getInstance().getAcceptLanguage(wiki))
                    .build();
            return chain.proceed(request);
        }
    }
}


text:
#include <folly/experimental/AutoTimer.h>

#include <folly/portability/GTest.h>

using namespace folly;
using namespace std;

struct StubLogger {
  void operator()(StringPiece msg, std::chrono::duration<double> sec) {
    m = msg.str();
    t = sec.count();
  }
  static std::string m;
  static double t;
};

std::string StubLogger::m = "";
double StubLogger::t = 0;

struct StubClock {
  typedef std::chrono::seconds duration;

  static std::chrono::time_point<StubClock> now() {
    return std::chrono::time_point<StubClock>(std::chrono::duration<int>(t));
  }
  static int t;
};

int StubClock::t = 0;

TEST(TestAutoTimer, HandleBasicClosure) {
  auto logger = [](StringPiece mesg, auto sec) {
    return StubLogger()(mesg, sec);
  };
  StubClock::t = 1;
  // Here decltype is needed. But since most users are expected to use this
  // method with the default clock, template specification won't be needed even
  // when they use a closure. See test case HandleRealTimerClosure
  auto timer = makeAutoTimer<decltype(logger), StubClock>(
      "", std::chrono::duration<double>::zero(), std::move(logger));
  StubClock::t = 3;
  timer.log("foo");
  ASSERT_EQ("foo", StubLogger::m);
  ASSERT_EQ(2, StubLogger::t);
  timer.logFormat(fmt::runtime("bar {}"), 5e-2);
  ASSERT_EQ("bar 0.05", StubLogger::m);
  ASSERT_EQ(0, StubLogger::t);
}

TEST(TestAutoTimer, HandleBasic) {
  StubClock::t = 1;
  AutoTimer<StubLogger, StubClock> timer;
  StubClock::t = 3;
  timer.log("foo");
  ASSERT_EQ("foo", StubLogger::m);
  ASSERT_EQ(2, StubLogger::t);
  timer.logFormat(fmt::runtime("bar {}"), 5e-2);
  ASSERT_EQ("bar 0.05", StubLogger::m);
  ASSERT_EQ(0, StubLogger::t);
}

TEST(TestAutoTimer, HandleLogOnDestruct) {
  {
    StubClock::t = 0;
    AutoTimer<StubLogger, StubClock> timer("message");
    StubClock::t = 3;
    timer.log("foo");
    EXPECT_EQ("foo", StubLogger::m);
    EXPECT_EQ(3, StubLogger::t);
    StubClock::t = 5;
  }
  ASSERT_EQ("message", StubLogger::m);
  ASSERT_EQ(2, StubLogger::t);
}

TEST(TestAutoTimer, HandleRealTimerClosure) {
  auto t = makeAutoTimer(
      "Third message on destruction",
      std::chrono::duration<double>::zero(),
      [](StringPiece mesg, auto sec) {
        GoogleLogger<GoogleLoggerStyle::PRETTY>()(mesg, sec);
      });
  t.log("First message");
  t.log("Second message");
}

TEST(TestAutoTimer, HandleRealTimer) {
  AutoTimer<> t("Third message on destruction");
  t.log("First message");
  t.log("Second message");
}

TEST(TestAutoTimer, HandleMinLogTime) {
  StubClock::t = 1;
  AutoTimer<StubLogger, StubClock> timer("", std::chrono::duration<double>(3));
  StubClock::t = 3;
  // only 2 "seconds" have passed, so this shouldn't log
  StubLogger::t = 0;
  ASSERT_EQ(std::chrono::duration<double>(2), timer.log("foo"));
  ASSERT_EQ(std::chrono::duration<double>::zero().count(), StubLogger::t);
}

TEST(TestAutoTimer, MovedObjectDestructionDoesntLog) {
  const std::vector<std::string> expectedMsgs = {
      "BEFORE_MOVE", "AFTER_MOVE", "END"};
  int32_t current = 0;
  SCOPE_EXIT { EXPECT_EQ(3, current); };

  auto timer = [&expectedMsgs, &current] {
    auto oldTimer = folly::makeAutoTimer(
        "END",
        std::chrono::duration<double>::zero(),
        [&expectedMsgs, &current](
            StringPiece msg, const std::chrono::duration<double>&) {
          EXPECT_EQ(expectedMsgs.at(current), msg);
          current++;
        });
    oldTimer.log("BEFORE_MOVE");
    auto newTimer = std::move(oldTimer); // force the move-ctor
    return newTimer;
  }();
  timer.log("AFTER_MOVE");
}


text:
/*
  ==============================================================================

    exFont.h
    Created: 25 Feb 2014 7:37:37pm
    Author:  pac

  ==============================================================================
*/

#pragma once

#include "typedefs.h"

PROTO_API pFont Font_new(const char *typefaceName, float fontHeight, int styleFlags, bool hinted)
{
	String stypefaceName = typefaceName;
	if (hinted)
		stypefaceName += "_hinted_";
	pFont f = { new Font(stypefaceName, fontHeight, styleFlags) };
	return f;
}

PROTO_API void Font_delete(pFont f)
{
	delete f.f;
}


text:
var AdRequest = require('./enums/AdRequest.js');
var Property = require('./ad/Property.js');
var Impression = require('./ad/Impression.js');
var Device = require('./ad/Device.js');
var User = require('./ad/User.js');
var JSONPayloadCreator = require('./JSONPayloadCreator.js')
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 //The top-level ad request is required to contain at least the site containing
 // the unique site ID, and the device containing the client IP address and user
 // agent information.

 // If you're using one of the classes under com.inmobi.monetization.ads to
 // request ads, you must provide a valid Request.
// @author Rishabh Chowdhary
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function Request(property,impression,device,user) {
		this.impression = impression;
		this.device = device;
		this.user = user;
		this.property = property;
		this.requestType = AdRequest.NONE;
}

Request.prototype.isValid = function() {
	valid = false;

	if(this.property != null && typeof(this.property) == "object" && this.property.isValid() == true) {
		if(this.device != null && typeof(this.device) == "object" && this.device.isValid() == true) {
			if(this.requestType == AdRequest.NATIVE)
				valid = true;
			else if (this.requestType == AdRequest.BANNER || this.requestType == AdRequest.INTERSTITIAL) {
				if(this.impression != null && typeof(this.impression) == "object" && this.impression.isValid()) {
					valid = true;
				}
			}
		}
	}
	return valid;
}

Request.prototype.toJSON = function() {
	if(this.isValid() == true) {
		return JSONPayloadCreator.fetchJSON(this);
	}
	return null;
}

module.exports = Request;


text:
#ifndef MANAGEDIALOG_HPP
#define MANAGEDIALOG_HPP

#include <QDialog>

namespace Ui {
	class ManageDialog;
}

class AlertModel;

class ManageDialog : public QDialog {
	Q_OBJECT

public:
	explicit ManageDialog(AlertModel *model, QWidget *parent = 0);
	~ManageDialog();

private slots:
	/**
	 * @brief Fill the fields with the details of a specific alert
	 *
	 * @param index QModelIndex of the alert in the model
	 */
	void updateAlertDetails(const QModelIndex &index);

	/**
	 * @brief Sets the content of the fields back to their original value
	 */
	void reset();

	/**
	 * @brief Update the model data with the values filled in the fields
	 */
	void updateModel();

	/**
	 * @brief The text in the label text edit changed
	 */
	void onLabelChanged();

	/**
	 * @brief The text in the description text edit changed
	 */
	void onDescriptionChanged();

	/**
	 * @brief The state of the repetitive check box changed
	 */
	void onRepetitiveChanged();

	/**
	 * @brief Removes the currently selected alert
	 */
	void removeAlert();

	void refreshDetails();

private:
	Ui::ManageDialog *_ui;

	AlertModel *_model;

	void updateButtonAvailability();

	bool _labelChanged;
	bool _descriptionChanged;
	bool _repetitiveChanged;
};

#endif // MANAGEDIALOG_HPP


text:
<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateStudentsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('students', function (Blueprint $table) {
            $table->increments('id');

            $table->integer('enrollment_number');
            $table->string('first_name');
            $table->string('last_name');
            $table->string('email')->unique();
            $table->integer('semester');

            $table->integer('university_id')->unsigned();
            $table->foreign('university_id')->references('id')->on('universities')->onDelete('cascade');

            $table->string('major');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::drop('students');
    }
}


text:
ACCEPTED

#### According to
Index Fungorum

#### Published in
null

#### Original name
Uromyces ligulariae Hirats. & Hoshioka {?}

### Remarks
null


text:
package com.facebook.buck.util;

import com.facebook.buck.io.file.MostFiles;
import java.io.Closeable;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.attribute.FileAttribute;

/** Creates a temporary directory that is (recursively) deleted when this object is closed. */
public class NamedTemporaryDirectory implements Closeable {
  private final Path path;

  public NamedTemporaryDirectory(String prefix, FileAttribute<?>... attrs) throws IOException {
    this.path = Files.createTempDirectory(prefix, attrs);
  }

  @Override
  public void close() throws IOException {
    MostFiles.deleteRecursively(path);
  }

  public Path getPath() {
    return path;
  }
}


text:
package xworker.org.apache.kafka.streams.processor;

import org.apache.kafka.streams.processor.RecordContext;
import org.apache.kafka.streams.processor.TopicNameExtractor;
import org.xmeta.ActionContext;
import org.xmeta.Thing;

public class ActionTopicNameExtractor implements TopicNameExtractor<Object, Object>{
	Thing thing;
	ActionContext actionContext;

	public ActionTopicNameExtractor(Thing thing, ActionContext actionContext) {
		this.thing = thing;
		this.actionContext = actionContext;
	}

	public static ActionTopicNameExtractor create(ActionContext actionContext) {
		Thing self = actionContext.getObject("self");

		return new ActionTopicNameExtractor(self, actionContext);
	}

	@Override
	public String extract(Object key, Object value, RecordContext recordContext) {
		return thing.getAction().run(actionContext, "key", key, "value", value, "recordContext", recordContext);
	}

}


text:
from __future__ import annotations

import unittest
from unittest import mock
from unittest.mock import MagicMock

import pytest

from airflow.exceptions import AirflowException
from airflow.models import DAG, DagBag
from airflow.providers.google.cloud.operators.looker import LookerStartPdtBuildOperator
from airflow.utils.timezone import datetime
from tests.test_utils.db import clear_db_runs, clear_db_xcom

OPERATOR_PATH = "airflow.providers.google.cloud.operators.looker.{}"

TASK_ID = "task-id"
LOOKER_CONN_ID = "test-conn"
MODEL = "test_model"
VIEW = "test_view"

TEST_DAG_ID = "test-looker-operators"
DEFAULT_DATE = datetime(2020, 1, 1)
TEST_JOB_ID = "123"

class LookerTestBase(unittest.TestCase):
    @classmethod
    def setUpClass(cls):
        cls.dagbag = DagBag(dag_folder="/dev/null", include_examples=False)
        cls.dag = DAG(TEST_DAG_ID, default_args={"owner": "airflow", "start_date": DEFAULT_DATE})

    def setUp(self):
        self.mock_ti = MagicMock()
        self.mock_context = {"ti": self.mock_ti}

    def tearDown(self):
        self.mock_ti = MagicMock()
        self.mock_context = {"ti": self.mock_ti}

    @classmethod
    def tearDownClass(cls):
        clear_db_runs()
        clear_db_xcom()

class TestLookerStartPdtBuildOperator(LookerTestBase):
    @mock.patch(OPERATOR_PATH.format("LookerHook"))
    def test_execute(self, mock_hook):
        # mock return vals from hook
        mock_hook.return_value.start_pdt_build.return_value.materialization_id = TEST_JOB_ID
        mock_hook.return_value.wait_for_job.return_value = None

        # run task in mock context (asynchronous=False)
        task = LookerStartPdtBuildOperator(
            task_id=TASK_ID,
            looker_conn_id=LOOKER_CONN_ID,
            model=MODEL,
            view=VIEW,
        )
        task.execute(context=self.mock_context)

        # assertions

        # hook's constructor called once
        mock_hook.assert_called_once_with(looker_conn_id=LOOKER_CONN_ID)

        # hook.start_pdt_build called once
        mock_hook.return_value.start_pdt_build.assert_called_once_with(
            model=MODEL,
            view=VIEW,
            query_params=None,
        )

        # hook.wait_for_job called once
        mock_hook.return_value.wait_for_job.assert_called_once_with(
            materialization_id=TEST_JOB_ID,
            wait_time=10,
            timeout=None,
        )

    @mock.patch(OPERATOR_PATH.format("LookerHook"))
    def test_execute_async(self, mock_hook):
        # mock return vals from hook
        mock_hook.return_value.start_pdt_build.return_value.materialization_id = TEST_JOB_ID
        mock_hook.return_value.wait_for_job.return_value = None

        # run task in mock context (asynchronous=True)
        task = LookerStartPdtBuildOperator(
            task_id=TASK_ID,
            looker_conn_id=LOOKER_CONN_ID,
            model=MODEL,
            view=VIEW,
            asynchronous=True,
        )
        task.execute(context=self.mock_context)

        # assertions

        # hook's constructor called once
        mock_hook.assert_called_once_with(looker_conn_id=LOOKER_CONN_ID)

        # hook.start_pdt_build called once
        mock_hook.return_value.start_pdt_build.assert_called_once_with(
            model=MODEL,
            view=VIEW,
            query_params=None,
        )

        # hook.wait_for_job NOT called
        mock_hook.return_value.wait_for_job.assert_not_called()

    @mock.patch(OPERATOR_PATH.format("LookerHook"))
    def test_on_kill(self, mock_hook):
        # mock return vals from hook
        mock_hook.return_value.start_pdt_build.return_value.materialization_id = TEST_JOB_ID
        mock_hook.return_value.wait_for_job.return_value = None

        # run task in mock context (cancel_on_kill=False)
        task = LookerStartPdtBuildOperator(
            task_id=TASK_ID,
            looker_conn_id=LOOKER_CONN_ID,
            model=MODEL,
            view=VIEW,
            cancel_on_kill=False,
        )
        task.execute(context=self.mock_context)

        # kill and assert build is NOT canceled
        task.on_kill()
        mock_hook.return_value.stop_pdt_build.assert_not_called()

        # alternatively, kill and assert build is canceled
        task.cancel_on_kill = True
        task.on_kill()
        mock_hook.return_value.stop_pdt_build.assert_called_once_with(materialization_id=TEST_JOB_ID)

    @mock.patch(OPERATOR_PATH.format("LookerHook"))
    def test_materialization_id_returned_as_empty_str(self, mock_hook):
        # mock return vals from hook
        mock_hook.return_value.start_pdt_build.return_value.materialization_id = ""
        mock_hook.return_value.wait_for_job.return_value = None

        # run task in mock context (asynchronous=False)
        task = LookerStartPdtBuildOperator(
            task_id=TASK_ID,
            looker_conn_id=LOOKER_CONN_ID,
            model=MODEL,
            view=VIEW,
        )

        # check AirflowException is raised
        with pytest.raises(
            AirflowException, match=f"No `materialization_id` was returned for model: {MODEL}, view: {VIEW}."
        ):
            task.execute(context=self.mock_context)


text:
.class public final Landroid/provider/Telephony$Sms$Sent;
.super Ljava/lang/Object;
.source "Telephony.java"

# interfaces
.implements Landroid/provider/BaseColumns;
.implements Landroid/provider/Telephony$TextBasedSmsColumns;

# annotations
.annotation system Ldalvik/annotation/EnclosingClass;
    value = Landroid/provider/Telephony$Sms;
.end annotation

.annotation system Ldalvik/annotation/InnerClass;
    accessFlags = 0x19
    name = "Sent"
.end annotation

# static fields
.field public static final CONTENT_URI:Landroid/net/Uri;

.field public static final DEFAULT_SORT_ORDER:Ljava/lang/String; = "date DESC"

# direct methods
.method static constructor <clinit>()V
    .locals 1

    .prologue
    .line 1053
    const-string v0, "content://sms/sent"

    invoke-static {v0}, Landroid/net/Uri;->parse(Ljava/lang/String;)Landroid/net/Uri;

    move-result-object v0

    sput-object v0, Landroid/provider/Telephony$Sms$Sent;->CONTENT_URI:Landroid/net/Uri;

    return-void
.end method

.method public constructor <init>()V
    .locals 0

    .prologue
    .line 1049
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    return-void
.end method

.method public static addMessage(JLandroid/content/ContentResolver;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Long;)Landroid/net/Uri;
    .locals 10
    .param p0, "subId"    # J
    .param p2, "resolver"    # Landroid/content/ContentResolver;
    .param p3, "address"    # Ljava/lang/String;
    .param p4, "body"    # Ljava/lang/String;
    .param p5, "subject"    # Ljava/lang/String;
    .param p6, "date"    # Ljava/lang/Long;

    .prologue
    .line 1092
    sget-object v3, Landroid/provider/Telephony$Sms$Sent;->CONTENT_URI:Landroid/net/Uri;

    const/4 v8, 0x1

    const/4 v9, 0x0

    move-wide v0, p0

    move-object v2, p2

    move-object v4, p3

    move-object v5, p4

    move-object v6, p5

    move-object/from16 v7, p6

    invoke-static/range {v0 .. v9}, Landroid/provider/Telephony$Sms;->addMessageToUri(JLandroid/content/ContentResolver;Landroid/net/Uri;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Long;ZZ)Landroid/net/Uri;

    move-result-object v0

    return-object v0
.end method

.method public static addMessage(JLandroid/content/ContentResolver;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Long;I)Landroid/net/Uri;
    .locals 14
    .param p0, "subId"    # J
    .param p2, "resolver"    # Landroid/content/ContentResolver;
    .param p3, "address"    # Ljava/lang/String;
    .param p4, "body"    # Ljava/lang/String;
    .param p5, "subject"    # Ljava/lang/String;
    .param p6, "date"    # Ljava/lang/Long;
    .param p7, "nIndexOnSim"    # I

    .prologue
    .line 1104
    sget-object v3, Landroid/provider/Telephony$Sms$Sent;->CONTENT_URI:Landroid/net/Uri;

    const/4 v8, 0x1

    const/4 v9, 0x0

    const-wide/16 v10, -0x1

    move-wide v0, p0

    move-object/from16 v2, p2

    move-object/from16 v4, p3

    move-object/from16 v5, p4

    move-object/from16 v6, p5

    move-object/from16 v7, p6

    move/from16 v12, p7

    invoke-static/range {v0 .. v12}, Landroid/provider/Telephony$Sms;->addMessageToUri(JLandroid/content/ContentResolver;Landroid/net/Uri;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Long;ZZJI)Landroid/net/Uri;

    move-result-object v0

    return-object v0
.end method

.method public static addMessage(JLandroid/content/ContentResolver;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Long;Ljava/lang/String;)Landroid/net/Uri;
    .locals 14
    .param p0, "subId"    # J
    .param p2, "resolver"    # Landroid/content/ContentResolver;
    .param p3, "address"    # Ljava/lang/String;
    .param p4, "body"    # Ljava/lang/String;
    .param p5, "subject"    # Ljava/lang/String;
    .param p6, "date"    # Ljava/lang/Long;
    .param p7, "sIndexes"    # Ljava/lang/String;

    .prologue
    .line 1116
    sget-object v3, Landroid/provider/Telephony$Sms$Sent;->CONTENT_URI:Landroid/net/Uri;

    const/4 v8, 0x1

    const/4 v9, 0x0

    const-wide/16 v10, -0x1

    move-wide v0, p0

    move-object/from16 v2, p2

    move-object/from16 v4, p3

    move-object/from16 v5, p4

    move-object/from16 v6, p5

    move-object/from16 v7, p6

    move-object/from16 v12, p7

    invoke-static/range {v0 .. v12}, Landroid/provider/Telephony$Sms;->addMessageToUri(JLandroid/content/ContentResolver;Landroid/net/Uri;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Long;ZZJLjava/lang/String;)Landroid/net/Uri;

    move-result-object v0

    return-object v0
.end method

.method public static addMessage(JLandroid/content/ContentResolver;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Long;Ljava/lang/String;I)Landroid/net/Uri;
    .locals 14
    .param p0, "subId"    # J
    .param p2, "resolver"    # Landroid/content/ContentResolver;
    .param p3, "address"    # Ljava/lang/String;
    .param p4, "body"    # Ljava/lang/String;
    .param p5, "subject"    # Ljava/lang/String;
    .param p6, "date"    # Ljava/lang/Long;
    .param p7, "sIndexes"    # Ljava/lang/String;
    .param p8, "phonetype"    # I

    .prologue
    .line 1128
    sget-object v3, Landroid/provider/Telephony$Sms$Sent;->CONTENT_URI:Landroid/net/Uri;

    const/4 v8, 0x1

    const/4 v9, 0x0

    const-wide/16 v10, -0x1

    move-wide v0, p0

    move-object/from16 v2, p2

    move-object/from16 v4, p3

    move-object/from16 v5, p4

    move-object/from16 v6, p5

    move-object/from16 v7, p6

    move-object/from16 v12, p7

    move/from16 v13, p8

    invoke-static/range {v0 .. v13}, Landroid/provider/Telephony$Sms;->addMessageToUri(JLandroid/content/ContentResolver;Landroid/net/Uri;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Long;ZZJLjava/lang/String;I)Landroid/net/Uri;

    move-result-object v0

    return-object v0
.end method

.method public static addMessage(Landroid/content/ContentResolver;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Long;)Landroid/net/Uri;
    .locals 10
    .param p0, "resolver"    # Landroid/content/ContentResolver;
    .param p1, "address"    # Ljava/lang/String;
    .param p2, "body"    # Ljava/lang/String;
    .param p3, "subject"    # Ljava/lang/String;
    .param p4, "date"    # Ljava/lang/Long;

    .prologue
    .line 1074
    invoke-static {}, Landroid/telephony/SubscriptionManager;->getDefaultSmsSubId()J

    move-result-wide v0

    sget-object v3, Landroid/provider/Telephony$Sms$Sent;->CONTENT_URI:Landroid/net/Uri;

    const/4 v8, 0x1

    const/4 v9, 0x0

    move-object v2, p0

    move-object v4, p1

    move-object v5, p2

    move-object v6, p3

    move-object v7, p4

    invoke-static/range {v0 .. v9}, Landroid/provider/Telephony$Sms;->addMessageToUri(JLandroid/content/ContentResolver;Landroid/net/Uri;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Long;ZZ)Landroid/net/Uri;

    move-result-object v0

    return-object v0
.end method

.method public static addMessage(Landroid/content/ContentResolver;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Long;I)Landroid/net/Uri;
    .locals 13
    .param p0, "resolver"    # Landroid/content/ContentResolver;
    .param p1, "address"    # Ljava/lang/String;
    .param p2, "body"    # Ljava/lang/String;
    .param p3, "subject"    # Ljava/lang/String;
    .param p4, "date"    # Ljava/lang/Long;
    .param p5, "nIndexOnSim"    # I

    .prologue
    .line 1099
    invoke-static {}, Landroid/telephony/SubscriptionManager;->getDefaultSmsSubId()J

    move-result-wide v0

    sget-object v3, Landroid/provider/Telephony$Sms$Sent;->CONTENT_URI:Landroid/net/Uri;

    const/4 v8, 0x1

    const/4 v9, 0x0

    const-wide/16 v10, -0x1

    move-object v2, p0

    move-object v4, p1

    move-object v5, p2

    move-object/from16 v6, p3

    move-object/from16 v7, p4

    move/from16 v12, p5

    invoke-static/range {v0 .. v12}, Landroid/provider/Telephony$Sms;->addMessageToUri(JLandroid/content/ContentResolver;Landroid/net/Uri;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Long;ZZJI)Landroid/net/Uri;

    move-result-object v0

    return-object v0
.end method

.method public static addMessage(Landroid/content/ContentResolver;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Long;Ljava/lang/String;)Landroid/net/Uri;
    .locals 13
    .param p0, "resolver"    # Landroid/content/ContentResolver;
    .param p1, "address"    # Ljava/lang/String;
    .param p2, "body"    # Ljava/lang/String;
    .param p3, "subject"    # Ljava/lang/String;
    .param p4, "date"    # Ljava/lang/Long;
    .param p5, "sIndexes"    # Ljava/lang/String;

    .prologue
    .line 1111
    invoke-static {}, Landroid/telephony/SubscriptionManager;->getDefaultSmsSubId()J

    move-result-wide v0

    sget-object v3, Landroid/provider/Telephony$Sms$Sent;->CONTENT_URI:Landroid/net/Uri;

    const/4 v8, 0x1

    const/4 v9, 0x0

    const-wide/16 v10, -0x1

    move-object v2, p0

    move-object v4, p1

    move-object v5, p2

    move-object/from16 v6, p3

    move-object/from16 v7, p4

    move-object/from16 v12, p5

    invoke-static/range {v0 .. v12}, Landroid/provider/Telephony$Sms;->addMessageToUri(JLandroid/content/ContentResolver;Landroid/net/Uri;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Long;ZZJLjava/lang/String;)Landroid/net/Uri;

    move-result-object v0

    return-object v0
.end method

.method public static addMessage(Landroid/content/ContentResolver;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Long;Ljava/lang/String;I)Landroid/net/Uri;
    .locals 14
    .param p0, "resolver"    # Landroid/content/ContentResolver;
    .param p1, "address"    # Ljava/lang/String;
    .param p2, "body"    # Ljava/lang/String;
    .param p3, "subject"    # Ljava/lang/String;
    .param p4, "date"    # Ljava/lang/Long;
    .param p5, "sIndexes"    # Ljava/lang/String;
    .param p6, "phonetype"    # I

    .prologue
    .line 1123
    invoke-static {}, Landroid/telephony/SubscriptionManager;->getDefaultSmsSubId()J

    move-result-wide v0

    sget-object v3, Landroid/provider/Telephony$Sms$Sent;->CONTENT_URI:Landroid/net/Uri;

    const/4 v8, 0x1

    const/4 v9, 0x0

    const-wide/16 v10, -0x1

    move-object v2, p0

    move-object v4, p1

    move-object/from16 v5, p2

    move-object/from16 v6, p3

    move-object/from16 v7, p4

    move-object/from16 v12, p5

    move/from16 v13, p6

    invoke-static/range {v0 .. v13}, Landroid/provider/Telephony$Sms;->addMessageToUri(JLandroid/content/ContentResolver;Landroid/net/Uri;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Long;ZZJLjava/lang/String;I)Landroid/net/Uri;

    move-result-object v0

    return-object v0
.end method

.method public static addSIMMessage(JLandroid/content/ContentResolver;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Long;JIII)Landroid/net/Uri;
    .locals 15
    .param p0, "subId"    # J
    .param p2, "resolver"    # Landroid/content/ContentResolver;
    .param p3, "address"    # Ljava/lang/String;
    .param p4, "body"    # Ljava/lang/String;
    .param p5, "subject"    # Ljava/lang/String;
    .param p6, "date"    # Ljava/lang/Long;
    .param p7, "threadId"    # J
    .param p9, "simsms"    # I
    .param p10, "simindex"    # I
    .param p11, "phoneType"    # I

    .prologue
    .line 1155
    sget-object v3, Landroid/provider/Telephony$Sms$Sent;->CONTENT_URI:Landroid/net/Uri;

    const/4 v8, 0x1

    const/4 v9, 0x0

    move-wide v0, p0

    move-object/from16 v2, p2

    move-object/from16 v4, p3

    move-object/from16 v5, p4

    move-object/from16 v6, p5

    move-object/from16 v7, p6

    move-wide/from16 v10, p7

    move/from16 v12, p9

    move/from16 v13, p10

    move/from16 v14, p11

    invoke-static/range {v0 .. v14}, Landroid/provider/Telephony$Sms;->addSIMMessageToUri(JLandroid/content/ContentResolver;Landroid/net/Uri;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Long;ZZJIII)Landroid/net/Uri;

    move-result-object v0

    return-object v0
.end method

.method public static addSIMMessage(Landroid/content/ContentResolver;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Long;JIII)Landroid/net/Uri;
    .locals 15
    .param p0, "resolver"    # Landroid/content/ContentResolver;
    .param p1, "address"    # Ljava/lang/String;
    .param p2, "body"    # Ljava/lang/String;
    .param p3, "subject"    # Ljava/lang/String;
    .param p4, "date"    # Ljava/lang/Long;
    .param p5, "threadId"    # J
    .param p7, "simsms"    # I
    .param p8, "simindex"    # I
    .param p9, "phoneType"    # I

    .prologue
    .line 1150
    invoke-static {}, Landroid/telephony/SubscriptionManager;->getDefaultSmsSubId()J

    move-result-wide v0

    sget-object v3, Landroid/provider/Telephony$Sms$Sent;->CONTENT_URI:Landroid/net/Uri;

    const/4 v8, 0x1

    const/4 v9, 0x0

    move-object v2, p0

    move-object/from16 v4, p1

    move-object/from16 v5, p2

    move-object/from16 v6, p3

    move-object/from16 v7, p4

    move-wide/from16 v10, p5

    move/from16 v12, p7

    move/from16 v13, p8

    move/from16 v14, p9

    invoke-static/range {v0 .. v14}, Landroid/provider/Telephony$Sms;->addSIMMessageToUri(JLandroid/content/ContentResolver;Landroid/net/Uri;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Long;ZZJIII)Landroid/net/Uri;

    move-result-object v0

    return-object v0
.end method


text:
/* Generated By:JJTree: Do not edit this line. OJson.java Version 4.3 */
/* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=true,NODE_PREFIX=O,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
package com.orientechnologies.orient.core.sql.parser;

import com.orientechnologies.orient.core.command.OCommandContext;
import com.orientechnologies.orient.core.db.record.OIdentifiable;
import com.orientechnologies.orient.core.record.impl.ODocument;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class OJson extends SimpleNode {

  protected List<OJsonItem> items = new ArrayList<OJsonItem>();

  public OJson(int id) {
    super(id);
  }

  public OJson(OrientSql p, int id) {
    super(p, id);
  }

  /**
   * Accept the visitor. *
   */
  public Object jjtAccept(OrientSqlVisitor visitor, Object data) {
    return visitor.visit(this, data);
  }

  public void toString(Map<Object, Object> params, StringBuilder builder) {
    builder.append("{");
    boolean first = true;
    for (OJsonItem item : items) {
      if (!first) {
        builder.append(", ");
      }
      item.toString(params, builder);

      first = false;
    }
    builder.append("}");
  }

  public ODocument toDocument(OIdentifiable source, OCommandContext ctx) {
    String className = getClassNameForDocument(ctx);
    ODocument doc;
    if (className != null) {
      doc = new ODocument(className);
    } else {
      doc = new ODocument();
    }
    for (OJsonItem item : items) {
      String name = item.getLeftValue();
      if (name == null) {
        continue;
      }
      Object value;
      if (item.right.value instanceof OJson) {
        value = ((OJson) item.right.value).toDocument(source, ctx);
      } else {
        value = item.right.execute(source, ctx);
      }
      doc.field(name, value);
    }

    return doc;
  }

  public Map<String, Object> toMap(OIdentifiable source, OCommandContext ctx) {
    String className = getClassNameForDocument(ctx);
    Map<String, Object> doc = new HashMap<String, Object>();
    for (OJsonItem item : items) {
      String name = item.getLeftValue();
      if (name == null) {
        continue;
      }
      Object value = item.right.execute(source, ctx);
      doc.put(name, value);
    }

    return doc;
  }

  private String getClassNameForDocument(OCommandContext ctx) {
    for (OJsonItem item : items) {
      String left = item.getLeftValue();
      if (left.toLowerCase().equals("@class")) {
        return "" + item.right.execute(null, ctx);
      }
    }
    return null;
  }
}
/* JavaCC - OriginalChecksum=3beec9f6db486de944498588b51a505d (do not edit this line) */


text:
package render

import "net/http"

type Renderer interface {
	Render(w http.ResponseWriter, r *http.Request, status int, data interface{}) error
}