Package io.crate.metadata

Examples of io.crate.metadata.ColumnIdent


    }

    @Nullable
    private AnalyzedColumnDefinition columnDefinitionByIdent(ColumnIdent ident, boolean removeIfFound) {
        AnalyzedColumnDefinition result = null;
        ColumnIdent root = ident.getRoot();
        for (AnalyzedColumnDefinition column : columns) {
            if (column.ident().equals(root)) {
                result = column;
                break;
            }
View Full Code Here


            Expression expression = values.get(i);
            Symbol valuesSymbol = process(expression, context);

            // implicit type conversion
            Reference column = context.columns().get(i);
            final ColumnIdent columnIdent = column.info().ident().columnIdent();
            try {
                valuesSymbol = context.normalizeInputForReference(valuesSymbol, column, true);
            } catch (IllegalArgumentException | UnsupportedOperationException e) {
                throw new ColumnValidationException(column.info().ident().columnIdent().fqn(), e);
            }
            try {
                Object value = ((Input) valuesSymbol).value();
                if (context.primaryKeyColumnIndices().contains(i)) {
                    int idx = primaryKey.indexOf(columnIdent);
                    if (idx < 0) {
                        // oh look, one or more nested primary keys!
                        assert value instanceof Map;
                        for (ColumnIdent pkIdent : primaryKey) {
                            if (!pkIdent.getRoot().equals(columnIdent)) {
                                continue;
                            }
                            int pkIdx = primaryKey.indexOf(pkIdent);
                            Object nestedValue = StringObjectMaps.fromMapByPath((Map) value, pkIdent.path());
                            addPrimaryKeyValue(pkIdx, nestedValue, primaryKeyValues);
                        }
                    } else {
                        addPrimaryKeyValue(idx, value, primaryKeyValues);
                    }
                }
                if (i == context.routingColumnIndex()) {
                    routingValue = extractRoutingValue(columnIdent, value, context);
                }
                if (context.partitionedByIndices().contains(i)) {
                    Object rest = processPartitionedByValues(columnIdent, value, context);
                    if (rest != null) {
                        builder.field(columnIdent.name(), rest);
                    }
                } else {
                    if (value instanceof BytesRef) {
                        value = new BytesText(new BytesArray((BytesRef) value));
                    }
                    builder.field(columnIdent.name(), value);
                }
            } catch (ClassCastException e) {
                // symbol is no input
                throw new ColumnValidationException(columnIdent.name(),
                        String.format("invalid value '%s' in insert statement", valuesSymbol.toString()));
            }
        }
        context.sourceMaps().add(builder.bytes());
        context.addIdAndRouting(primaryKeyValues, routingValue);
View Full Code Here

        }
    }

    private String extractRoutingValue(ColumnIdent columnIdent, Object columnValue, InsertFromValuesAnalysis context) {
        Object clusteredByValue = columnValue;
        ColumnIdent clusteredByIdent = context.table().clusteredBy();
        if (!columnIdent.equals(clusteredByIdent)) {
            // oh my gosh! A nested clustered by value!!!
            assert clusteredByValue instanceof Map;
            clusteredByValue = StringObjectMaps.fromMapByPath((Map) clusteredByValue, clusteredByIdent.path());
        }
        if (clusteredByValue == null) {
            throw new IllegalArgumentException("Clustered by value must not be NULL");
        }
        return BytesRefs.toString(clusteredByValue);
View Full Code Here

        }

        int numPks = in.readVInt();
        primaryKeys = new ArrayList<>(numPks);
        for (int i = 0; i < numPks; i++) {
            ColumnIdent ident = new ColumnIdent();
            ident.readFrom(in);
            primaryKeys.add(ident);
        }

        int numPartitionedSymbols = in.readVInt();
        partitionedBySymbols = new ArrayList<>(numPartitionedSymbols);
        for (int i = 0; i < numPartitionedSymbols; i++) {
            partitionedBySymbols.add(Symbol.fromStream(in));
        }
        if (in.readBoolean()) {
            clusteredBySymbol = Symbol.fromStream(in);
        } else {
            clusteredBySymbol = null;
        }
        if (in.readBoolean()) {
            ColumnIdent ident = new ColumnIdent();
            ident.readFrom(in);
            clusteredByColumn = ident;
        }
        bulkActions = in.readVInt();
        autoCreateIndices = in.readBoolean();
    }
View Full Code Here

            }
        }

        @Override
        public Void visitReference(Reference symbol, OutputContext context) {
            ColumnIdent columnIdent = symbol.info().ident().columnIdent();
            if (columnIdent.isSystemColumn()) {
                if (DocSysColumns.VERSION.equals(columnIdent)) {
                    context.searchContext.version(true);
                } else {
                    context.needWholeSource = true;
                }
            } else if (!context.partitionBy.contains(symbol.info())) {
                context.fields.add(columnIdent.fqn());
            }
            return null;
        }
