<commit_before>package org.postgresql;

import java.io.*;
import java.lang.*;
import java.net.*;
import java.util.*;
import java.sql.*;
import java.security.*;
import org.postgresql.*;
import org.postgresql.core.*;
import org.postgresql.util.*;

/**
 * $Id: PG_Stream.java,v 1.12 2001/08/26 01:06:20 momjian Exp $
 *
 * This class is used by Connection & PGlobj for communicating with the
 * backend.
 *
 * @see java.sql.Connection
 */
//  This class handles all the Streamed I/O for a org.postgresql connection
public class PG_Stream
{
  private Socket connection;
  private InputStream pg_input;
  private BufferedOutputStream pg_output;
  private byte[] byte_buf = new byte[8*1024];

    BytePoolDim1 bytePoolDim1 = new BytePoolDim1();
    BytePoolDim2 bytePoolDim2 = new BytePoolDim2();

   private static class PrivilegedSocket
      implements PrivilegedExceptionAction
   {
      private String host;
      private int port;

      PrivilegedSocket(String host, int port)
      {
         this.host = host;
         this.port = port;
      }

      public Object run() throws Exception
      {
         return new Socket(host, port);
      }
   }


  /**
   * Constructor:  Connect to the PostgreSQL back end and return
   * a stream connection.
   *
   * @param host the hostname to connect to
   * @param port the port number that the postmaster is sitting on
   * @exception IOException if an IOException occurs below it.
   */
  public PG_Stream(String host, int port) throws IOException
  {
     PrivilegedSocket ps = new PrivilegedSocket(host, port);
     try {
        connection = (Socket)AccessController.doPrivileged(ps);
     }
     catch(PrivilegedActionException pae){
        throw (IOException)pae.getException();
     }

    // Submitted by <NAME> <<EMAIL>> adds a 10x speed
    // improvement on FreeBSD machines (caused by a bug in their TCP Stack)
    connection.setTcpNoDelay(true);

    // Buffer sizes submitted by <NAME> <<EMAIL>>
    pg_input = new BufferedInputStream(connection.getInputStream(), 8192);
    pg_output = new BufferedOutputStream(connection.getOutputStream(), 8192);
  }

  /**
   * Sends a single character to the back end
   *
   * @param val the character to be sent
   * @exception IOException if an I/O error occurs
   */
  public void SendChar(int val) throws IOException
  {
      pg_output.write((byte)val);
  }

  /**
   * Sends an integer to the back end
   *
   * @param val the integer to be sent<commit_msg>Please pull this patch.  It breaks JDBC1 support.  The JDBC1 code no longer compiles, due to objects being referenced in this patch that do not exist in JDK1.1.<commit_after>package org.postgresql;

import java.io.*;
import java.lang.*;
import java.net.*;
import java.util.*;
import java.sql.*;
import org.postgresql.*;
import org.postgresql.core.*;
import org.postgresql.util.*;

/**
 * $Id: PG_Stream.java,v 1.13 2001/08/26 17:08:48 momjian Exp $
 *
 * This class is used by Connection & PGlobj for communicating with the
 * backend.
 *
 * @see java.sql.Connection
 */
//  This class handles all the Streamed I/O for a org.postgresql connection
public class PG_Stream
{
  private Socket connection;
  private InputStream pg_input;
  private BufferedOutputStream pg_output;
  private byte[] byte_buf = new byte[8*1024];

    BytePoolDim1 bytePoolDim1 = new BytePoolDim1();
    BytePoolDim2 bytePoolDim2 = new BytePoolDim2();

  /**
   * Constructor:  Connect to the PostgreSQL back end and return
   * a stream connection.
   *
   * @param host the hostname to connect to
   * @param port the port number that the postmaster is sitting on
   * @exception IOException if an IOException occurs below it.
   */
  public PG_Stream(String host, int port) throws IOException
  {
    connection = new Socket(host, port);

    // Submitted by <NAME> <<EMAIL>> adds a 10x speed
    // improvement on FreeBSD machines (caused by a bug in their TCP Stack)
    connection.setTcpNoDelay(true);

    // Buffer sizes submitted by <NAME> <<EMAIL>>
    pg_input = new BufferedInputStream(connection.getInputStream(), 8192);
    pg_output = new BufferedOutputStream(connection.getOutputStream(), 8192);
  }

  /**
   * Sends a single character to the back end
   *
   * @param val the character to be sent
   * @exception IOException if an I/O error occurs
   */
  public void SendChar(int val) throws IOException
  {
      pg_output.write((byte)val);
  }

  /**
   * Sends an integer to the back end
   *
   * @param val the integer to be sent
{'fraction_non_alphanumeric': 0.09323542501112594, 'fraction_numerical': 0.017801513128615932, 'mean_word_length': 3.2009345794392523, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6318540', 'n_tokens_mistral': 1388, 'n_tokens_neox': 1314, 'n_words': 469}