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

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


    public void assignSelectValue(final HConnectionImpl conn,
                                  final Object obj,
                                  final int maxVersions,
                                  final Result result) throws HBqlException {

        final TableMapping tableMapping = this.getTableMapping();

        // Evaluate each of the families (select * will yield all families)
        for (int i = 0; i < this.getFamilyNameBytesList().size(); i++) {

            final String familyName = this.getFamilyNameList().get(i);
            final byte[] familyNameBytes = this.getFamilyNameBytesList().get(i);

            final NavigableMap<byte[], byte[]> columnMap = result.getFamilyMap(familyNameBytes);

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

                final byte[] valueBytes = columnMap.get(columnBytes);
                final String columnName = IO.getSerialization().getStringFromBytes(columnBytes);

                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


        if (this.hasValidExpressionTree()) {

            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);
View Full Code Here

        final FamilyMapping mapping = new FamilyMapping(EMBEDDED, false, columnList);
        final List<FamilyMapping> mappingList = Lists.newArrayList(mapping);

        try {
            return new TableMapping(null, true, false, EMBEDDED, null, null, mappingList);
        }
        catch (HBqlException e) {
            e.printStackTrace();
            throw new RecognitionException(input);
        }
View Full Code Here

        final Set<String> names = this.getFamilyNames(tableName);
        return names.contains(familyName);
    }

    public boolean familyExistsForMapping(final String familyName, final String mappingName) throws HBqlException {
        final TableMapping mapping = this.getMapping(mappingName);
        return mapping.containsFamily(familyName);
    }
View Full Code Here

            throw new HBqlException(e);
        }
    }

    public boolean indexExistsForMapping(final String indexName, final String mappingName) throws HBqlException {
        final TableMapping mapping = this.getMapping(mappingName);
        return this.indexExistsForTable(indexName, mapping.getTableName());
    }
View Full Code Here

        final IndexSpecification index = this.getIndexForTable(indexName, tableName);
        return index != null;
    }

    public void dropIndexForMapping(final String indexName, final String mappingName) throws HBqlException {
        final TableMapping mapping = this.getMapping(mappingName);
        this.dropIndexForTable(mapping.getTableName(), indexName);
    }
View Full Code Here

                                                   final List<FamilyMapping> familyMappingList) throws HBqlException {

        if (!mappingName.equals(SYSTEM_MAPPINGS) && this.mappingExists(mappingName))
            throw new HBqlException("Mapping already defined: " + mappingName);

        final TableMapping tableMapping = new TableMapping(this.getConnection(),
                                                           isTemp,
                                                           isSystem,
                                                           mappingName,
                                                           tableName,
                                                           keyInfo,
                                                           familyMappingList);

        if (tableMapping.isTempMapping()) {
            if (!tableMapping.isSystemMapping())
                this.getUserMappingsMap().put(mappingName, tableMapping);
            else
                this.getSystemMappingsMap().put(mappingName, tableMapping);
        }
        else {
            this.getCachedMappingsMap().put(mappingName, tableMapping);

            final String sql = "INSERT INTO " + SYSTEM_MAPPINGS + " (mapping_name, mapping_obj) VALUES (?, ?)";
            final HPreparedStatement stmt = this.getConnection().prepareStatement(sql);
            stmt.setParameter(1, tableMapping.getMappingName());
            stmt.setParameter(2, tableMapping);
            stmt.execute();
        }

        return tableMapping;
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.