use of org.apache.phoenix.schema.PColumn in project DataX by alibaba.
the class HbaseSQLHelper method getPColumnNames.
public static List<String> getPColumnNames(String connectionString, String tableName) throws SQLException {
Connection con = DriverManager.getConnection(connectionString);
PhoenixConnection phoenixConnection = con.unwrap(PhoenixConnection.class);
MetaDataClient metaDataClient = new MetaDataClient(phoenixConnection);
PTable table = metaDataClient.updateCache("", tableName).getTable();
List<String> columnNames = new ArrayList<String>();
for (PColumn pColumn : table.getColumns()) {
if (!pColumn.getName().getString().equals(SaltingUtil.SALTING_COLUMN_NAME))
columnNames.add(pColumn.getName().getString());
else
LOG.info(tableName + " is salt table");
}
return columnNames;
}
use of org.apache.phoenix.schema.PColumn in project phoenix by apache.
the class AlterMultiTenantTableWithViewsIT method getIndexOfPkColumn.
private int getIndexOfPkColumn(PhoenixConnection conn, String columnName, String tableName) throws SQLException {
String normalizedTableName = SchemaUtil.normalizeIdentifier(tableName);
PTable table = conn.getTable(new PTableKey(conn.getTenantId(), normalizedTableName));
List<PColumn> pkCols = table.getPKColumns();
String normalizedColumnName = SchemaUtil.normalizeIdentifier(columnName);
int i = 0;
for (PColumn pkCol : pkCols) {
if (pkCol.getName().getString().equals(normalizedColumnName)) {
return i;
}
i++;
}
return -1;
}
use of org.apache.phoenix.schema.PColumn in project phoenix by apache.
the class EncodedColumnsUtil method setQualifiersForColumnsInFamily.
public static Pair<Integer, Integer> setQualifiersForColumnsInFamily(PTable table, String cf, NavigableSet<byte[]> qualifierSet) throws ColumnFamilyNotFoundException {
QualifierEncodingScheme encodingScheme = table.getEncodingScheme();
checkArgument(encodingScheme != QualifierEncodingScheme.NON_ENCODED_QUALIFIERS);
Collection<PColumn> columns = table.getColumnFamily(cf).getColumns();
if (columns.size() > 0) {
int[] qualifiers = new int[columns.size()];
int i = 0;
for (PColumn col : columns) {
qualifierSet.add(col.getColumnQualifierBytes());
qualifiers[i++] = encodingScheme.decode(col.getColumnQualifierBytes());
}
Arrays.sort(qualifiers);
return new Pair<>(qualifiers[0], qualifiers[qualifiers.length - 1]);
}
return null;
}
use of org.apache.phoenix.schema.PColumn in project phoenix by apache.
the class PhoenixRuntime method getPColumn.
@Deprecated
private static PColumn getPColumn(PTable table, @Nullable String familyName, String columnName) throws SQLException {
if (table == null) {
throw new SQLException("Table must not be null.");
}
if (columnName == null) {
throw new SQLException("columnName must not be null.");
}
// normalize and remove quotes from family and column names before looking up.
familyName = SchemaUtil.normalizeIdentifier(familyName);
columnName = SchemaUtil.normalizeIdentifier(columnName);
PColumn pColumn = null;
if (familyName != null) {
PColumnFamily family = table.getColumnFamily(familyName);
pColumn = family.getPColumnForColumnName(columnName);
} else {
pColumn = table.getColumnForColumnName(columnName);
}
return pColumn;
}
use of org.apache.phoenix.schema.PColumn in project phoenix by apache.
the class MetaDataUtil method getAutoPartitionColumnName.
public static String getAutoPartitionColumnName(PTable parentTable) {
List<PColumn> parentTableColumns = parentTable.getPKColumns();
PColumn column = parentTableColumns.get(getAutoPartitionColIndex(parentTable));
return column.getName().getString();
}
Aggregations