TODO: Can't Buffer hold `intester` as an instance variable?
553003
protected void flushInternal(Ingester ingester, boolean force)
            throws IOException
    {
        moveRetentionBuffersToFlushable(force);

        TaggableBuffer flushableBuffer;
        while (!Thread.currentThread().isInterrupted() &&
                (flushableBuffer = flushableBuffers.poll()) != null) {
            boolean keepBuffer = false;
            try {
                LOG.trace("flushInternal(): bufferUsage={}, flushableBuffer={}", getBufferUsage(), flushableBuffer);
                String tag = flushableBuffer.getTag();
                ByteBuffer dataBuffer = flushableBuffer.getByteBuffer();
                ingester.ingest(tag, dataBuffer);
            }
            catch (IOException e) {
                LOG.warn("Failed to send data. The data is going to be saved into the buffer again: data={}", flushableBuffer);
                keepBuffer = true;
                throw e;
            }
            finally {
                if (keepBuffer) {
                    try {
                        flushableBuffers.put(flushableBuffer);
                    }
                    catch (InterruptedException e1) {
                        LOG.warn("Failed to save the data into the buffer. Trying to save it in extra buffer: chunk={}", flushableBuffer);
                        Thread.currentThread().interrupt();
                        backupBuffers.add(flushableBuffer);
                    }
                }
                else {
                    bufferPool.returnBuffer(flushableBuffer.getByteBuffer());
                }
            }
        }
    }
1095588
function cloneBuffer(buffer, offset = 0, length = buffer.length) {
    if (!context || context.isFake) {
        return buffer;
    }
    const numChannels = buffer.numberOfChannels;
    const cloned = context.createBuffer(numChannels, length, buffer.sampleRate);
    for (let i = 0; i < numChannels; i++) {
        cloned.getChannelData(i)
            .set(buffer.getChannelData(i).slice(offset, offset + length));
    }
    return cloned;
}
997666
private static void padInt(StringBuilder buffer, int value, int length) {
        String strValue = Integer.toString(value);
        for (int i = length - strValue.length(); i > 0; i--) {
            buffer.append('0');
        }
        buffer.append(strValue);
    }
