Package org.apache.camel.component.hbase.model

Examples of org.apache.camel.component.hbase.model.HBaseCell


                List<KeyValue> keyValues = result.list();
                if (keyValues != null) {
                    Set<HBaseCell> cellModels = rowModel.getCells();
                    if (cellModels.size() > 0) {
                        for (HBaseCell modelCell : cellModels) {
                            HBaseCell resultCell = new HBaseCell();
                            String family = modelCell.getFamily();
                            String column = modelCell.getQualifier();
                            resultCell.setValue(endpoint.getCamelContext().getTypeConverter().convertTo(modelCell.getValueType(),
                                    result.getValue(HBaseHelper.getHBaseFieldAsBytes(family), HBaseHelper.getHBaseFieldAsBytes(column))));
                            resultCell.setFamily(modelCell.getFamily());
                            resultCell.setQualifier(modelCell.getQualifier());
                            resultRow.getCells().add(resultCell);
                        }
                    } else {
                        // just need to put every key value into the result Cells
                        for (KeyValue keyValue : keyValues) {
                            String qualifier = new String(keyValue.getQualifier());
                            String family = new String(keyValue.getFamily());
                            HBaseCell resultCell = new HBaseCell();
                            resultCell.setFamily(family);
                            resultCell.setQualifier(qualifier);
                            resultCell.setValue(endpoint.getCamelContext().getTypeConverter().convertTo(String.class, keyValue.getValue()));
                            resultRow.getCells().add(resultCell);
                        }
                    }
              
                    data.getRows().add(resultRow);
View Full Code Here


    /**
     * Resolves the cell that the {@link Exchange} refers to.
     */
    private HBaseRow resolveRow(Message message, int index) {
        HBaseRow hRow = new HBaseRow();
        HBaseCell hCell = new HBaseCell();

        if (message != null) {
            Object id =  message.getHeader(HbaseAttribute.HBASE_ROW_ID.asHeader(index));
            String rowClassName = message.getHeader(HbaseAttribute.HBASE_ROW_TYPE.asHeader(index), String.class);
            Class<?> rowClass = rowClassName == null || rowClassName.isEmpty() ? String.class : message.getExchange().getContext().getClassResolver().resolveClass(rowClassName);
            String columnFamily = (String) message.getHeader(HbaseAttribute.HBASE_FAMILY.asHeader(index));
            String columnName = (String) message.getHeader(HbaseAttribute.HBASE_QUALIFIER.asHeader(index));
            Object value =  message.getHeader(HbaseAttribute.HBASE_VALUE.asHeader(index));

            String valueClassName = message.getHeader(HbaseAttribute.HBASE_VALUE_TYPE.asHeader(index), String.class);
            Class<?> valueClass = valueClassName == null || valueClassName.isEmpty() ? String.class : message.getExchange().getContext().getClassResolver().resolveClass(valueClassName);

            //Id can be accepted as null when using get, scan etc.
            if (id == null && columnFamily == null && columnName == null) {
                return null;
            }

            hRow.setId(id);
            hRow.setRowType(rowClass);
            hCell.setQualifier(columnName);
            hCell.setFamily(columnFamily);
            hCell.setValue(value);
            hCell.setValueType(valueClass);
            hRow.getCells().add(hCell);
        }
        return hRow;
    }
View Full Code Here

                List<KeyValue> keyValues = result.list();
                if (keyValues != null) {
                    for (KeyValue keyValue : keyValues) {
                        String qualifier = new String(keyValue.getQualifier());
                        String family = new String(keyValue.getFamily());
                        HBaseCell resultCell = new HBaseCell();
                        resultCell.setFamily(family);
                        resultCell.setQualifier(qualifier);
                        resultCell.setValue(endpoint.getCamelContext().getTypeConverter().convertTo(String.class, keyValue.getValue()));
                        resultRow.getCells().add(resultCell);
                    }
                    data.getRows().add(resultRow);
                    Exchange exchange = endpoint.createExchange();
                    exchange.getIn().setHeader(CellMappingStrategyFactory.STRATEGY, CellMappingStrategyFactory.BODY);
View Full Code Here

                rowModel.setRowType(getCamelContext().getClassResolver().resolveClass(rowType));
            }
        }
        for (int i = 1; parameters.get(HbaseAttribute.HBASE_FAMILY.asOption(i)) != null
                && parameters.get(HbaseAttribute.HBASE_QUALIFIER.asOption(i)) != null; i++) {
            HBaseCell cellModel = new HBaseCell();
            cellModel.setFamily(String.valueOf(parameters.remove(HbaseAttribute.HBASE_FAMILY.asOption(i))));
            cellModel.setQualifier(String.valueOf(parameters.remove(HbaseAttribute.HBASE_QUALIFIER.asOption(i))));
            cellModel.setValue(String.valueOf(parameters.remove(HbaseAttribute.HBASE_VALUE.asOption(i))));
            if (parameters.containsKey(HbaseAttribute.HBASE_VALUE_TYPE.asOption())) {
                String valueType = String.valueOf(parameters.remove(HbaseAttribute.HBASE_VALUE_TYPE.asOption()));
                if (valueType != null && !valueType.isEmpty()) {
                    rowModel.setRowType(getCamelContext().getClassResolver().resolveClass(valueType));
                }
View Full Code Here

                List<KeyValue> keyValues = result.list();
                if (keyValues != null) {
                    for (KeyValue keyValue : keyValues) {
                        String qualifier = new String(keyValue.getQualifier());
                        String family = new String(keyValue.getFamily());
                        HBaseCell resultCell = new HBaseCell();
                        resultCell.setFamily(family);
                        resultCell.setQualifier(qualifier);
                        resultCell.setValue(endpoint.getCamelContext().getTypeConverter().convertTo(String.class, keyValue.getValue()));
                        resultRow.getCells().add(resultCell);
                    }
                    data.getRows().add(resultRow);
                    exchange = endpoint.createExchange();
                    // Probably overkill but kept it here for consistency.
View Full Code Here

    /**
     * Resolves the cell that the {@link Exchange} refers to.
     */
    private HBaseRow resolveRow(Message message, int index) {
        HBaseRow hRow = new HBaseRow();
        HBaseCell hCell = new HBaseCell();

        if (message != null) {
            Object id =  message.getHeader(HbaseAttribute.HBASE_ROW_ID.asHeader(index));
            String rowClassName = message.getHeader(HbaseAttribute.HBASE_ROW_TYPE.asHeader(index), String.class);
            Class<?> rowClass = rowClassName == null || rowClassName.isEmpty() ? String.class : message.getExchange().getContext().getClassResolver().resolveClass(rowClassName);
            String columnFamily = (String) message.getHeader(HbaseAttribute.HBASE_FAMILY.asHeader(index));
            String columnName = (String) message.getHeader(HbaseAttribute.HBASE_QUALIFIER.asHeader(index));
            Object value =  message.getHeader(HbaseAttribute.HBASE_VALUE.asHeader(index));

            String valueClassName = message.getHeader(HbaseAttribute.HBASE_VALUE_TYPE.asHeader(index), String.class);
            Class<?> valueClass = valueClassName == null || valueClassName.isEmpty() ? String.class : message.getExchange().getContext().getClassResolver().resolveClass(valueClassName);

            //Id can be accepted as null when using get, scan etc.
            if (id == null && columnFamily == null && columnName == null) {
                return null;
            }

            hRow.setId(id);
            hRow.setRowType(rowClass);
            if (columnFamily != null && columnName != null) {
                hCell.setQualifier(columnName);
                hCell.setFamily(columnFamily);
                hCell.setValue(value);
                // String is the default value type
                hCell.setValueType((valueClass != null) ? valueClass : String.class);
                hRow.getCells().add(hCell);
            }
        }
        return hRow;
    }
View Full Code Here

                rowModel.setRowType(getCamelContext().getClassResolver().resolveClass(rowType));
            }
        }
        for (int i = 1; parameters.get(HbaseAttribute.HBASE_FAMILY.asOption(i)) != null
                && parameters.get(HbaseAttribute.HBASE_QUALIFIER.asOption(i)) != null; i++) {
            HBaseCell cellModel = new HBaseCell();
            cellModel.setFamily(String.valueOf(parameters.remove(HbaseAttribute.HBASE_FAMILY.asOption(i))));
            cellModel.setQualifier(String.valueOf(parameters.remove(HbaseAttribute.HBASE_QUALIFIER.asOption(i))));
            cellModel.setValue(String.valueOf(parameters.remove(HbaseAttribute.HBASE_VALUE.asOption(i))));
            if (parameters.containsKey(HbaseAttribute.HBASE_VALUE_TYPE.asOption(i))) {
                String valueType = String.valueOf(parameters.remove(HbaseAttribute.HBASE_VALUE_TYPE.asOption(i)));
                if (valueType != null && !valueType.isEmpty()) {
                    rowModel.setRowType(getCamelContext().getClassResolver().resolveClass(valueType));
                }
View Full Code Here

        }

        Result result = table.get(get);

        for (HBaseCell cellModel : cellModels) {
            HBaseCell resultCell = new HBaseCell();
            String family = cellModel.getFamily();
            String column = cellModel.getQualifier();
            resultCell.setFamily(family);
            resultCell.setQualifier(column);

            List<KeyValue> kvs = result.getColumn(HBaseHelper.getHBaseFieldAsBytes(family), HBaseHelper.getHBaseFieldAsBytes(column));
            if (kvs != null && !kvs.isEmpty()) {
                //Return the most recent entry.
                resultCell.setValue(endpoint.getCamelContext().getTypeConverter().convertTo(cellModel.getValueType(), kvs.get(0).getValue()));
            }
            resultCells.add(resultCell);
            resultRow.getCells().add(resultCell);
        }
        return resultRow;
View Full Code Here

        while (result != null) {
            HBaseRow resultRow = new HBaseRow();
            resultRow.setId(endpoint.getCamelContext().getTypeConverter().convertTo(model.getRowType(), result.getRow()));
            cellModels = model.getCells();
            for (HBaseCell modelCell : cellModels) {
                HBaseCell resultCell = new HBaseCell();
                String family = modelCell.getFamily();
                String column = modelCell.getQualifier();
                resultRow.setId(endpoint.getCamelContext().getTypeConverter().convertTo(model.getRowType(), result.getRow()));
                resultCell.setValue(endpoint.getCamelContext().getTypeConverter().convertTo(modelCell.getValueType(),
                        result.getValue(HBaseHelper.getHBaseFieldAsBytes(family), HBaseHelper.getHBaseFieldAsBytes(column))));
                resultCell.setFamily(modelCell.getFamily());
                resultCell.setQualifier(modelCell.getQualifier());
                resultRow.getCells().add(resultCell);
                rowSet.add(resultRow);
            }

            result = resultScanner.next();
View Full Code Here

                List<KeyValue> keyValues = result.list();
                if (keyValues != null) {
                    for (KeyValue keyValue : keyValues) {
                        String qualifier = new String(keyValue.getQualifier());
                        String family = new String(keyValue.getFamily());
                        HBaseCell resultCell = new HBaseCell();
                        resultCell.setFamily(family);
                        resultCell.setQualifier(qualifier);
                        resultCell.setValue(endpoint.getCamelContext().getTypeConverter().convertTo(String.class, keyValue.getValue()));
                        resultRow.getCells().add(resultCell);
                    }
                    data.getRows().add(resultRow);
                    Exchange exchange = endpoint.createExchange();
                    exchange.getIn().setHeader(CellMappingStrategyFactory.STRATEGY, CellMappingStrategyFactory.BODY);
View Full Code Here

TOP

Related Classes of org.apache.camel.component.hbase.model.HBaseCell

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.