Package com.alvazan.orm.api.z8spi.meta

Examples of com.alvazan.orm.api.z8spi.meta.DboTableMeta


    session.persistIndex(cf, indColFamily, rowKey, col);
  }
 
  @Override
  public void remove(String colFamily, TypedRow row) {
    DboTableMeta metaDbo = cachedMeta.getMeta(colFamily);
    if(metaDbo == null)
      throw new IllegalArgumentException("DboTableMeta for colFamily="+colFamily+" was not found");
   
    TypedRow proxy = row;
    Object rowKey = row.getRowKey();
    DboColumnIdMeta idMeta = metaDbo.getIdColumnMeta();
    byte[] byteKey = idMeta.convertToStorage2(rowKey);
    byte[] virtualKey = idMeta.formVirtRowKey(byteKey);
    if(!metaDbo.hasIndexedField()) {
      session.remove(metaDbo, virtualKey);
      return;
    } else if(!(row instanceof NoSqlTypedRowProxy)) {
      //then we don't have the database information for indexes so we need to read from the database
      proxy = find(metaDbo.getColumnFamily(), rowKey);
    }
   
    List<IndexData> indexToRemove = metaDbo.findIndexRemoves((NoSqlTypedRowProxy)proxy, byteKey);
   
    //REMOVE EVERYTHING HERE, we are probably removing extra and could optimize this later
    for(IndexData ind : indexToRemove) {
      session.removeFromIndex(metaDbo, ind.getColumnFamilyName(), ind.getRowKeyBytes(), ind.getIndexColumn());
    }
View Full Code Here


 
  @Override
  public Cursor<KeyValue<TypedRow>> createFindCursor(String colFamily, Iterable<Object> keys, int batchSize) {
    if(keys == null)
      throw new IllegalArgumentException("keys list cannot be null");
    DboTableMeta meta = cachedMeta.getMeta(colFamily);
    if(meta == null)
      throw new IllegalArgumentException("Meta for columnfamily="+colFamily+" was not found");
    DboColumnMeta idMeta = meta.getIdColumnMeta();
    DirectCursor<byte[]> noSqlKeys = new TypedProxyWrappingCursor<Object>(idMeta, new IterableWrappingCursor<Object>(keys));
    return findAllImpl2(meta, keys, noSqlKeys, null, batchSize);
  }
View Full Code Here

  }

  @Override
  public Cursor<IndexPoint> indexView(String columnFamily, String column,
      String partitionBy, String partitionId) {
    DboTableMeta meta = cachedMeta.getMeta(columnFamily);
    if(meta == null)
      throw new IllegalArgumentException("columnFamily="+columnFamily+" not found");
    DboColumnMeta colMeta = meta.getColumnMeta(column);
    if (colMeta == null) {
      colMeta = meta.getIdColumnMeta();
      if (!(colMeta != null && colMeta.getColumnName().equals(column)))
        throw new IllegalArgumentException("Column=" + column
            + " not found on meta info for column family="
            + columnFamily);
    }
    else if(!colMeta.isIndexed())
      throw new IllegalArgumentException("Column="+column+" is not an indexed column");
    else if(meta.getPartitionedColumns().size() > 1 && partitionBy == null)
      throw new IllegalArgumentException("Must supply partitionBy parameter BECAUSE this column family="+columnFamily+" is partitioned multiple ways");
   
    ScanInfo info = ScanInfo.createScanInfo(colMeta, partitionBy, partitionId);
    AbstractCursor<IndexColumn> indCol = session.scanIndex(info, null, null, null);
    AbstractCursor<IndexPoint> results = new CursorToIndexPoint(meta.getIdColumnMeta(), colMeta, indCol);
    return results;
  }
