@Override public List<PColumnFamily> getColumnFamilies() { return delegate.getColumnFamilies(); }
private HashSet<String> existingColumnFamilies(PTable table) { List<PColumnFamily> cfs = table.getColumnFamilies(); HashSet<String> cfNames = new HashSet<>(cfs.size()); for (PColumnFamily cf : table.getColumnFamilies()) { cfNames.add(cf.getName().getString()); } return cfNames; }
/** * Calculate what the new column family will be after the column is dropped, returning null * if unchanged. * @param table table containing column to drop * @param columnToDrop column being dropped * @return the new column family or null if unchanged. */ private static byte[] getNewEmptyColumnFamilyOrNull (PTable table, PColumn columnToDrop) { if (table.getType() != PTableType.VIEW && !SchemaUtil.isPKColumn(columnToDrop) && table.getColumnFamilies().get(0).getName().equals(columnToDrop.getFamilyName()) && table.getColumnFamilies().get(0).getColumns().size() == 1) { return SchemaUtil.getEmptyColumnFamily(table.getDefaultFamilyName(), table.getColumnFamilies().subList(1, table.getColumnFamilies().size()), table.getIndexType() == IndexType.LOCAL); } // If unchanged, return null return null; }
private static void projectAllColumnFamilies(PTable table, Scan scan) { // Will project all known/declared column families scan.getFamilyMap().clear(); for (PColumnFamily family : table.getColumnFamilies()) { scan.addFamily(family.getName().getBytes()); } }
private void deleteFromStatsTable(List<TableRef> tableRefs, long ts) throws SQLException { boolean isAutoCommit = connection.getAutoCommit(); try { connection.setAutoCommit(true); StringBuilder buf = new StringBuilder("DELETE FROM SYSTEM.STATS WHERE PHYSICAL_NAME IN ("); for (TableRef ref : tableRefs) { buf.append("'" + ref.getTable().getPhysicalName().getString() + "',"); } buf.setCharAt(buf.length() - 1, ')'); if(tableRefs.get(0).getTable().getIndexType()==IndexType.LOCAL) { buf.append(" AND COLUMN_FAMILY IN("); if (tableRefs.get(0).getTable().getColumnFamilies().isEmpty()) { buf.append("'" + QueryConstants.DEFAULT_LOCAL_INDEX_COLUMN_FAMILY + "',"); } else { for(PColumnFamily cf : tableRefs.get(0).getTable().getColumnFamilies()) { buf.append("'" + cf.getName().getString() + "',"); } } buf.setCharAt(buf.length() - 1, ')'); } connection.createStatement().execute(buf.toString()); } finally { connection.setAutoCommit(isAutoCommit); } }
public static ImmutableBytesPtr getEmptyColumnFamilyPtr(PTable table) { List<PColumnFamily> families = table.getColumnFamilies(); return families.isEmpty() ? table.getDefaultFamilyName() == null ? (table.getIndexType() == IndexType.LOCAL ? QueryConstants.DEFAULT_LOCAL_INDEX_COLUMN_FAMILY_BYTES_PTR : QueryConstants.DEFAULT_COLUMN_FAMILY_BYTES_PTR) : table.getDefaultFamilyName().getBytesPtr() : families.get(0) .getName().getBytesPtr(); }
public static byte[] getEmptyColumnFamily(PTable table) { List<PColumnFamily> families = table.getColumnFamilies(); return families.isEmpty() ? table.getDefaultFamilyName() == null ? (table.getIndexType() == IndexType.LOCAL ? QueryConstants.DEFAULT_LOCAL_INDEX_COLUMN_FAMILY_BYTES : QueryConstants.DEFAULT_COLUMN_FAMILY_BYTES) : table.getDefaultFamilyName().getBytes() : families.get(0).getName().getBytes(); }
public static String getEmptyColumnFamilyAsString(PTable table) { List<PColumnFamily> families = table.getColumnFamilies(); return families.isEmpty() ? table.getDefaultFamilyName() == null ? (table.getIndexType() == IndexType.LOCAL ? QueryConstants.DEFAULT_LOCAL_INDEX_COLUMN_FAMILY : QueryConstants.DEFAULT_COLUMN_FAMILY) : table.getDefaultFamilyName().getString() : families.get(0).getName().getString(); }
for (PColumnFamily family : indexTable.getColumnFamilies()) { for (PColumn col : family.getColumns()) { if (col.getViewConstant() == null) {
public static boolean useEncodedQualifierListOptimization(PTable table, Scan scan) { /* * HBase doesn't allow raw scans to have columns set. And we need columns to be set * explicitly on the scan to use this optimization. * * Disabling this optimization for tables with more than one column family. * See PHOENIX-3890. */ return !scan.isRaw() && table.getColumnFamilies().size() <= 1 && table.getImmutableStorageScheme() != null && table.getImmutableStorageScheme() == ImmutableStorageScheme.ONE_CELL_PER_COLUMN && usesEncodedColumnNames(table) && !table.isTransactional() && !ScanUtil.hasDynamicColumns(table); }
for (PColumnFamily family : table.getColumnFamilies()) { Collection<PColumn> columns = family.getColumns();
PTable table = PhoenixRuntime.getTable(conn, logicalNames.get(index)); if (!table.getImmutableStorageScheme().equals(ImmutableStorageScheme.ONE_CELL_PER_COLUMN)) { List<PColumnFamily> cfs = table.getColumnFamilies(); for (int i = 0; i < cfs.size(); i++) { byte[] family = cfs.get(i).getName().getBytes();
PTable table = PhoenixRuntime.getTable(conn, logicalNames.get(index)); if (!table.getImmutableStorageScheme().equals(ImmutableStorageScheme.ONE_CELL_PER_COLUMN)) { List<PColumnFamily> cfs = table.getColumnFamilies(); for (int i = 0; i < cfs.size(); i++) { byte[] family = cfs.get(i).getName().getBytes();
private void ensureViewIndexTableCreated(PTable table, long timestamp, boolean isNamespaceMapped) throws SQLException { byte[] physicalTableName = table.getPhysicalName().getBytes(); TableDescriptor htableDesc = this.getTableDescriptor(physicalTableName); List<Pair<byte[],Map<String,Object>>> families = Lists.newArrayListWithExpectedSize(Math.max(1, table.getColumnFamilies().size() + 1)); // Create all column families that the parent table has for (PColumnFamily family : table.getColumnFamilies()) { byte[] familyName = family.getName().getBytes(); Map<String,Object> familyProps = createPropertiesMap(htableDesc.getColumnFamily(familyName).getValues()); families.add(new Pair<>(familyName, familyProps)); } // Always create default column family, because we don't know in advance if we'll // need it for an index with no covered columns. byte[] defaultFamilyName = table.getDefaultFamilyName() == null ? QueryConstants.DEFAULT_COLUMN_FAMILY_BYTES : table.getDefaultFamilyName().getBytes(); families.add(new Pair<>(defaultFamilyName, Collections.<String,Object>emptyMap())); byte[][] splits = null; if (table.getBucketNum() != null) { splits = SaltingUtil.getSalteByteSplitPoints(table.getBucketNum()); } // Transfer over table values into tableProps // TODO: encapsulate better Map<String,Object> tableProps = createPropertiesMap(htableDesc.getValues()); tableProps.put(PhoenixDatabaseMetaData.TRANSACTIONAL, table.isTransactional()); tableProps.put(PhoenixDatabaseMetaData.IMMUTABLE_ROWS, table.isImmutableRows()); ensureViewIndexTableCreated(physicalTableName, tableProps, families, splits, timestamp, isNamespaceMapped); }
public void invalidateAll(PTable table) { byte[] physicalName = table.getPhysicalName().getBytes(); List<PColumnFamily> families = table.getColumnFamilies(); if (families.isEmpty()) { invalidate(new GuidePostsKey(physicalName, SchemaUtil.getEmptyColumnFamily(table))); } else { for (PColumnFamily family : families) { invalidate(new GuidePostsKey(physicalName, family.getName().getBytes())); } } }
byte[] defaultCF = SchemaUtil.getEmptyColumnFamily(getTable()); byte[] cf = null; if ( !table.getColumnFamilies().isEmpty() && !whereConditions.isEmpty() ) { for(Pair<byte[], byte[]> where : context.getWhereConditionColumns()) { byte[] whereCF = where.getFirst();
private void setSharedIndexMaxVersion(PTable table, TableDescriptor tableDescriptor, TableDescriptorBuilder indexDescriptorBuilder) { if (table.getColumnFamilies().isEmpty()) { byte[] familyName = SchemaUtil.getEmptyColumnFamily(table); ColumnFamilyDescriptorBuilder indexColDescriptorBuilder = ColumnFamilyDescriptorBuilder.newBuilder(indexDescriptorBuilder.build().getColumnFamily(familyName)); ColumnFamilyDescriptor tableColDescriptor = tableDescriptor.getColumnFamily(familyName); indexColDescriptorBuilder.setMaxVersions(tableColDescriptor.getMaxVersions()); indexColDescriptorBuilder.setValue( Bytes.toBytes(PhoenixTransactionContext.PROPERTY_TTL),tableColDescriptor.getValue(Bytes.toBytes(PhoenixTransactionContext.PROPERTY_TTL))); indexDescriptorBuilder.removeColumnFamily(familyName); indexDescriptorBuilder.addColumnFamily(indexColDescriptorBuilder.build()); } else { for (PColumnFamily family : table.getColumnFamilies()) { byte[] familyName = family.getName().getBytes(); ColumnFamilyDescriptor indexColDescriptor = indexDescriptorBuilder.build().getColumnFamily(familyName); if (indexColDescriptor != null) { ColumnFamilyDescriptor tableColDescriptor = tableDescriptor.getColumnFamily(familyName); ColumnFamilyDescriptorBuilder indexColDescriptorBuilder = ColumnFamilyDescriptorBuilder.newBuilder(indexColDescriptor); indexColDescriptorBuilder.setMaxVersions(tableColDescriptor.getMaxVersions()); indexColDescriptorBuilder.setValue( Bytes.toBytes(PhoenixTransactionContext.PROPERTY_TTL),tableColDescriptor.getValue(Bytes.toBytes(PhoenixTransactionContext.PROPERTY_TTL))); indexDescriptorBuilder.removeColumnFamily(familyName); indexDescriptorBuilder.addColumnFamily(indexColDescriptorBuilder.build()); } } } }
if (index.getColumnFamilies().isEmpty()) { byte[] dataFamilyName = SchemaUtil.getEmptyColumnFamily(table); byte[] indexFamilyName = SchemaUtil.getEmptyColumnFamily(index); indexDescriptorBuilder.setColumnFamily(indexColDescriptor.build()); } else { for (PColumnFamily family : index.getColumnFamilies()) { byte[] familyName = family.getName().getBytes(); ColumnFamilyDescriptorBuilder indexColDescriptor = ColumnFamilyDescriptorBuilder.newBuilder(indexDescriptorBuilder.build().getColumnFamily(familyName));
List<PColumnFamily> families = logicalTable.getColumnFamilies(); if (families.isEmpty()) { connection.getQueryServices().invalidateStats(new GuidePostsKey(physicalName.getBytes(), SchemaUtil.getEmptyColumnFamily(logicalTable)));
} else { if (!dataTable.getColumnFamilies().isEmpty()) { for (Map.Entry<byte[],List<Cell>> entry : dataMutation.getFamilyCellMap().entrySet()) { PColumnFamily family = dataTable.getColumnFamily(entry.getKey());