Package com.foundationdb.ais.model

Examples of com.foundationdb.ais.model.Column


        boolean sawRename = false;
        Iterator<JoinColumn> oldIt = oldJoin.getJoinColumns().iterator();
        Iterator<JoinColumn> newIt = newJoin.getJoinColumns().iterator();
        while(oldIt.hasNext()) {
            Column oldCol = oldIt.next().getChild();
            String newName = findNewName(columnChanges, newIt.next().getChild().getName());
            if(newName == null) {
                return ParentChange.DROP;
            } else {
                Column newCol = newJoin.getChild().getColumn(newName);
                if(compare(oldCol, newCol) == ChangeLevel.TABLE) {
                    return ParentChange.DROP;
                } else if(!oldCol.getName().equals(newName)) {
                    sawRename = true;
                }
View Full Code Here


            column.getType().writeCollating(source, target);
        }

        public void append(FieldDef fieldDef, RowData rowData) {
            fromRowDataSource.bind(fieldDef, rowData);
            Column column = fieldDef.column();
            column.getType().writeCollating(fromRowDataSource, target);
        }
View Full Code Here

            conversions = new ProtobufRowConversion[nfields];
            fields = new FieldDescriptor[nfields];
            columnIndexesByField = new HashMap<>(nfields);
            Map<String,Integer> columnIndexedByUuid = new HashMap<>(nfields);
            for (int i = 0; i < nfields; i++) {
                Column column = table.getColumnsIncludingInternal().get(i);
                conversions[i] = ProtobufRowConversion.forTInstance(column.getType());
                columnIndexedByUuid.put(column.getUuid().toString(), i);
            }
            FieldDescriptor[] nullFields = null;
            Map<FieldDescriptor,Integer> nullableIndexesByField = null;
            for (FieldDescriptor field : tableMessage.getFields()) {
                ColumnOptions options = field.getOptions().getExtension(ColumnOptions.fdbsql);
View Full Code Here

            else {
                int offset = i;
                if (i > firstSpatialColumn) {
                    offset += index.dimensions() - 1;
                }
                Column column = index.getKeyColumns().get(firstColumn + offset).getColumn();
                type = column.getType();
                AkCollator collator = column.getCollator();
                useRawSegment = ((collator != null) && !collator.isRecoverable());
            }
            Object keyValue;
            if (useRawSegment) {
                keyValue = getRawSegment(key, i);
View Full Code Here

        // Fill in input values
        Iterator<Column> colIt = inputColumns.iterator();
        TableRowType targetRowType = schema().tableRowType(table);
        TPreparedExpression[] row = new TPreparedExpression[targetRowType.nFields()];
        for (int i = 0; i < inputColumns.size(); i++) {
            Column column = colIt.next();
            TInstance type = column.getType();
            int pos = column.getPosition();
            row[pos] = insertExprs.get(i);
            if(!type.equals(row[pos].resultType())) {
                TCast tcast = registryService().getCastsResolver().cast(row[pos].resultType().typeClass(),
                                                                        type.typeClass());
                row[pos] = new TCastExpression(row[pos], tcast, type);
            }
        }
        // Fill in column defaults
        for(int i = 0, len = targetRowType.nFields(); i < len; ++i) {
            Column column = table.getColumnsIncludingInternal().get(i);
            row[i] = PlanGenerator.generateDefaultExpression(column,
                                                             row[i],
                                                             registryService(),
                                                             getTypesTranslator(),
                                                             queryContext());
View Full Code Here

                        }
                    }
                    return null;
                }

                Column column = columnIt.next();

                Long precision = null;
                Long scale = null;
                Long radix = null;
                String charset = null;
                String collation = null;
                if (column.getType().hasAttributes(DecimalAttribute.class)) {
                    precision = (long) column.getType().attribute(DecimalAttribute.PRECISION);
                    scale = (long) column.getType().attribute(DecimalAttribute.SCALE);
                    radix = 10L;
                }
                Long charMaxLength = null;
                Long charOctetLength = null;
                if (column.hasCharsetAndCollation()) {
                    charset = column.getCharsetName().toLowerCase();
                    collation = column.getCollationName().toLowerCase();
                }
                if (column.getType().hasAttributes(StringAttribute.class)) {
                    charMaxLength = (long) column.getType().attribute(StringAttribute.MAX_LENGTH);
                    charOctetLength = column.getMaxStorageSize() - column.getPrefixSize();
                }
                else if (column.getType().hasAttributes(TBinary.Attrs.class)) {
                    charMaxLength = charOctetLength = (long) column.getType().attribute(TBinary.Attrs.LENGTH);
                }
                String sequenceSchema = null;
                String sequenceName = null;
                String identityGeneration = null;
                long identityStart = 0,
                        identityIncrement = 0,
                        identityMin = 0,
                        identityMax = 0;
                String identityCycle = null;
                if (column.getIdentityGenerator() != null) {
                    sequenceSchema = column.getIdentityGenerator().getSequenceName().getSchemaName();
                    sequenceName   = column.getIdentityGenerator().getSequenceName().getTableName();
                    identityGeneration = column.getDefaultIdentity() ? "BY DEFAULT" : "ALWAYS";
                    identityStart = column.getIdentityGenerator().getStartsWith();
                    identityIncrement = column.getIdentityGenerator().getIncrement();
                    identityMin = column.getIdentityGenerator().getMinValue();
                    identityMax = column.getIdentityGenerator().getMaxValue();
                    identityCycle = boolResult(column.getIdentityGenerator().isCycle());
                }
                String defaultString = null;
                if (column.getDefaultValue() != null) {
                    defaultString = column.getDefaultValue();
                }
                else if (column.getDefaultFunction() != null) {
                    defaultString = column.getDefaultFunction() + "()";
                }
               
                return new ValuesRow(rowType,
                                    null,
                                     column.getColumnar().getName().getSchemaName(),
                                     column.getColumnar().getName().getTableName(),
                                     column.getName(),
                                     column.getPosition().longValue(),
                                     defaultString,
                                     boolResult(column.getNullable()),
                                     column.getTypeName(),
                                     charMaxLength,
                                     charOctetLength,
                                     precision,
                                     radix,
                                     scale,
View Full Code Here

            // tables with hidden PK (noPK tables) return no values
            if (row.rowType().table().getPrimaryKey() == null) return;
           
            List<IndexColumn> columns = row.rowType().table().getPrimaryKey().getIndex().getKeyColumns();
            for (int i = 0; i < columns.size(); i++) {
                Column column = columns.get(i).getColumn();
                writeValue(column.getName(), row.value(column.getPosition()), appender, i == 0, options);
                pkValues.put(column, row.value(column.getPosition()));
            }
        }
View Full Code Here

        AkibanInformationSchema ais = context.getQueryContext().getStore().schema().ais();
        Table table = ais.getTable(parts[0], parts[1]);
        if(table == null) {
            throw new NoSuchTableException(parts[0], parts[1]);
        }
        Column column = table.getColumn(parts[2]);
        if(column == null) {
            throw new NoSuchColumnException(String.format("%s.%s.%s", parts[0], parts[1], parts[2]));
        }
        Sequence seq = column.getIdentityGenerator();
        if(seq == null) {
            output.putNull();
        } else {
            output.putString(seq.getSequenceName().toStringEscaped(), null);
        }
View Full Code Here

        // Pass one, insert fields from the table
        Iterator<Entry<String,JsonNode>> i = node.fields();
        while (i.hasNext()) {
            Entry<String,JsonNode> field = i.next();
            if (field.getValue().isValueNode()) {
                Column column = getColumn(context.table, field.getKey());
                context.allValues.put(column, field.getValue().isNull() ? null : field.getValue().asText());
            }
        }
        runInsert(context, appender);
        boolean first = true;
View Full Code Here

        LOG.trace("Insert row into: {}, values {}", context.tableName, context.queryContext);
        // Fill in parent columns if this is a child table
        if(context.pkValues != null && context.table.getParentJoin() != null) {
            Join join = context.table.getParentJoin();
            for (Entry<Column, ValueSource> entry : context.pkValues.entrySet()) {
                Column parentCol = entry.getKey();
                Column childCol = join.getMatchingChild(parentCol);
                String fkValue = valueToString(entry.getValue());
                String curValue = context.allValues.get(childCol);
                if(curValue == null) {
                    context.allValues.put(childCol, fkValue);
                } else if(!fkValue.equals(curValue)) {
View Full Code Here

TOP

Related Classes of com.foundationdb.ais.model.Column

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.