@Override public ColumnRef resolveColumn(String schemaName, String tableName, String colName) throws SQLException { PColumn column = tableName != null ? tableRef.getTable().getColumnFamily(tableName).getPColumnForColumnName(colName) : tableRef.getTable().getColumnForColumnName(colName); return new ColumnRef(tableRef, column.getPosition()); }
@Override public PTableRef getTableRef(PTableKey key) throws TableNotFoundException { PTableRef ref = metaData.get(key); if (ref == null) { throw new TableNotFoundException(key.getName()); } return ref; }
private String getDataColFullName(PColumn dCol) { String dColFullName = ""; if (dCol.getFamilyName() != null) { dColFullName += dCol.getFamilyName().getString() + QueryConstants.NAME_SEPARATOR; } dColFullName += dCol.getName().getString(); return dColFullName; }
public KeyValueColumnExpression(PColumn column) { super(column); this.cf = column.getFamilyName().getBytes(); // for backward compatibility since older tables won't have columnQualifierBytes in their metadata this.cq = column.getColumnQualifierBytes() != null ? column.getColumnQualifierBytes() : column.getName().getBytes(); this.displayName = column.getName().getString(); }
private String getFullTableName(TableRef dataTableRef) { String schemaName = dataTableRef.getTable().getSchemaName().getString(); String tableName = dataTableRef.getTable().getTableName().getString(); String fullName = schemaName == null ? ("\"" + tableName + "\"") : ("\"" + schemaName + "\"" + QueryConstants.NAME_SEPARATOR + "\"" + tableName + "\""); return fullName; }
private static boolean hasInactiveIndex(PMetaData metaCache, PTableKey key) throws TableNotFoundException { PTable table = metaCache.getTableRef(key).getTable(); for (PTable index : table.getIndexes()) { if (index.getIndexState() == PIndexState.INACTIVE) { return true; } } return false; }
public TupleProjector(Expression[] expressions) { this.expressions = expressions; KeyValueSchemaBuilder builder = new KeyValueSchemaBuilder(0); for (int i = 0; i < expressions.length; i++) { builder.addField(expressions[i]); } schema = builder.build(); valueSet = ValueBitSet.newInstance(schema); }
public MetaDataMutationResult(MutationCode returnCode, long currentTime, PTable table, PColumn column) { this(returnCode, currentTime, table); if(column != null){ this.columnName = column.getName().getBytes(); this.familyName = column.getFamilyName().getBytes(); } }
private PRow newRow(KeyValueBuilder builder, long ts, ImmutableBytesWritable key, int i, boolean hasOnDupKey, byte[]... values) { PRow row = new PRowImpl(builder, key, ts, getBucketNum(), hasOnDupKey); if (i < values.length) { for (PColumnFamily family : getColumnFamilies()) { for (PColumn column : family.getColumns()) { row.setValue(column, values[i++]); if (i == values.length) return row; } } } return row; }
private static PTable getFromTable(PMetaData metaData, String name, TestTimeKeeper timeKeeper) throws TableNotFoundException { PTable table = metaData.getTableRef(new PTableKey(null,name)).getTable(); timeKeeper.incrementTime(); return table; }
private static void setValueBitSet(KeyValueSchema schema, ValueBitSet valueSet) { for (int i = 0; i < schema.getFieldCount() - schema.getMinNullable(); i++) { if ((i & 1) == 1) { valueSet.set(i); } } }
private static void addToTable(PMetaData metaData, String name, int size, TestTimeKeeper timeKeeper) throws SQLException { PTable table = new PSizedTable(new PTableKey(null,name), size); metaData.addTable(table, System.currentTimeMillis()); timeKeeper.incrementTime(); }
public static ValueBitSet newInstance(ValueSchema schema) { if (schema.getFieldCount() == schema.getMinNullable()) { return EMPTY_VALUE_BITSET; } return new ValueBitSet(schema); }
private static int getSaltBuckets(TableAlreadyExistsException e) { PTable table = e.getTable(); Integer sequenceSaltBuckets = table == null ? null : table.getBucketNum(); return sequenceSaltBuckets == null ? 0 : sequenceSaltBuckets; }
/** * Get a PTableImpl.Builder from an existing PTable and set the builder columns * @param table Original PTable * @param columns Columns to set in the builder for the new PTable to be constructed * @return PTable builder object based on an existing PTable */ public static PTableImpl.Builder builderWithColumns(PTable table, Collection<PColumn> columns) { return builderFromExisting(table).setColumns(columns); }
public PTableImpl build() throws SQLException { // Note that we call initDerivedAttributes to populate derivable attributes if // this.columns is set in the PTableImpl.Builder object return (this.columns == null) ? new PTableImpl(this) : new PTableImpl(this.initDerivedAttributes()); }
@Override public KeyValueSchema build() { List<Field> condensedFields = buildFields(); return new KeyValueSchema(this.minNullable, condensedFields); }
private static boolean hasIndexWithState(PMetaData metaCache, PTableKey key, PIndexState expectedState) throws TableNotFoundException { PTable table = metaCache.getTableRef(key).getTable(); for (PTable index : table.getIndexes()) { if (index.getIndexState() == expectedState) { return true; } } return false; }