1144819
def insert_text(self, string):
        """
        self.l_buffer.insert_text(string, self.argument_reset)
        self.finalize()
507063
function bufferFromArrayBuffer(arrayBuffer) {
  const buffer = Buffer.alloc(arrayBuffer.byteLength);
  const view = new Uint8Array(arrayBuffer);

  for (let i = 0; i < buffer.length; ++i) {
    buffer[i] = view[i];
  }

  return buffer;
}
555411
private ByteBuf buffer(int i) {
        ByteBuf b = buffers[i];
        return b instanceof Component ? ((Component) b).buf : b;
    }
1242356
private void bufferRows2() throws IOException {
		BinaryRow copy = key2.copy();
		buffer2.reset();
		do {
			buffer2.add(row2);
		} while (nextRow2() && keyComparator.compare(key2, copy) == 0);
		buffer2.complete();
	}
72165
function castBuffer (val) {
  if (Buffer.isBuffer(val)) {
    return val
  }

  val = toJSON(val)
  var args = assertArgs([val], {
    val: ['string', 'array', 'object', 'number', 'boolean']
  })
  val = args.val

  var str

  if (Array.isArray(val)) {
    val = val.map(toJSON)
    str = JSON.stringify(val)
  } else if (isObject(val)) {
    val = toJSON(val)
    str = JSON.stringify(val)
  } else { // val is a string, number, or boolean
    str = val + ''
  }

  return new Buffer(str)
}
782411
function(identifier, typemap, args, error) {
		var bufArray = [ new Buffer([ module.exports.EnumExecutionCode.ExecFunction ]) ];
		bufArray.push(new Buffer(4)); // [1] = reserverd for total payload size, minus the execution code
		
		var buf = new Buffer(4);
		buf.writeUInt32LE(identifier.length);
		bufArray.push(buf);
		
		var tempBuf = new Buffer(identifier);
		bufArray.push(tempBuf);
		
		var payloadLength = 4 + identifier.length;
		for(var i = 0; i < args.length; i++) {
			var iStr = i.toString();
			var argtype = typemap[iStr];
			
			if(!argtype) {
				if(args[i] === null) {
					argtype = 'null';
				}
				else {
					switch(typeof args[i]) {
						case 'number':
							if(args[i] === (args[i]|0)) {
								argtype = 'int'; // Default to int for normal numbers
							}
							else {
								argtype = 'float'; // float for anything else
							}
							break;
						case 'string':
							argtype = 'string';
							break;
						case 'boolean':
							argtype = 'boolean';
							break;
						case 'undefined':
							argtype = 'undefined';
							break;
					}
				}
				typemap[iStr] = argtype;
			}
			
			var dataType = module.exports.EnumDataType[argtype];
			if(dataType !== undefined) {
				switch(dataType) {
					case module.exports.EnumDataType.byte:
						tempBuf = new Buffer(1);
						tempBuf.writeInt8(args[i], 0);
						break;
					case module.exports.EnumDataType.ubyte:
						tempBuf = new Buffer(1);
						tempBuf.writeUInt8(args[i], 0);
						break;
					case module.exports.EnumDataType.short:
						tempBuf = new Buffer(2);
						tempBuf.writeInt16LE(args[i], 0);
						break;
					case module.exports.EnumDataType.ushort:
						tempBuf = new Buffer(2);
						tempBuf.writeUInt16LE(args[i], 0);
						break;
					case module.exports.EnumDataType.int:
						tempBuf = new Buffer(4);
						tempBuf.writeInt32LE(args[i], 0);
						break;
					case module.exports.EnumDataType.uint:
						tempBuf = new Buffer(4);
						tempBuf.writeUInt32LE(args[i], 0);
						break;
					case module.exports.EnumDataType.float:
						tempBuf = new Buffer(4);
						tempBuf.writeFloatLE(args[i], 0);
						break;
					case module.exports.EnumDataType.double:
						tempBuf = new Buffer(8);
						tempBuf.writeDoubleLE(args[i], 0);
						break;
					case module.exports.EnumDataType.string:
						tempBuf = new Buffer(args[i]);
						break;
					case module.exports.EnumDataType.boolean:
						tempBuf = new Buffer(1);
						tempBuf.writeUInt8(args[i] ? 0x1 : 0x0, 0);
						break;
					case module.exports.EnumDataType.undefined:
					case module.exports.EnumDataType.null:
						tempBuf = new Buffer(0);
						break;
					default:
						error(new Error('Data type ' + dataType + ' has gone unhandled by client'));
						return;
				}
				var argHeader = new Buffer(5);
				argHeader.writeUInt8(dataType, 0);
				argHeader.writeUInt32LE(tempBuf.length, 1);
				bufArray.push(argHeader);
				bufArray.push(tempBuf);
				
				payloadLength += argHeader.length + tempBuf.length;
			}
			else {
				error(new Error('Unsupported data type argument passed to remote function'));
				return;
			}
		}
		
		bufArray[1].writeUInt32LE(payloadLength);
		
		return Buffer.concat(bufArray);
	}
88839
function updateGreyColorBuffer(buf) {
  for (let i = 0; i < buf.length; ++i) {
    buf[i] = 0.5;
  }
  return buf;
}
458537
function(x) {
  var len, i;
  if (x instanceof Buffer) { // Copy
    this.buf = new Buffer(x.length);
    x.copy(this.buf);
  } else if (x instanceof BitBuffer) {
    this.buf = new Buffer(x.buf.length);
    x.buf.copy(this.buf);
  } else { // Size
    if (typeof(x) === 'number') { // Size
      len = x;
    } else {
      len = 128;
    }
    this.buf = new Buffer(len / 8);
    // Zero the buffer before use.
    len = this.buf.length;
    for (i = 0; i < len; i += 1) {
      this.buf[i] = 0;
    }
  }
}
940161
private void executeInt(String []path, LineMap lineMap)
    throws JavaCompileException, IOException
  {
    MemoryStream tempStream = new MemoryStream();
    WriteStreamOld error = new WriteStreamOld(tempStream);

    try {
      // String parent = javaPath.getParent().getNativePath();

      ArrayList<String> argList = new ArrayList<String>();
      argList.add("-d");
      argList.add(_compiler.getClassDirName());
      if (_compiler.getEncoding() != null) {
        String encoding = Encoding.getJavaName(_compiler.getEncoding());
        if (encoding != null && ! encoding.equals("ISO8859_1")) {
          argList.add("-encoding");
          argList.add(_compiler.getEncoding());
        }
      }

      argList.add("-classpath");
      argList.add(_compiler.getClassPath());

      ArrayList<String> args = _compiler.getArgs();
      if (args != null)
        argList.addAll(args);

      for (int i = 0; i < path.length; i++) {
        PathImpl javaPath = _compiler.getSourceDir().lookup(path[i]);
        argList.add(javaPath.getNativePath());
      }

      if (log.isLoggable(Level.FINER)) {
        CharBuffer msg = new CharBuffer();
        msg.append("javac(int)");
        for (int i = 0; i < argList.size(); i++) {
          if (argList.get(i).equals("-classpath")
              && ! log.isLoggable(Level.FINEST)) {
            i++;
            continue;
          }

          msg.append(" ");
          msg.append(argList.get(i));
        }

        log.finer(msg.toString());
      }

      String []argArray = argList.toArray(new String[argList.size()]);

      int status = -1;
      
      Thread thread = Thread.currentThread();
      ClassLoader oldLoader = thread.getContextClassLoader();

      // env = _internalLoader;


      try {
        thread.setContextClassLoader(_envClassLoader);
        
        if (_javac == null)
          throw new ConfigException(L.l("javac compiler is not available in {0}. Check that you are using the JDK, not the JRE.",
                                        System.getProperty("java.runtime.name")
                                        + " " + System.getProperty("java.runtime.version")));
        
        status = _javac.run(null, error, error, argArray);
      
        error.close();
        tempStream.close();
      } finally {
        thread.setContextClassLoader(oldLoader);
      }

      ReadStreamOld read = tempStream.openReadAndSaveBuffer();
      JavacErrorParser parser = new JavacErrorParser(this, path[0], _compiler.getEncoding());

      String errors = parser.parseErrors((InputStream) read, lineMap);
      read.close();

      if (errors != null)
        errors = errors.trim();

      if (log.isLoggable(Level.FINE)) {
        read = tempStream.openReadAndSaveBuffer();
        CharBuffer cb = new CharBuffer();
        int ch;
        while ((ch = read.read()) >= 0) {
          cb.append((char) ch);
        }
        read.close();

        log.fine(cb.toString());
      }
      else if (status == 0 && errors != null && ! errors.equals("")) {
        final String msg = errors;

        new com.caucho.v5.loader.ClassLoaderContext(_compiler.getClassLoader()) {
          public void run()
          {
            log.warning(msg);
          }
        };
      }

      if (status != 0)
        throw new JavaCompileException(errors);
    } finally {
      tempStream.destroy();
    }
  }
1219885
function inType() {
  var path = this;
  while (path) {
    var _arr3 = arguments;

    for (var _i3 = 0; _i3 < _arr3.length; _i3++) {
      var type = _arr3[_i3];
      if (path.node.type === type) return true;
    }
    path = path.parentPath;
  }

  return false;
}
608726
function _addStringToBuffer(buffer, val) {
  buffer.putInt32(val.length);
  buffer.putString(val);
}
1046353
function (given_obj, given_label, given_mode, limit_size_buffer) {

		console.log("_______TOP show_object ", given_label, given_mode);

		// populate defaults if not supplied
		
		var mode = given_mode || "partial";
		var label = given_label || "";
 
		limit_size_buffer = (limit_size_buffer == 0) ? 9999999999 : limit_size_buffer; // no limit if given 0 as limit

		var size_buffer = limit_size_buffer;

		console.log("_______TOP limit_size_buffer ", limit_size_buffer);
		console.log("_______TOP size_buffer       ", size_buffer);


		if ("partial" == mode) {

		    for (var property in given_obj) {

		        // console.log(given_label, " property ", property);
		        console.log(given_label, " property -->" + property + "<--\t", given_obj[property]);
		    }

		} else {

		    for (var property in given_obj) {

		        // console.log(property, "\t property.substring(0,3) \t", property.substring(0,3));

		        if (property.substring(0,3) == "cb_") {

		        	// console.log(given_label, property, " ignoring callback");

		        } else if (property == "socket_conn") {

		        	// console.log(given_label, property, " ignoring socket connection details");


		        } else if ("buffer" == property || 
		        	   "raw_buffer" == property || 
		  "buffer_input_file_float" == property || 
		        "buffer_input_file" == property)   {

		        		var max_value_seen = -9999999, min_value_seen = 9999999;

			        	console.log(given_label, " about to show ", property);
			        	console.log(given_label, property, " of length ", given_obj[property].length);

			        	var local_min_size_buffer = (given_obj[property].length < size_buffer) ? 
			        							     given_obj[property].length : size_buffer;

			        	var local_max_size_buffer = local_min_size_buffer;

			        	if (local_min_size_buffer == 0) {

			        		local_max_size_buffer = given_obj[property].length;
			        	}

			    		for (var index = 0; index < local_max_size_buffer; index++) {

			        		console.log(given_label, property, "\t", index, given_obj[property][index]);

			        		min_value_seen = (given_obj[property][index] < min_value_seen) ? 
			        						  given_obj[property][index] : min_value_seen;
			        		max_value_seen = (given_obj[property][index] > max_value_seen) ? 
			        						  given_obj[property][index] : max_value_seen;
			    		}
			    		// if (given_obj.buffer.length > local_size_buffer) {
			    		if (given_obj[property].length > local_max_size_buffer) {

			        		console.log(given_label, "\t....... ");
			    		}

			        	console.log(given_label, " min_value_seen ", min_value_seen,
			        							 " max_value_seen ", max_value_seen);
		    	} else {

		    		// if (typeof property === "object") {
		    		// if (typeof given_obj[property] === "object") {

		    		// 	// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/typeof

		    		// 	console.log("cool seeing property ", property, " IS typeof object so recurse");

		    		// 	show_object(given_obj[property], given_label + " " + property, 
		    		// 				given_mode, limit_size_buffer);

		    		// } else {

		        		console.log(given_label, " property -->" + property + "<--\t", given_obj[property]);
		    		// }
		    	}
		    }
		}

		console.log("_______ BOTTOM show_object ", given_label, given_mode, " buffer size ",
					given_obj[property].length);
	}
968475
function ByteBuffer(arg) {
    var initial_size;
    if (arg == null) {
        initial_size = 1024 * 1024;
    } else if (typeof arg === "number") {
        initial_size = arg;
    } else if (arg instanceof Uint8Array) {
        this.buffer = arg;
        this.position = 0;  // Overwrite
        return;
    } else {
        // typeof arg -> String
        throw typeof arg + " is invalid parameter type for ByteBuffer constructor";
    }
    // arg is null or number
    this.buffer = new Uint8Array(initial_size);
    this.position = 0;
}
248364
function __serializeIntVar(data) {
	if ( data.size > 127 ) {
		throw new Error( "Cannot support IntVar whose size is greater than 127 bytes" );
	}

	const size = new Uint8Array([data.size]);
	return [size.buffer, data.toBytes().buffer];
}