View Full Code Here

    return impl;
  }

  @Override
  public TypedRow createTypedRow(String colFamily) {
    DboTableMeta metaClass = cachedMeta.getMeta(colFamily);
    if(metaClass == null)
      throw new IllegalArgumentException("DboTableMeta for colFamily="+colFamily+" was not found");
   
    TypedRow r = new TypedRow(null, metaClass);
    return r;
View Full Code Here

  }

  private void updateRow(List<TypedRow> joinedRow, List<TypedColumn> updateList) {
    for(TypedRow r: joinedRow) {
      ViewInfo view = r.getView();
      DboTableMeta meta = view.getTableMeta();
      for(TypedColumn c : r.getColumnsAsColl()) {
        for (TypedColumn columnforUpdate : updateList ) {
          if (columnforUpdate.getName().equals(c.getName())) {
            Object value = columnforUpdate.getValue();
            c.setValue(value);
          }
        }
      }
      put(meta.getColumnFamily(), r)
    }
  }
View Full Code Here

  }

  private void deleteRow(List<TypedRow> typeRowList) {
    for (TypedRow r : typeRowList) {
      ViewInfo view = r.getView();
      DboTableMeta meta = view.getTableMeta();
      remove(meta.getColumnFamily(), r);
    }
  }
View Full Code Here

  }

  private boolean deleteColumn(List<TypedRow> typeRowList, List<TypedColumn> deleteList) {
    for (TypedRow r : typeRowList) {
      ViewInfo view = r.getView();
          DboTableMeta metaClass = view.getTableMeta();
          for(TypedColumn c : r.getColumnsAsColl()) {
            for (TypedColumn columnforDelete : deleteList ) {
              if (columnforDelete.getName().equals(c.getName())) {
                session.removeColumn(metaClass, StandardConverters.convertToBytes(r.getRowKey()), c.getNameRaw());
                return true;
View Full Code Here

    }
    return false;
  }

  public int count(String columnFamily, String indexedColName, Object value) {
    DboTableMeta meta = cachedMeta.getMeta(columnFamily);
    if(meta == null)
      throw new IllegalArgumentException("columnFamily="+columnFamily+" not found");
    DboColumnMeta colMeta = meta.getColumnMeta(indexedColName);
    if(colMeta == null)
      throw new IllegalArgumentException("Column="+indexedColName+" not found on meta info for column family="+columnFamily);
    else if(!colMeta.isIndexed())
      throw new IllegalArgumentException("Column="+indexedColName+" is not an indexed column");
    String query = "SELECT * FROM " +  columnFamily + " WHERE " + indexedColName + " = ";
View Full Code Here

  public void init(NoSqlEntityManagerFactory factory) {
    mgr = factory.createEntityManager();
  }
 
  public DboTableMeta getMeta(String colFamily) {
    DboTableMeta dboTableMeta = cachedMeta.get(colFamily);
    if(dboTableMeta != null)
      return dboTableMeta;
    return loadAllTableData(colFamily);
  }
View Full Code Here

  private DboTableMeta loadAllTableData(String colFamily) {
    //only synchronize on the column family we need to create so we create it once
    synchronized(colFamily.intern()) {
      if (log.isInfoEnabled())
        log.info("loading table="+colFamily);
      DboTableMeta dboTableMeta = cachedMeta.get(colFamily);
      if(dboTableMeta != null)
        return dboTableMeta;
     
      DboTableMeta table = mgr.find(DboTableMeta.class, colFamily);
      counter++;
      if(table == null)
        throw new RuntimeException("table="+colFamily+" was not found");
      //We don't want lots of threads writing data into this structure as it reads from the database so instead
      //we will prefetch everything that is typically used here....
      DboColumnIdMeta idMeta = table.getIdColumnMeta();
      idMeta.getColumnName(); //make sure the idmeta is loaded from datastore
      //load all columns as well
      for(DboColumnMeta col : table.getAllColumns()) {
        if(col instanceof DboColumnToManyMeta) {
          ((DboColumnToManyMeta)col).getFkToColumnFamily().getIdColumnMeta().getColumnName();
        } else if(col instanceof DboColumnToOneMeta) {
          ((DboColumnToOneMeta)col).getFkToColumnFamily().getIdColumnMeta().getColumnName();
        }
View Full Code Here

TOP

Related Classes of com.alvazan.orm.api.z8spi.meta.DboTableMeta

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.