Package org.apache.hadoop.hbase.hbql.mapping

Examples of org.apache.hadoop.hbase.hbql.mapping.ColumnAttrib


                if (obj instanceof HRecordImpl) {
                    final HRecordImpl record = (HRecordImpl)obj;
                    record.addNameToPositionList(familyName + ":" + columnName);
                }

                final ColumnAttrib attrib = this.getResultAccessor().getColumnAttribByQualifiedName(familyName,
                                                                                                    columnName);
                if (attrib == null) {
                    final ColumnAttrib unMappedAttrib = tableMapping.getUnMappedAttrib(familyName);
                    if (unMappedAttrib != null)
                        unMappedAttrib.setUnMappedCurrentValue(obj, columnName, valueBytes);
                }
                else {
                    attrib.setCurrentValue(obj, 0, valueBytes);
                }
            }

            // Bail if no versions were requested
            if (maxVersions <= 1)
                continue;

            final NavigableMap<byte[], NavigableMap<byte[], NavigableMap<Long, byte[]>>> familyMap = result.getMap();
            final NavigableMap<byte[], NavigableMap<Long, byte[]>> versionColumnMap = familyMap.get(familyNameBytes);

            if (versionColumnMap == null)
                continue;

            for (final byte[] columnBytes : versionColumnMap.keySet()) {

                final NavigableMap<Long, byte[]> timeStampMap = versionColumnMap.get(columnBytes);
                final String columnName = IO.getSerialization().getStringFromBytes(columnBytes);

                final ColumnAttrib attrib = this.getResultAccessor().getVersionAttrib(familyName, columnName);

                if (attrib == null) {
                    final ColumnAttrib unMappedAttrib = tableMapping.getUnMappedAttrib(familyName);
                    if (unMappedAttrib != null)
                        unMappedAttrib.setUnMappedVersionMap(obj, columnName, timeStampMap);
                }
                else {
                    attrib.setVersionMap(obj, timeStampMap);
                }
            }
View Full Code Here


            try {
                final String familyName = Bytes.toString(v.getFamily());
                final String columnName = Bytes.toString(v.getQualifier());
                final TableMapping tableMapping = this.getMapping();
                final ColumnAttrib attrib = tableMapping.getAttribFromFamilyQualifiedName(familyName, columnName);

                // Do not bother setting value if it is not used in expression
                if (this.getExpressionTree().getAttribsUsedInExpr().contains(attrib)) {
                    if (this.getVerbose())
                        LOG.debug("In filterKeyValue() setting value for: " + familyName + ":" + columnName);
                    final Object val = attrib.getValueFromBytes(null, v.getValue());
                    this.getHRecord().setCurrentValue(familyName, columnName, v.getTimestamp(), val);
                    this.getHRecord().setVersionValue(familyName, columnName, v.getTimestamp(), val, true);
                }
            }
            catch (Exception e) {
View Full Code Here

    public List<RowRequest> getRowRequestList(final HConnectionImpl conn,
                                              final Mapping mapping,
                                              final Set<ColumnAttrib> columnAttribs) throws HBqlException {

        final ColumnAttrib keyAttrib;

        if (this.hasAnIndex()) {
            // Need to look up the index
            final IndexSpecification index = conn.getIndexForTable(this.getIndexName(), mapping.getTableName());
            final byte[][] cols = index.getIndexedColumns();
View Full Code Here

    // Current Object values
    public void setCurrentValue(final String family,
                                final String column,
                                final long timestamp,
                                final Object val) throws HBqlException {
        final ColumnAttrib attrib = this.getTableMapping().getAttribFromFamilyQualifiedName(family, column);
        if (attrib == null)
            throw new HBqlException("Invalid column name " + family + ":" + column);
        this.setCurrentValue(attrib.getAliasName(), timestamp, val, true);
    }
View Full Code Here

    public void setVersionValue(final String familyName,
                                final String columnName,
                                final long timestamp,
                                final Object val,
                                final boolean inMapping) throws HBqlException {
        final ColumnAttrib attrib = this.getTableMapping().getAttribFromFamilyQualifiedName(familyName, columnName);
        if (attrib == null)
            throw new HBqlException("Invalid column name " + familyName + ":" + columnName);

        this.getColumnValue(attrib.getColumnName(), inMapping).getVersionMap().put(timestamp, val);
    }
View Full Code Here

        if (columnValue != null) {
            final Object retval = columnValue.getCurrentValue();
            if (retval != null) {
                // Check if Date value
                if (retval instanceof Long) {
                    final ColumnAttrib att = this.getMappingContext().getResultAccessor().getColumnAttribByName(name);
                    if (att != null && att.getFieldType() == FieldType.DateType)
                        return new Date((Long)retval);
                }
                return retval;
            }
        }

        // Return default value if it exists
        final ColumnAttrib attrib = this.getMappingContext().getResultAccessor().getColumnAttribByName(name);
        return (attrib != null) ? attrib.getDefaultValue() : null;
    }
View Full Code Here

        if (context.getMapping() == null)
            throw new InternalErrorException("Null mapping for: " + context.asString());

        // See if referenced var is in mapping
        final String variableName = this.getVariableName();
        final ColumnAttrib attrib = context.getResultAccessor().getColumnAttribByName(variableName);

        this.variableDefinedInMapping = (attrib != null);

        if (this.isVariableDefinedInMapping()) {

            switch (attrib.getFieldType()) {

                case KeyType:
                    this.setTypedColumn(new KeyColumn(attrib));
                    break;

                case StringType:
                    this.setTypedColumn(new StringColumn(attrib));
                    break;

                case BooleanType:
                    this.setTypedColumn(new BooleanColumn(attrib));
                    break;

                case ByteType:
                    this.setTypedColumn(new ByteColumn(attrib));
                    break;

                case CharType:
                    this.setTypedColumn(new CharColumn(attrib));
                    break;

                case ShortType:
                    this.setTypedColumn(new ShortColumn(attrib));
                    break;

                case IntegerType:
                    this.setTypedColumn(new IntegerColumn(attrib));
                    break;

                case LongType:
                    this.setTypedColumn(new LongColumn(attrib));
                    break;

                case FloatType:
                    this.setTypedColumn(new FloatColumn(attrib));
                    break;

                case DoubleType:
                    this.setTypedColumn(new DoubleColumn(attrib));
                    break;

                case DateType:
                    this.setTypedColumn(new DateColumn(attrib));
                    break;

                case ObjectType:
                    this.setTypedColumn(new ObjectColumn(attrib));
                    break;

                default:
                    throw new HBqlException("Invalid type: " + attrib.getFieldType().name());
            }

            this.getTypedColumn().setExpressionContext(context);
        }
    }
View Full Code Here

    private HRecordImpl getRecord() {
        return this.record;
    }

    public void addElement(final T value) throws HBqlException {
        final ColumnAttrib attrib = this.getRecord().getResultAccessor().getColumnAttribByName(value.getName());
        final String name = (attrib == null) ? value.getName() : attrib.getFamilyQualifiedName();
        this.put(name, value);
    }
View Full Code Here

        // If that doesn't work, then try qualified name
        if (this.containsName(name))
            return this.getElement(name);

        // Look up by  alias name
        final ColumnAttrib attrib = this.getRecord().getResultAccessor().getColumnAttribByName(name);

        if (attrib != null) {
            final String qualifiedName = attrib.getFamilyQualifiedName();
            if (!qualifiedName.equals(name) && this.containsName(qualifiedName))
                return this.getElement(qualifiedName);
        }

        return null;
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hbase.hbql.mapping.ColumnAttrib

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.