public StringBuilder toString(StringBuilder sb) { sb.append("HBaseOperationContext={"); sb.append("Operation={").append(operation).append("} "); sb.append("User ={").append(user).append("} "); if (nameSpace != null ) { sb.append("NameSpace={").append(nameSpace).append("}"); } else { if (namespaceDescriptor != null) { sb.append("NameSpace={").append(namespaceDescriptor.toString()).append("}"); } } if (tableName != null ) { sb.append("Table={").append(tableName).append("}"); } else { if ( hColumnDescriptor != null) { sb.append("Table={").append(hTableDescriptor.toString()).append("}"); } } if (columnFamily != null ) { sb.append("Columm Family={").append(columnFamily).append("}"); } else { if ( hColumnDescriptor != null) { sb.append("Columm Family={").append(hColumnDescriptor.toString()).append("}"); } } sb.append("Message ={").append(getMessages()).append("} "); sb.append(" }"); return sb; }
public StringBuilder toString(StringBuilder sb) { sb.append("HBaseOperationContext={"); sb.append("Operation={").append(operation).append("} "); sb.append("User ={").append(user).append("} "); if (nameSpace != null ) { sb.append("NameSpace={").append(nameSpace).append("}"); } else { if (namespaceDescriptor != null) { sb.append("NameSpace={").append(namespaceDescriptor.toString()).append("}"); } } if (tableName != null ) { sb.append("Table={").append(tableName).append("}"); } else { if ( hColumnDescriptor != null) { sb.append("Table={").append(hTableDescriptor.toString()).append("}"); } } if (columnFamily != null ) { sb.append("Columm Family={").append(columnFamily).append("}"); } else { if ( hColumnDescriptor != null) { sb.append("Columm Family={").append(hColumnDescriptor.toString()).append("}"); } } sb.append("Message ={").append(getMessages()).append("} "); sb.append(" }"); return sb; }
/** * Add column to a table * @param tableName * @param hcd * @return Modified HTableDescriptor with new column added. * @throws IOException */ public HTableDescriptor addColumn(byte[] tableName, HColumnDescriptor hcd) throws IOException { LOG.info("AddColumn. Table = " + Bytes.toString(tableName) + " HCD = " + hcd.toString()); HTableDescriptor htd = this.services.getTableDescriptors().get(tableName); if (htd == null) { throw new InvalidFamilyOperationException("Family '" + hcd.getNameAsString() + "' cannot be modified as HTD is null"); } htd.addFamily(hcd); this.services.getTableDescriptors().add(htd); return htd; } }
/** * Modify Column of a table * @param tableName * @param hcd HColumnDesciptor * @return Modified HTableDescriptor with the column modified. * @throws IOException */ public HTableDescriptor modifyColumn(byte[] tableName, HColumnDescriptor hcd) throws IOException { LOG.info("AddModifyColumn. Table = " + Bytes.toString(tableName) + " HCD = " + hcd.toString()); HTableDescriptor htd = this.services.getTableDescriptors().get(tableName); byte [] familyName = hcd.getName(); if(!htd.hasFamily(familyName)) { throw new InvalidFamilyOperationException("Family '" + Bytes.toString(familyName) + "' doesn't exists so cannot be modified"); } htd.addFamily(hcd); this.services.getTableDescriptors().add(htd); return htd; }
hcd.setCompressionType(reader.getCompressionAlgorithm()); LOG.info("Setting compression " + hcd.getCompressionType().name() + " for family " + hcd.toString());
hcol.readFields(new DataInputStream(new ByteArrayInputStream(hcolBytes))); LOG.info("Output path: {}", outputPath); LOG.info("HColumnDescriptor: {}", hcol.toString()); Configuration noCacheConf = new Configuration(conf); noCacheConf.setFloat(HConstants.HFILE_BLOCK_CACHE_SIZE_KEY, 0.0f);
/** * Add column to a table * @param tableName * @param hcd * @return Modified HTableDescriptor with new column added. * @throws IOException */ public HTableDescriptor addColumn(TableName tableName, HColumnDescriptor hcd) throws IOException { LOG.info("AddColumn. Table = " + tableName + " HCD = " + hcd.toString()); HTableDescriptor htd = this.services.getTableDescriptors().get(tableName); if (htd == null) { throw new InvalidFamilyOperationException("Family '" + hcd.getNameAsString() + "' cannot be modified as HTD is null"); } htd.addFamily(hcd); this.services.getTableDescriptors().add(htd); return htd; }
/** * Add the column family to the file system */ private void updateTableDescriptor(final MasterProcedureEnv env) throws IOException { // Update table descriptor LOG.info("AddColumn. Table = " + tableName + " HCD = " + cfDescriptor.toString()); HTableDescriptor htd = env.getMasterServices().getTableDescriptors().get(tableName); if (htd.hasFamily(cfDescriptor.getName())) { // It is possible to reach this situation, as we could already add the column family // to table descriptor, but the master failover happens before we complete this state. // We should be able to handle running this function multiple times without causing problem. return; } htd.addFamily(cfDescriptor); env.getMasterServices().getTableDescriptors().add(htd); }
/** * Modify the column family from the file system */ private void updateTableDescriptor(final MasterProcedureEnv env) throws IOException { // Update table descriptor LOG.info("ModifyColumnFamily. Table = " + tableName + " HCD = " + cfDescriptor.toString()); HTableDescriptor htd = env.getMasterServices().getTableDescriptors().get(tableName); htd.modifyFamily(cfDescriptor); env.getMasterServices().getTableDescriptors().add(htd); }
@Override public void bulkHFile(final HColumnDescriptor hcd, final FileStatus hfileStatus) throws IOException { Path hfile = hfileStatus.getPath(); HFile.Reader reader = HFile.createReader(fs, hfile, new CacheConfig(getConf()), getConf()); try { if (hcd.getCompressionType() != reader.getFileContext().getCompression()) { hcd.setCompressionType(reader.getFileContext().getCompression()); LOG.info("Setting compression " + hcd.getCompressionType().name() + " for family " + hcd.toString()); } reader.loadFileInfo(); byte[] first = reader.getFirstRowKey(); byte[] last = reader.getLastRowKey(); LOG.info("Trying to figure out region boundaries hfile=" + hfile + " first=" + Bytes.toStringBinary(first) + " last=" + Bytes.toStringBinary(last)); // To eventually infer start key-end key boundaries Integer value = map.containsKey(first)? map.get(first):0; map.put(first, value+1); value = map.containsKey(last)? map.get(last):0; map.put(last, value-1); } finally { reader.close(); } } });
/** * Modify Column of a table * @param tableName * @param hcd HColumnDesciptor * @return Modified HTableDescriptor with the column modified. * @throws IOException */ public HTableDescriptor modifyColumn(TableName tableName, HColumnDescriptor hcd) throws IOException { LOG.info("AddModifyColumn. Table = " + tableName + " HCD = " + hcd.toString()); HTableDescriptor htd = this.services.getTableDescriptors().get(tableName); byte [] familyName = hcd.getName(); if(!htd.hasFamily(familyName)) { throw new InvalidFamilyOperationException("Family '" + Bytes.toString(familyName) + "' doesn't exists so cannot be modified"); } htd.modifyFamily(hcd); this.services.getTableDescriptors().add(htd); return htd; }