@Override public Object getPTableValue(PTable table) { return table.getImmutableStorageScheme(); }
@Override public ImmutableStorageScheme getImmutableStorageScheme() { return delegate.getImmutableStorageScheme(); }
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); }
@Override public Void visit(ProjectedColumnExpression expression) { if (expression.getDataType().isArrayType()) { indexProjectedColumns.add(expression); PColumn col = expression.getColumn(); PTable table = context.getCurrentTable().getTable(); KeyValueColumnExpression keyValueColumnExpression; if (table.getImmutableStorageScheme() != ImmutableStorageScheme.ONE_CELL_PER_COLUMN) { keyValueColumnExpression = new SingleCellColumnExpression(col, col.getName().getString(), table.getEncodingScheme(), table.getImmutableStorageScheme()); } else { keyValueColumnExpression = new KeyValueColumnExpression(col); } indexKVs.add(keyValueColumnExpression); copyOfChildren.set(0, keyValueColumnExpression); Integer count = arrayExpressionCounts.get(expression); arrayExpressionCounts.put(expression, count != null ? (count - 1) : -1); } return null; } });
private void serializeDataTableColumnsToJoin(Scan scan, Set<PColumn> dataColumns, PTable dataTable) { ByteArrayOutputStream stream = new ByteArrayOutputStream(); try { DataOutputStream output = new DataOutputStream(stream); boolean storeColsInSingleCell = dataTable.getImmutableStorageScheme() == ImmutableStorageScheme.SINGLE_CELL_ARRAY_WITH_OFFSETS; if (storeColsInSingleCell) { // if storeColsInSingleCell is true all columns of a given column family are stored in a single cell scan.setAttribute(BaseScannerRegionObserver.COLUMNS_STORED_IN_SINGLE_CELL, QueryConstants.EMPTY_COLUMN_VALUE_BYTES); } WritableUtils.writeVInt(output, dataColumns.size()); for (PColumn column : dataColumns) { byte[] cf = column.getFamilyName().getBytes(); byte[] cq = column.getColumnQualifierBytes(); Bytes.writeByteArray(output, cf); Bytes.writeByteArray(output, cq); } scan.setAttribute(BaseScannerRegionObserver.DATA_TABLE_COLUMNS_TO_JOIN, stream.toByteArray()); } catch (IOException e) { throw new RuntimeException(e); } finally { try { stream.close(); } catch (IOException e) { throw new RuntimeException(e); } } }
for (int index = 0; index < logicalNames.size(); index++) { 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++) {
for (int index = 0; index < logicalNames.size(); index++) { 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++) {
public static void setColumns(PColumn column, PTable table, Scan scan) { if (table.getImmutableStorageScheme() == ImmutableStorageScheme.SINGLE_CELL_ARRAY_WITH_OFFSETS) { // if a table storage scheme is COLUMNS_STORED_IN_SINGLE_CELL set then all columns of a column family are stored in a single cell // (with the qualifier name being same as the family name), just project the column family here // so that we can calculate estimatedByteSize correctly in ProjectionCompiler scan.addFamily(column.getFamilyName().getBytes()); } else { if (column.getColumnQualifierBytes() != null) { scan.addColumn(column.getFamilyName().getBytes(), column.getColumnQualifierBytes()); } } }
private void assertColumnEncodingMetadata(QualifierEncodingScheme expectedEncodingScheme, ImmutableStorageScheme expectedStorageScheme, String tableName, Connection conn) throws Exception { PhoenixConnection phxConn = conn.unwrap(PhoenixConnection.class); PTable table = phxConn.getTable(new PTableKey(null, tableName)); assertEquals(expectedEncodingScheme, table.getEncodingScheme()); assertEquals(expectedStorageScheme, table.getImmutableStorageScheme()); }
Expression expression = table.getImmutableStorageScheme() == ImmutableStorageScheme.SINGLE_CELL_ARRAY_WITH_OFFSETS ? new SingleCellColumnExpression(column, displayName, table.getEncodingScheme(), table.getImmutableStorageScheme()) : new KeyValueColumnExpression(column, displayName);
@Override public Expression visit(ColumnParseNode node) throws SQLException { ColumnRef ref = resolveColumn(node); TableRef tableRef = ref.getTableRef(); Expression newColumnExpression = ref.newColumnExpression(node.isTableNameCaseSensitive(), node.isCaseSensitive()); if (tableRef.equals(context.getCurrentTable()) && !SchemaUtil.isPKColumn(ref.getColumn())) { byte[] cq = tableRef.getTable().getImmutableStorageScheme() == ImmutableStorageScheme.SINGLE_CELL_ARRAY_WITH_OFFSETS ? QueryConstants.SINGLE_KEYVALUE_COLUMN_QUALIFIER_BYTES : ref.getColumn().getColumnQualifierBytes(); // track the where condition columns. Later we need to ensure the Scan in HRS scans these column CFs context.addWhereConditionColumn(ref.getColumn().getFamilyName().getBytes(), cq); } return newColumnExpression; }
new SingleCellColumnExpression(localIndexCol, indexColumnName, localIndex2.getEncodingScheme(), localIndex2.getImmutableStorageScheme()); ImmutableBytesPtr ptr = new ImmutableBytesPtr(); colExpression.evaluate(new ResultTuple(result), ptr);
KeyValueColumnExpression colExpression = new SingleCellColumnExpression(dataColumn, "V2", dataTable.getEncodingScheme(), dataTable.getImmutableStorageScheme()); ImmutableBytesPtr ptr = new ImmutableBytesPtr(); colExpression.evaluate(new ResultTuple(result), ptr); new SingleCellColumnExpression(glovalIndexCol, "0:V2", globalIndexTable.getEncodingScheme(), globalIndexTable.getImmutableStorageScheme()); ImmutableBytesPtr ptr = new ImmutableBytesPtr(); colExpression.evaluate(new ResultTuple(result), ptr); new SingleCellColumnExpression(localIndexCol, "0:V2", localIndexTable.getEncodingScheme(), localIndexTable.getImmutableStorageScheme()); ImmutableBytesPtr ptr = new ImmutableBytesPtr(); assertTrue(colExpression.evaluate(new ResultTuple(result), ptr));
PTable table = conn.unwrap(PhoenixConnection.class).getTable(new PTableKey(null, dataTableName)); PColumn nameColumn = table.getColumnForColumnName("NAME"); byte[] qualifier = table.getImmutableStorageScheme()== ImmutableStorageScheme.SINGLE_CELL_ARRAY_WITH_OFFSETS ? QueryConstants.SINGLE_KEYVALUE_COLUMN_QUALIFIER_BYTES : nameColumn.getColumnQualifierBytes(); assertTrue(rs.containsColumn(QueryConstants.DEFAULT_COLUMN_FAMILY_BYTES, qualifier)); assertTrue(rs.size() == 2); // 2 because it also includes the empty key value column KeyValueColumnExpression colExpression = table.getImmutableStorageScheme() == ImmutableStorageScheme.SINGLE_CELL_ARRAY_WITH_OFFSETS ? new SingleCellColumnExpression(nameColumn, "NAME", table.getEncodingScheme(), table.getImmutableStorageScheme()) : new KeyValueColumnExpression(nameColumn); ImmutableBytesPtr ptr = new ImmutableBytesPtr();
if (index.getImmutableStorageScheme() == ImmutableStorageScheme.SINGLE_CELL_ARRAY_WITH_OFFSETS) { scan.addFamily(columnRef.getFamily()); } else {
scan.setAttribute(BaseScannerRegionObserver.IMMUTABLE_STORAGE_ENCODING_SCHEME, new byte[]{table.getImmutableStorageScheme().getSerializedMetadataValue()});
.setAutoPartitionSeqName(table.getAutoPartitionSeqName()) .setAppendOnlySchema(table.isAppendOnlySchema()) .setImmutableStorageScheme(table.getImmutableStorageScheme()) .setQualifierEncodingScheme(table.getEncodingScheme()) .setBaseColumnCount(BASE_TABLE_BASE_COLUMN_COUNT)
.setAutoPartitionSeqName(table.getAutoPartitionSeqName()) .setAppendOnlySchema(table.isAppendOnlySchema()) .setImmutableStorageScheme(table.getImmutableStorageScheme() == null ? ImmutableStorageScheme.ONE_CELL_PER_COLUMN : table.getImmutableStorageScheme()) .setQualifierEncodingScheme(table.getEncodingScheme() == null ? QualifierEncodingScheme.NON_ENCODED_QUALIFIERS : table.getEncodingScheme())
PTable table = context.getCurrentTable().getTable(); QualifierEncodingScheme encodingScheme = table.getEncodingScheme(); ImmutableStorageScheme storageScheme = table.getImmutableStorageScheme(); Counter.Count count = counter.getCount(); boolean allCFs = false;