View Full Code Here

            // can't use the SortField(fieldName, type) constructor
            // because values are saved using docValues and therefore they're indexed in lucene as binary and not
            // with the reference valueType.
            // this is why we use a custom comparator source with the same logic as ES

            ColumnIdent columnIdent = symbol.info().ident().columnIdent();
            if (columnIdent.isColumn() && SortParseElement.SCORE_FIELD_NAME.equals(columnIdent.name())) {
                return !context.reverseFlag ? SortParseElement.SORT_SCORE_REVERSE : SortParseElement.SORT_SCORE;
            }

            MultiValueMode sortMode = context.reverseFlag ? MultiValueMode.MAX : MultiValueMode.MIN;
            SearchContext searchContext = context.context.searchContext();

            FieldMapper fieldMapper = context.context.searchContext().smartNameFieldMapper(columnIdent.fqn());
            SortOrder sortOrder = new SortOrder(context.reverseFlag, context.nullFirst);
            IndexFieldData.XFieldComparatorSource fieldComparatorSource =
                    searchContext.fieldData().getForField(fieldMapper).comparatorSource(sortOrder.missing(), sortMode);

            return new SortField(
View Full Code Here

public abstract class SysShardExpression<T> extends SysExpression<T> implements ShardReferenceImplementation {

    private final ReferenceInfo info;

    protected SysShardExpression(String name) {
        this(new ColumnIdent(name));
    }
View Full Code Here

    protected void configure() {
        MapBinder<ReferenceIdent, ShardReferenceImplementation> b = MapBinder
                .newMapBinder(binder(), ReferenceIdent.class, ShardReferenceImplementation.class);

        Map<ColumnIdent, ReferenceInfo> infos = SysShardsTableInfo.INFOS;
        b.addBinding(infos.get(new ColumnIdent(ShardIdExpression.NAME)).ident()).to(ShardIdExpression.class).asEagerSingleton();
        b.addBinding(infos.get(new ColumnIdent(ShardSizeExpression.NAME)).ident()).to(ShardSizeExpression.class).asEagerSingleton();
        b.addBinding(infos.get(new ColumnIdent(ShardNumDocsExpression.NAME)).ident()).to(ShardNumDocsExpression.class).asEagerSingleton();
        b.addBinding(infos.get(new ColumnIdent(ShardPrimaryExpression.NAME)).ident()).to(ShardPrimaryExpression.class).asEagerSingleton();
        b.addBinding(infos.get(new ColumnIdent(ShardStateExpression.NAME)).ident()).to(ShardStateExpression.class).asEagerSingleton();
        b.addBinding(infos.get(new ColumnIdent(ShardRelocatingNodeExpression.NAME)).ident()).to(ShardRelocatingNodeExpression.class).asEagerSingleton();
        b.addBinding(infos.get(new ColumnIdent(ShardTableNameExpression.NAME)).ident()).to(ShardTableNameExpression.class).asEagerSingleton();
        b.addBinding(infos.get(new ColumnIdent(ShardSchemaNameExpression.NAME)).ident()).to(ShardSchemaNameExpression.class).asEagerSingleton();
        b.addBinding(infos.get(new ColumnIdent(ShardPartitionIdentExpression.NAME)).ident()).to(ShardPartitionIdentExpression.class).asEagerSingleton();
        b.addBinding(infos.get(new ColumnIdent(ShardPartitionOrphanedExpression.NAME)).ident()).to(ShardPartitionOrphanedExpression.class).asEagerSingleton();
    }
View Full Code Here

    private final ReferenceInfo info;
    protected UnassignedShard row;

    protected UnassignedShardCollectorExpression(String name) {
        this.info = SysShardsTableInfo.INFOS.get(new ColumnIdent(name));
    }
View Full Code Here

        MapBinder<ReferenceIdent, BlobShardReferenceImplementation> binder = MapBinder
                .newMapBinder(binder(), ReferenceIdent.class, BlobShardReferenceImplementation.class);
        if (settings.getAsBoolean(BlobIndices.SETTING_INDEX_BLOBS_ENABLED, false)){

            Map<ColumnIdent, ReferenceInfo> infos = SysShardsTableInfo.INFOS;
            binder.addBinding(infos.get(new ColumnIdent(BlobShardIdExpression.NAME)).ident()).to(BlobShardIdExpression.class).asEagerSingleton();
            binder.addBinding(infos.get(new ColumnIdent(BlobShardNumDocsExpression.NAME)).ident()).to(BlobShardNumDocsExpression.class).asEagerSingleton();
            binder.addBinding(infos.get(new ColumnIdent(BlobShardPrimaryExpression.NAME)).ident()).to(BlobShardPrimaryExpression.class).asEagerSingleton();
            binder.addBinding(infos.get(new ColumnIdent(BlobShardRelocatingNodeExpression.NAME)).ident()).to(BlobShardRelocatingNodeExpression.class).asEagerSingleton();
            binder.addBinding(infos.get(new ColumnIdent(BlobShardSchemaNameExpression.NAME)).ident()).to(BlobShardSchemaNameExpression.class).asEagerSingleton();
            binder.addBinding(infos.get(new ColumnIdent(BlobShardSizeExpression.NAME)).ident()).to(BlobShardSizeExpression.class).asEagerSingleton();
            binder.addBinding(infos.get(new ColumnIdent(BlobShardStateExpression.NAME)).ident()).to(BlobShardStateExpression.class).asEagerSingleton();
            binder.addBinding(infos.get(new ColumnIdent(BlobShardTableNameExpression.NAME)).ident()).to(BlobShardTableNameExpression.class).asEagerSingleton();
            binder.addBinding(infos.get(new ColumnIdent(BlobShardPartitionIdentExpression.NAME)).ident()).to(BlobShardPartitionIdentExpression.class).asEagerSingleton();
            binder.addBinding(infos.get(new ColumnIdent(BlobShardPartitionOrphanedExpression.NAME)).ident()).to(BlobShardPartitionOrphanedExpression.class).asEagerSingleton();

        }
    }
View Full Code Here

TOP

Related Classes of io.crate.metadata.ColumnIdent

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.