Append to an existing file in the namespace.
177946
public LocatedBlock appendFile(String src, String holder, String clientMachine,
      BlockMetaInfoType type) throws IOException {
    if (supportAppends == false) {
      throw new IOException("Append to hdfs not supported." +
        " Please refer to dfs.support.append configuration parameter.");
    }
    startFileInternal(src, null, holder, clientMachine, false, true,
      false, (short) maxReplication, (long) 0);
    getEditLog().logSync();

    //
    // Create a LocatedBlock object for the last block of the file
    // to be returned to the client. Return null if the file does not
    // have a partial block at the end.
    //
    LocatedBlock lb = null;
    writeLock();
    try {
      // Need to re-check existence here, since the file may have been deleted
      // in between the synchronized blocks
      INodeFileUnderConstruction file = checkLease(src, holder);
      INode.enforceRegularStorageINode(file,
          "Append to hdfs not supported for " + src);

      Block[] blocks = file.getBlocks();
      if (blocks != null && blocks.length > 0) {
        Block last = blocks[blocks.length - 1];
        BlockInfo storedBlock = blocksMap.getStoredBlock(last);
        if (file.getPreferredBlockSize() > storedBlock.getNumBytes()) {
          long fileLength = file.computeContentSummary().getLength();          
          DatanodeDescriptor[] targets = new DatanodeDescriptor[blocksMap.numNodes(last)];
          Iterator<DatanodeDescriptor> it = blocksMap.nodeIterator(last);
          for (int i = 0; it != null && it.hasNext(); i++) {
            targets[i] = it.next();
          }
          // remove the replica locations of this block from the blocksMap
          for (int i = 0; i < targets.length; i++) {
            targets[i].removeBlock(storedBlock);
          }
          // set the locations of the last block in the lease record
          file.setLastBlock(storedBlock, targets);

          // We make a copy of block object to prevent a data race that after
          // releasing the lock, before serializing the result object to clients,
          // the block object is changed. It is unlikely for this append() case
          // so potentially we can avoid the object copying. Since append() doesn't
          // happen frequently, now we make a copy to be extra safe.
          Block lastCopy = null;
          if (last != null) {
            lastCopy = new Block(last);
            // bump up the generation stamp for the lastcopy.
            if (type.equals(
                  BlockMetaInfoType.VERSION_AND_NAMESPACEID_AND_OLD_GS)) {
              lastCopy.setGenerationStamp(this.nextGenerationStamp());
            }
          }
          lb = createLocatedBlock(lastCopy, targets, fileLength
              - storedBlock.getNumBytes(),
              DataTransferProtocol.DATA_TRANSFER_VERSION, 
              last.getGenerationStamp(), type);
          
          // Remove block from replication queue.
          neededReplications.remove(storedBlock, -1);

          // remove this block from the list of pending blocks to be deleted.
          // This reduces the possibility of triggering HADOOP-1349.
          //
          for (DatanodeDescriptor dd : targets) {
            String datanodeId = dd.getStorageID();
            LightWeightHashSet<Block> v = recentInvalidateSets.get(datanodeId);
            if (v != null && v.remove(last)) {
              if (v.isEmpty()) {
                recentInvalidateSets.remove(datanodeId);
              }
              pendingDeletionBlocksCount--;
            }
          }
        }
      }
    } finally {
      writeUnlock();
    }
    if (lb != null) {
      if (NameNode.stateChangeLog.isDebugEnabled()) {
        NameNode.stateChangeLog.debug("DIR* NameSystem.appendFile: file "
          + src + " for " + holder + " at " + clientMachine
          + " block " + lb.getBlock()
          + " block size " + lb.getBlock().getNumBytes());
      }
    }

    if (auditLog.isInfoEnabled()) {
      logAuditEvent(getCurrentUGI(),
        Server.getRemoteIp(),
        "append", src, null, null);
    }
    return lb;
  }
793824
def _add(self, codeobj):
        """"""
        assert isinstance(codeobj, (CodeNamespace, CodeClass,
                                    CodeFunction, CodeVariable))
        self.children.append(codeobj)
