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

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


        return this.indexName;
    }

    protected ExecutionResults execute(final HConnectionImpl conn) throws HBqlException {
        conn.dropIndexForMapping(this.getIndexName(), this.getMappingContext().getMappingName());
        final TableMapping mapping = conn.getMapping(this.getMappingContext().getMappingName());
        return new ExecutionResults("Index " + this.getIndexName() + " dropped for table " + mapping.getTableName());
    }
View Full Code Here


    protected ExecutionResults execute(final HConnectionImpl conn) throws HBqlException {

        this.getMappingContext().validateMappingName(conn);

        final TableMapping tableMapping = this.getMappingContext().getTableMapping();

        if (tableMapping == null)
            return new ExecutionResults("Unknown mapping: " + this.getMappingContext().getMappingName());
        else
            return new ExecutionResults(tableMapping.asString());
    }
View Full Code Here

        for (final String deleteItem : this.originaltemList) {
            if (deleteItem.contains(":")) {
                this.getDeleteItemList().add(deleteItem);
            }
            else {
                final TableMapping mapping = this.getMappingContext().getTableMapping();
                final ColumnAttrib attrib = mapping.getAttribByVariableName(deleteItem);
                if (attrib == null)
                    throw new HBqlException("Invalid variable: " + deleteItem);

                this.getDeleteItemList().add(attrib.getFamilyQualifiedName());
            }
View Full Code Here

        return this.indexName;
    }

    protected ExecutionResults execute(final HConnectionImpl conn) throws HBqlException {

        final TableMapping mapping = conn.getMapping(this.getMappingContext().getMappingName());

        final List<String> indexList = this.getQualifiedNameList(mapping, this.indexColumns);
        final List<String> includeList = this.getQualifiedNameList(mapping, this.includeColumns);
        final IndexSpecification spec = SingleColumnIndex.newIndex(this.getIndexName(), indexList, includeList);

        try {
            conn.getIndexTableAdmin().addIndex(mapping.getTableNameAsBytes(), spec);
        }
        catch (IOException e) {
            throw new HBqlException(e);
        }
View Full Code Here

        if (!this.isADelegateColumnReference()) {
            this.assignCalculation(conn, obj, result);
            return;
        }

        final TableMapping tableMapping = this.getTableMapping();

        // Column reference is not known to mapping, so just assign byte[] value
        if (this.getColumnAttrib() == null) {
            final ColumnAttrib unMappedAttrib = tableMapping.getUnMappedAttrib(this.getFamilyName());
            if (unMappedAttrib != null) {
                final byte[] b = result.getValue(this.getFamilyNameBytes(), this.getColumnNameBytes());
                unMappedAttrib.setUnMappedCurrentValue(obj, this.getSelectName(), b);
            }
        }
        else {
            if (this.getColumnAttrib().isACurrentValue()) {
                final byte[] b = result.getValue(this.getFamilyNameBytes(), this.getColumnNameBytes());
                this.getColumnAttrib().setCurrentValue(obj, 0, b);
            }
        }

        // Now assign versions if they were requested. Do not process if it doesn't support version values
        if (maxVerions > 1) {

            // Bail if a known column is not a version attrib
            if (this.getColumnAttrib() != null && !this.getColumnAttrib().isAVersionValue())
                return;

            final NavigableMap<byte[], NavigableMap<byte[], NavigableMap<Long, byte[]>>> familyMap = result.getMap();
            final NavigableMap<byte[], NavigableMap<Long, byte[]>> columnMap = familyMap.get(this.getFamilyNameBytes());

            if (columnMap == null)
                return;

            final NavigableMap<Long, byte[]> timeStampMap = columnMap.get(this.getColumnNameBytes());

            if (this.getColumnAttrib() == null) {
                final ColumnAttrib unMappedAttrib = tableMapping.getUnMappedAttrib(this.getFamilyName());
                if (unMappedAttrib != null)
                    unMappedAttrib.setUnMappedVersionMap(obj, this.getSelectName(), timeStampMap);
            }
            else {
                final Map<Long, Object> mapVal = this.getColumnAttrib().getVersionMap(obj);
View Full Code Here

        }
    }

    protected ExecutionResults execute(final HConnectionImpl conn) throws HBqlException {

        final TableMapping tableMapping = conn.createMapping(this.isTempMapping(),
                                                             this.isSystemMapping(),
                                                             this.getMappingContext().getMappingName(),
                                                             this.getTableName(),
                                                             this.getKeyInfo(),
                                                             this.getFamilyMappingList());
        this.getMappingContext().setMapping(tableMapping);
        tableMapping.validate(tableMapping.getMappingName());
        return new ExecutionResults("Mapping " + tableMapping.getMappingName() + " defined.");
    }
View Full Code Here

    public void insert(final T newrec) throws HBqlException {

        if (newrec instanceof HRecordImpl) {
            final HRecordImpl record = (HRecordImpl)newrec;
            final TableMapping tableMapping = record.getTableMapping();
            final ColumnAttrib keyAttrib = tableMapping.getKeyAttrib();
            if (!record.isCurrentValueSet(keyAttrib))
                throw new HBqlException("Record key value must be assigned");

            final Put put = this.createPut(record.getResultAccessor(), record);
            this.getActionList(tableMapping.getTableName()).add(new InsertAction(put));
        }
        else {
            final AnnotationResultAccessor accessor = this.getHConnectionImpl().getAnnotationMapping(newrec);
            final Put put = this.createPut(accessor, newrec);
            this.getActionList(accessor.getMapping().getTableName()).add(new InsertAction(put));
View Full Code Here

    public void delete(final T newrec) throws HBqlException {

        if (newrec instanceof HRecordImpl) {
            final HRecordImpl record = (HRecordImpl)newrec;
            final TableMapping tableMapping = record.getTableMapping();
            final ColumnAttrib keyAttrib = tableMapping.getKeyAttrib();
            if (!record.isCurrentValueSet(keyAttrib))
                throw new HBqlException("Record key value must be assigned");
            this.delete(tableMapping, record);
        }
        else {
View Full Code Here

        this.getActionList(tableMapping.getTableName()).add(new DeleteAction(new Delete(keyval)));
    }

    private Put createPut(final ResultAccessor resultAccessor, final Object newrec) throws HBqlException {

        final TableMapping tableMapping = resultAccessor.getTableMapping();
        final ColumnAttrib keyAttrib = resultAccessor.getKeyAttrib();

        final Put put;

        if (newrec instanceof HRecordImpl) {
            final HRecordImpl record = (HRecordImpl)newrec;
            final byte[] keyval = keyAttrib.getValueAsBytes(record);
            put = new Put(keyval);

            for (final String family : tableMapping.getFamilySet()) {
                for (final ColumnAttrib attrib : tableMapping.getColumnAttribListByFamilyName(family)) {
                    if (record.isCurrentValueSet(attrib)) {
                        final byte[] b = attrib.getValueAsBytes(record);
                        put.add(attrib.getFamilyNameAsBytes(), attrib.getColumnNameAsBytes(), b);
                    }
                }
            }
        }
        else {
            final byte[] keyval = keyAttrib.getValueAsBytes(newrec);
            put = new Put(keyval);
            for (final String family : tableMapping.getFamilySet()) {
                for (final ColumnAttrib colattrib : tableMapping.getColumnAttribListByFamilyName(family)) {

                    // One extra lookup for annotations
                    final ColumnAttrib attrib = resultAccessor.getColumnAttribByName(colattrib.getFamilyQualifiedName());
                    final byte[] b = attrib.getValueAsBytes(newrec);
                    put.add(attrib.getFamilyNameAsBytes(), attrib.getColumnNameAsBytes(), b);
View Full Code Here

        byte[] startKey = null;
        byte[] stopKey = null;

        if (this.getStartRow() != HConstants.EMPTY_START_ROW) {
            final TableMapping tableMapping = (TableMapping)mapping;
            tableMapping.validateKeyInfo(withArgs.getIndexName());
            final int width = tableMapping.getKeyInfo().getWidth();
            startKey = Bytes.add(this.getStartRow(), Util.getFixedWidthString(Character.MIN_VALUE, width));
        }

        if (this.getStopRow() != HConstants.EMPTY_END_ROW) {
            final TableMapping tableMapping = (TableMapping)mapping;
            tableMapping.validateKeyInfo(withArgs.getIndexName());
            final int width = tableMapping.getKeyInfo().getWidth();
            stopKey = Bytes.add(this.getStopRow(), Util.getFixedWidthString(Character.MAX_VALUE, width));
        }

        try {
            return index.getIndexedScanner(withArgs.getIndexName(),
View Full Code Here

TOP

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

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.