Package com.datastax.driver.core

Examples of com.datastax.driver.core.ColumnDefinitions


  }

  private CqlRowMetadata extractRowMetadata(Row row, Map<String, CqlColumnType> typeMap) {

    // collect and count all columns
    ColumnDefinitions definitions = row.getColumnDefinitions();
    ImmutableList.Builder<CqlExtendedColumnName> columnsBuild = ImmutableList.builder();
    CqlPartitionKey partitionKey = null;
    for (int colIndex = 0; colIndex < definitions.size(); colIndex++) {
      if (colIndex > config.cassandra.columnsLimit) {
        LOG.debug("Reached columns limit: {}", config.cassandra.columnsLimit);
        break;
      }
      if (row.isNull(colIndex)) {
        continue;
      }
      DataType dataType = definitions.getType(colIndex);
      String columnNameText = definitions.getName(colIndex);
      CqlColumnType columnType = typeMap.get(columnNameText.toLowerCase());
      if (columnType == null) {
        columnType = CqlColumnType.REGULAR;
        LOG.debug("Column type not found for: {} - using regular", columnNameText);
      }
View Full Code Here


        JsonObject response = new JsonObject();
        List<Row> rows = rs.all();
        if (!rows.isEmpty() && rows.size()==1) {
            rowStr = rows.get(0).toString();
        }
        ColumnDefinitions colDefs = rs.getColumnDefinitions();
        colStr = colDefs.toString();
        response.putString("columns", colStr.substring(8,colStr.length()-1));
        response.putString("values", rowStr.substring(4,rowStr.length()-1));
        return response.toString();
       
//        for (Row ro:rows) {
View Full Code Here

        JsonObject response = new JsonObject();
        List<Row> rows = rs.all();
        if (!rows.isEmpty() && rows.size() == 1) {
            rowStr = rows.get(0).toString();
        }
        ColumnDefinitions colDefs = rs.getColumnDefinitions();
        colStr = colDefs.toString();
        response.putString("columns", colStr.substring(8, colStr.length() - 1));
        response.putString("values", rowStr.substring(4, rowStr.length() - 1));
        return response.toString();

    }
View Full Code Here

        JsonObject response = new JsonObject();
        List<Row> rows = rs.all();
        if (!rows.isEmpty() && rows.size() == 1) {
            rowStr = rows.get(0).toString();
        }
        ColumnDefinitions colDefs = rs.getColumnDefinitions();
        colStr = colDefs.toString();
        response.putString("columns", colStr.substring(8, colStr.length() - 1));
        response.putString("values", rowStr.substring(4, rowStr.length() - 1));
        return response.toString();
    }
View Full Code Here

        JsonObject response = new JsonObject();
        List<Row> rows = rs.all();
        if (!rows.isEmpty() && rows.size() == 1) {
            rowStr = rows.get(0).toString();
        }
        ColumnDefinitions colDefs = rs.getColumnDefinitions();
        colStr = colDefs.toString();
        response.putString("columns", colStr.substring(8, colStr.length() - 1));
        response.putString("values", rowStr.substring(4, rowStr.length() - 1));
        return response.toString();
    }
View Full Code Here

  /**
   * @param row
   * @return
   */
  protected Object firstColumnToObject(Row row) {
    ColumnDefinitions cols = row.getColumnDefinitions();
    if (cols.size() == 0) {
      return null;
    }
    return cols.getType(0).deserialize(row.getBytesUnsafe(0));
  }
View Full Code Here

  protected Map<String, Object> toMap(Row row) {
    if (row == null) {
      return null;
    }

    ColumnDefinitions cols = row.getColumnDefinitions();
    Map<String, Object> map = new HashMap<String, Object>(cols.size());

    for (Definition def : cols.asList()) {
      String name = def.getName();
      map.put(name, def.getType().deserialize(row.getBytesUnsafe(name)));
    }

    return map;
View Full Code Here

    if (row == null) {
      return null;
    }

    ColumnDefinitions cols = row.getColumnDefinitions();
    List<Object> list = new ArrayList<Object>(cols.size());

    for (Definition def : cols.asList()) {
      String name = def.getName();
      list.add(row.isNull(name) ? null : def.getType().deserialize(row.getBytesUnsafe(name)));
    }

    return list;
View Full Code Here

    if (row == null) {
      return null;
    }

    ColumnDefinitions cols = row.getColumnDefinitions();
    Map<String, Object> map = new HashMap<String, Object>(cols.size());

    for (Definition def : cols.asList()) {

      String name = def.getName();
      map.put(name, row.isNull(name) ? null : def.getType().deserialize(row.getBytesUnsafe(name)));
    }
View Full Code Here

    return result;
  }

    public TypedMap mapRow(Row row) {
    log.trace("Map CQL row to a map of <ColumnName,Value>");
    ColumnDefinitions columnDefinitions = row.getColumnDefinitions();
        Validator.validateNotNull(columnDefinitions,"Impossible to fetch column definitions for the row '%s'", row);
        TypedMap line = new TypedMap();
        for (Definition column : columnDefinitions) {
            line.put(column.getName(), mapColumn(row, column));
        }
View Full Code Here

TOP

Related Classes of com.datastax.driver.core.ColumnDefinitions

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.