83078
def Append(self, component=None, **kwarg):
    """"""
    if component is None:
      component = self.__class__(**kwarg)

    if self.HasField("pathtype"):
      self.last.nested_path = component
    else:
      for k, v in iteritems(kwarg):
        setattr(self, k, v)

      self.SetRawData(component.GetRawData())

    return self
994653
def append(self, resultFile, resultElem, all_columns=False):
        
        self._xml_results += [(result, resultFile) for result in _get_run_tags_from_xml(resultElem)]
        for attrib, values in RunSetResult._extract_attributes_from_result(resultFile, resultElem).items():
            self.attributes[attrib].extend(values)

        if not self.columns:
            self.columns = RunSetResult._extract_existing_columns_from_result(resultFile, resultElem, all_columns)
339986
def Append(self, desc):
    """"""
    if desc not in self.descriptors:
      self.descriptors.append(desc)
      self.descriptor_map[desc.name] = desc
      self.descriptor_names.append(desc.name)
276662
def add_file(self, name, required=False, error=None, extensions=None):
        
        if name is None:
            return
        self.file_arguments.append(dict(
            name=name,
            required=required,
            error=error,
            extensions=extensions))
88924
def add_output_file(self, filename):
    
    if filename not in self.__output_files:
      self.__output_files.append(filename)
532278
function appendFilename(pathStr, valueToAppend) {
  var pfile = path.parse(pathStr);
  var result = Array.prototype.join.call([
    pfile.dir,
    '/',
    pfile.name,
    valueToAppend,
    pfile.ext
  ], '');
  return result;
}
183932
def _append_value(self, value, _file, _name):
        
        _tabs = '\t' * self._tctr
        _cmma = ',\n' if self._vctr[self._tctr] else ''
        _keys = '{cmma}{tabs}"{name}" :'.format(cmma=_cmma, tabs=_tabs, name=_name)

        _file.seek(self._sptr, os.SEEK_SET)
        _file.write(_keys)

        self._vctr[self._tctr] += 1
        self._append_object(value, _file)
286536
private void appendToFile(RandomAccessFile output, InputStream input)
            throws IOException {
        byte[] buffer = new byte[1024 * 1024];
        int bytesRead = 0;
        do {
            bytesRead = input.read(buffer);
            if (bytesRead < 0)
                break;
            output.write(buffer, 0, bytesRead);
        } while (bytesRead > 0);
        return;
    }
982628
def add_file(self, filename):
        """"""

        assert not self.final, 'Trying to mutate a final graph.'
        self.add_source_file(filename)
        resolved, unresolved = self.get_file_deps(filename)
        self.graph.add_node(filename)
        for f in resolved:
            self.graph.add_node(f)
            self.graph.add_edge(filename, f)
        for imp in unresolved:
            self.broken_deps[filename].add(imp)
1272422
def add_file(self, file, filename):
        
        self.files['_{}'.format(filename)] = (filename, file)
418961
def append(self, pattern):
        """"""
        assert isinstance(pattern, Pattern)
        self.patterns.append(pattern)
        if self._all_files is not None:
            self._all_files = self._all_files or pattern.all_files()
595974
def _append_value(self, value, _file, _name):
        
        if self._flag:
            _keys = _name + '\n'
        else:
            _keys = '\n' + _name + '\n'
        _file.seek(self._sptr, os.SEEK_SET)
        _file.write(_keys)

        self._bctr = collections.defaultdict(int)    # blank branch counter dict
        self._append_branch(value, _file)
1225254
def _init_append(self):
        
        # Require to load the full file content in buffer
        self._write_buffer[:] = self._readall()

        # Make initial seek position to current end of file
        self._seek = self._size
111692
def add_file(self, f):
        """"""

        if not self.files:
            self.files = set()

        self.files.add(f)

        self.locations.set(f.type_)
301967
def append_to_path (path, directory):
    """"""
    if not os.path.isdir(directory) or directory in path:
        return path
    if not path.endswith(os.pathsep):
        path += os.pathsep
    return path + directory