Populate the byte array with PGpoint in the binary syntax expected by org.postgresql.
977705
public void toBytes(byte[] b, int offset) {
    ByteConverter.float8(b, offset, x);
    ByteConverter.float8(b, offset + 8, y);
  }
696092
@Override
    public void setBytes(int parameterIndex, byte[] x) throws SQLException
    {
        checkParameterBounds(parameterIndex);
        this.parameters[parameterIndex-1] = x;
    }
958817
@Override
  public final <T> void fill(final Map<String, Object> pAddParam,
    final T pEntity, final IRecordSet<RS> pSource) throws Exception {
    @SuppressWarnings("unchecked")
    IFillerObjectFields<T> filler = (IFillerObjectFields<T>)
      fillersFieldsFactory.lazyGet(pAddParam, pEntity.getClass());
    TableSql tableSql = this.tablesMap.get(pEntity.getClass().getSimpleName());
    @SuppressWarnings("unchecked")
    Collection<String> fieldsNames = (Collection<String>) pAddParam.
      get(pEntity.getClass().getSimpleName() + "neededFields");
    if (fieldsNames == null) {
      fieldsNames = tableSql.getFieldsMap().keySet();
    }
    boolean isDbgSh = this.logger.getDbgSh(this.getClass())
      && this.logger.getDbgFl() < 7031 && this.logger.getDbgCl() > 7033;
    String currentLevelNm = "currentLevel";
    @SuppressWarnings("unchecked")
    List<Integer> currentLevel = (List<Integer>) pAddParam.get(currentLevelNm);
    String deepLevelNm = "deepLevel";
    @SuppressWarnings("unchecked")
    List<Integer> deepLevel = (List<Integer>) pAddParam.get(deepLevelNm);
    @SuppressWarnings("unchecked")
    List<String> foreignFieldNms = (List<String>)
      pAddParam.get("foreignFieldNms");
    for (String fieldName : fieldsNames) {
      if (!tableSql.getFieldsMap().get(fieldName).getTypeField()
            .equals(ETypeField.DERIVED_FROM_COMPOSITE)) {
        String convName = this.fieldConverterNamesHolder.getFor(pEntity
         .getClass(), fieldName);
        IConverterByName<IRecordSet<RS>, ?> conv = this.convertersFieldsFatory
          .lazyGet(pAddParam, convName);
        if (conv != null) { // e.g. transient or composite (non-foreign) itsId
          try {
            Field field = this.fieldsRapiHolder
              .getFor(pEntity.getClass(), fieldName);
            String parName;
            String tableAlias;
            if (currentLevel.get(0) > 1) { // in TOP level
              String currForeignFieldNm = foreignFieldNms
                .get(foreignFieldNms.size() - 1);
              tableAlias = currForeignFieldNm.toUpperCase();
            } else {
              tableAlias = "";
            }
            if (Enum.class.isAssignableFrom(field.getType())) {
              parName = tableAlias + fieldName.toUpperCase();
              pAddParam.put("fieldClass", field.getType());
            } else {
              if (tableSql.getFieldsMap().get(fieldName)
                .getForeignEntity() != null) {
                Integer deepLevelReq = (Integer) pAddParam.get(pEntity
                  .getClass().getSimpleName() + fieldName + deepLevelNm);
                if (deepLevelReq != null) {
                  //sub-entities with overridden deep:
                  currentLevel.add(1);
                  deepLevel.add(deepLevelReq);
                } //nothing for sub-entities
                if (deepLevel.size() != currentLevel.size()) {
                  throw new Exception(
                "Algorithm error: deepLevel.size/currentLevel.size/Entity/Field"
                  + deepLevel.size() + "/" + currentLevel.size() + "/"
                    + pEntity.getClass().getSimpleName() + "/" + fieldName);
                }
                parName = fieldName;
                 //table current alias for name
                foreignFieldNms.add(fieldName);
                // foreign entity class for factory:
                pAddParam.put("fieldClass", field.getType());
                pAddParam.put("entityClass", pEntity.getClass());
                if (isDbgSh) {
                  StringBuffer sb = new StringBuffer();
                  sb.append("deepLevel size/value1/value...: " + deepLevel
                    .size() + "/");
                  for (Integer dl : deepLevel) {
                    sb.append(dl + "/");
                  }
                  sb.append("\ncurrentLevel size/value1/value...: "
                    + currentLevel.size() + "/");
                  for (Integer cl : currentLevel) {
                    sb.append(cl + "/");
                  }
                  sb.append("\nforeignFieldNms size/value1/value...: "
                    + foreignFieldNms.size() + "/");
                  for (String fln : foreignFieldNms) {
                    sb.append(fln + "/");
                  }
                  sb.append("\nForeign class/fieldNm/type: "
                    + pEntity.getClass().getSimpleName() + "/" + fieldName + "/"
                     + field.getType().getSimpleName());
                  this.logger.debug(null, FillerEntitiesFromRs.class,
                    sb.toString());
                }
              } else {
                parName = tableAlias + fieldName.toUpperCase();
              }
            }
            Object fieldVal = conv.convert(pAddParam, pSource, parName);
            if (isDbgSh) {
              this.logger.debug(null, FillerEntitiesFromRs.class,
                "Converted from RS class/field/type/converter/value: "
                  + pEntity.getClass().getSimpleName() + "/" + fieldName + "/"
                    + field.getType().getSimpleName() + "/"
                      + conv.getClass().getSimpleName() + "/" + fieldVal);
            }
            filler.fill(pAddParam, pEntity, fieldVal, fieldName);
          } catch (Exception ex) {
            String msg = "Can't fill field/class: " + fieldName + "/"
              + pEntity.getClass().getCanonicalName();
            throw new ExceptionWithCode(ExceptionWithCode.SOMETHING_WRONG,
              msg, ex);
          }
        }
      }
    }
    pAddParam.remove("fieldClass");
    pAddParam.remove("entityClass");
  }
1309654
private void fillIn(PackageSymbol p) throws IOException {
        if (p.members_field == null) p.members_field = new Scope(p);
        String packageName = p.fullname.toString();

        Set<JavaFileObject.Kind> kinds = getPackageFileKinds();

        fillIn(p, PLATFORM_CLASS_PATH,
               fileManager.list(PLATFORM_CLASS_PATH,
                                packageName,
                                EnumSet.of(JavaFileObject.Kind.CLASS),
                                false));

        Set<JavaFileObject.Kind> classKinds = EnumSet.copyOf(kinds);
        classKinds.remove(JavaFileObject.Kind.SOURCE);
        boolean wantClassFiles = !classKinds.isEmpty();

        Set<JavaFileObject.Kind> sourceKinds = EnumSet.copyOf(kinds);
        sourceKinds.remove(JavaFileObject.Kind.CLASS);
        boolean wantSourceFiles = !sourceKinds.isEmpty();

        boolean haveSourcePath = fileManager.hasLocation(SOURCE_PATH);

        if (verbose && verbosePath) {
            if (fileManager instanceof StandardJavaFileManager) {
                StandardJavaFileManager fm = (StandardJavaFileManager)fileManager;
                if (haveSourcePath && wantSourceFiles) {
                    List<File> path = List.nil();
                    for (File file : fm.getLocation(SOURCE_PATH)) {
                        path = path.prepend(file);
                    }
                    log.printVerbose("sourcepath", path.reverse().toString());
                } else if (wantSourceFiles) {
                    List<File> path = List.nil();
                    for (File file : fm.getLocation(CLASS_PATH)) {
                        path = path.prepend(file);
                    }
                    log.printVerbose("sourcepath", path.reverse().toString());
                }
                if (wantClassFiles) {
                    List<File> path = List.nil();
                    for (File file : fm.getLocation(PLATFORM_CLASS_PATH)) {
                        path = path.prepend(file);
                    }
                    for (File file : fm.getLocation(CLASS_PATH)) {
                        path = path.prepend(file);
                    }
                    log.printVerbose("classpath",  path.reverse().toString());
                }
            }
        }

        if (wantSourceFiles && !haveSourcePath) {
            fillIn(p, CLASS_PATH,
                   fileManager.list(CLASS_PATH,
                                    packageName,
                                    kinds,
                                    false));
        } else {
            if (wantClassFiles)
                fillIn(p, CLASS_PATH,
                       fileManager.list(CLASS_PATH,
                                        packageName,
                                        classKinds,
                                        false));
            if (wantSourceFiles)
                fillIn(p, SOURCE_PATH,
                       fileManager.list(SOURCE_PATH,
                                        packageName,
                                        sourceKinds,
                                        false));
        }
        verbosePath = false;
    }
1230788
def _populate_cparams(self, img_array, mct=None, cratios=None, psnr=None,
                          cinema2k=None, cinema4k=None, irreversible=None,
                          cbsize=None, eph=None, grid_offset=None, modesw=None,
                          numres=None, prog=None, psizes=None, sop=None,
                          subsam=None, tilesize=None, colorspace=None):
        
        other_args = (mct, cratios, psnr, irreversible, cbsize, eph,
                      grid_offset, modesw, numres, prog, psizes, sop, subsam)
        if (((cinema2k is not None or cinema4k is not None) and
             (not all([arg is None for arg in other_args])))):
            msg = ("Cannot specify cinema2k/cinema4k along with any other "
                   "options.")
            raise IOError(msg)

        if cratios is not None and psnr is not None:
            msg = "Cannot specify cratios and psnr options together."
            raise IOError(msg)

        if version.openjpeg_version_tuple[0] == 1:
            cparams = opj.set_default_encoder_parameters()
        else:
            cparams = opj2.set_default_encoder_parameters()

        outfile = self.filename.encode()
        num_pad_bytes = opj2.PATH_LEN - len(outfile)
        outfile += b'0' * num_pad_bytes
        cparams.outfile = outfile

        if self.filename[-4:].endswith(('.jp2', '.JP2')):
            cparams.codec_fmt = opj2.CODEC_JP2
        else:
            cparams.codec_fmt = opj2.CODEC_J2K

        # Set defaults to lossless to begin.
        cparams.tcp_rates[0] = 0
        cparams.tcp_numlayers = 1
        cparams.cp_disto_alloc = 1

        cparams.irreversible = 1 if irreversible else 0

        if cinema2k is not None:
            self._cparams = cparams
            self._set_cinema_params('cinema2k', cinema2k)
            return

        if cinema4k is not None:
            self._cparams = cparams
            self._set_cinema_params('cinema4k', cinema4k)
            return

        if cbsize is not None:
            cparams.cblockw_init = cbsize[1]
            cparams.cblockh_init = cbsize[0]

        if cratios is not None:
            cparams.tcp_numlayers = len(cratios)
            for j, cratio in enumerate(cratios):
                cparams.tcp_rates[j] = cratio
            cparams.cp_disto_alloc = 1

        cparams.csty |= 0x02 if sop else 0
        cparams.csty |= 0x04 if eph else 0

        if grid_offset is not None:
            cparams.image_offset_x0 = grid_offset[1]
            cparams.image_offset_y0 = grid_offset[0]

        if modesw is not None:
            for shift in range(6):
                power_of_two = 1 << shift
                if modesw & power_of_two:
                    cparams.mode |= power_of_two

        if numres is not None:
            cparams.numresolution = numres

        if prog is not None:
            cparams.prog_order = core.PROGRESSION_ORDER[prog.upper()]

        if psnr is not None:
            cparams.tcp_numlayers = len(psnr)
            for j, snr_layer in enumerate(psnr):
                cparams.tcp_distoratio[j] = snr_layer
            cparams.cp_fixed_quality = 1

        if psizes is not None:
            for j, (prch, prcw) in enumerate(psizes):
                cparams.prcw_init[j] = prcw
                cparams.prch_init[j] = prch
            cparams.csty |= 0x01
            cparams.res_spec = len(psizes)

        if subsam is not None:
            cparams.subsampling_dy = subsam[0]
            cparams.subsampling_dx = subsam[1]

        if tilesize is not None:
            cparams.cp_tdx = tilesize[1]
            cparams.cp_tdy = tilesize[0]
            cparams.tile_size_on = opj2.TRUE

        if mct is None:
            # If the multi component transform was not specified, we infer
            # that it should be used if the color space is RGB.
            cparams.tcp_mct = 1 if self._colorspace == opj2.CLRSPC_SRGB else 0
        else:
            if self._colorspace == opj2.CLRSPC_GRAY:
                msg = ("Cannot specify usage of the multi component transform "
                       "if the colorspace is gray.")
                raise IOError(msg)
            cparams.tcp_mct = 1 if mct else 0

        self._validate_compression_params(img_array, cparams, colorspace)

        self._cparams = cparams
1256334
function (table, opts) {
            opts = opts || {};
            var m = this.outputIdentifierFunc;
            var im = this.inputIdentifierFunc;
            var parts = this.__schemaAndTable(table), schema = parts[0];
            table = parts[1];
            return this.serverVersion().chain(function (version) {
                var attNums;
                if (version >= 80100) {
                    attNums = sql.ANY("ind__indkey");
                } else {
                    attNums = [];
                    for (var i = 0; i < 32; i++) {
                        attNums.push(new Subscript("ind__indkey", [i]));
                    }
                }
                var orderRange = [];
                for (var j = 0; j < 32; j++) {
                    orderRange.push(new Subscript("ind__indkey", [j]));
                }
                orderRange = sql["case"](orderRange, 32, "att__attnum");
                var ds = this.metadataDataset.from("pg_class___tab")
                    .join("pg_index___ind", [
                        [identifier("indrelid"), identifier("oid")],
                        [im(table), "relname"]
                    ])
                    .join("pg_class___indc", [
                        [identifier("oid"), identifier("indexrelid")]
                    ])
                    .join("pg_attribute___att", [
                        [identifier("attrelid"), identifier("tab__oid")],
                        [identifier("attnum"), attNums]
                    ])
                    .filter({"indc__relkind": 'i', "ind__indisprimary": false, indexprs: null, indpred: null})
                    .order("indc__relname", orderRange)
                    .select("indc__relname___name", "ind__indisunique___unique", "att__attname___column");

                if (schema) {
                    ds = ds.join("pg_namespace___nsp", {oid: identifier("tab__relnamespace"), nspname: schema.toString()});
                }
                if (version >= 80200) {
                    ds = ds.filter({indisvalid: true});
                }
                if (version >= 80300) {
                    ds = ds.filter({indisready: true, indcheckxmin: false});
                }
                var indexes = {};
                return ds.forEach(function (r) {
                    var ident = m(r.name), i = indexes[ident];
                    if (!i) {
                        i = indexes[ident] = {columns: [], unique: r.unique};
                    }
                    i.columns.push(r.column);
                }).chain(function () {
                    return indexes;
                });
            });
        }
1060106
private void expectedByte(int position, int count)
        throws UTFDataFormatException {
        String msg = JspCoreException.getMsg("jsp.error.xml.expectedByte", new Object[] {Integer.toString(position), Integer.toString(count)});
        throw new UTFDataFormatException(msg);

    }
696162
def from_bytes(rawbytes):
        '''
        
        '''
        ipopts = IPOptionList()

        i = 0
        while i < len(rawbytes):
            opttype = rawbytes[i]
            optcopied = opttype >> 7         # high order 1 bit
            optclass = (opttype >> 5) & 0x03 # next 2 bits
            optnum = opttype & 0x1f          # low-order 5 bits are optnum
            optnum = IPOptionNumber(optnum)
            obj = IPOptionClasses[optnum]()
            eaten = obj.from_bytes(rawbytes[i:])
            i += eaten
            ipopts.append(obj)
        return ipopts
1196164
def _sqla_postgresql(self, uri, version=None,
                         isolation_level="READ COMMITTED"):
        '''
        
        '''
        isolation_level = isolation_level or "READ COMMITTED"
        kwargs = dict(isolation_level=isolation_level)
        # FIXME: version of postgresql < 9.2 don't have pg.JSON!
        # check and use JSONTypedLite instead
        # override default dict and list column types
        types = {list: pg.ARRAY, tuple: pg.ARRAY, set: pg.ARRAY,
                 dict: JSONDict, datetime: UTCEpoch}
        self.type_map.update(types)
        bs = self.config['batch_size']
        # 999 batch_size is default for sqlite, postgres handles more at once
        self.config['batch_size'] = 5000 if bs == 999 else bs
        self._lock_required = False
        # default schema name is 'public' for postgres
        dsn = self.config['db_schema']
        self.config['db_schema'] = dsn or 'public'
        return uri, kwargs
1257610
protected void fillBytes(int value, long count) throws BitStreamException {
		// if it's short, write bytes directly
		if (count < PAD_LIMIT) {
			for (int i = 0; i < count; i++) writeByte(value);
			return;
		}

		// obtain an array we can use to write the bytes efficiently
		byte b = (byte) value;
		byte[] buffer = getBuffer(b);
		int len;
		if (buffer == null) {
			//TODO should all buffers be cached?
			len = count > PAD_BUFFER ? PAD_BUFFER : (int) count;
			buffer = new byte[len];
			Arrays.fill(buffer, b);
		} else {
			len = PAD_BUFFER;
		}

		// if we can, just do it with a single buffer
		if (count <= len) {
			writeBytes(buffer, 0, (int) count);
			return;
		}

		// write the buffer as many times as we need to
		long limit = count / len;
		for (long i = 0; i < limit; i++) {
			writeBytes(buffer, 0, len);
		}
		int r = (int) (count - limit * len);
		if (r != 0) writeBytes(buffer, 0, r);
	}
1093374
def create_response_pdu(self, data):
        
        log.debug('Create multi bit response pdu {0}.'.format(data))
        fmt = '>BB' + conf.TYPE_CHAR * len(data)

        return struct.pack(fmt, self.function_code, len(data) * 2, *data)
568992
public static MySQLBinaryProtocolValue getBinaryProtocolValue(final MySQLColumnType columnType) {
        Preconditions.checkArgument(BINARY_PROTOCOL_VALUES.containsKey(columnType), "Cannot find MySQL type '%s' in column type when process binary protocol value", columnType);
        return BINARY_PROTOCOL_VALUES.get(columnType);
    }
731903
public byte[] popByteArray() throws ParseException
    {
        final Object popped = super.pop();
        if (popped instanceof byte[])
            return (byte[]) popped;

        throw new ParseException("byte[] required, found " + popped.getClass().getSimpleName(), 0);
    }
616524
private static byte[] decodeBytes(byte[] pInBytes) {
        byte[] decodabet = DECODABET;

        int    len34   = pInBytes.length * 3 / 4;       // Estimate on array size
        byte[] outBuff = new byte[ len34 ]; // Upper limit on size of output
        int    outBuffPosn = 0;             // Keep track of where we're writing

        byte[] b4        = new byte[4];     // Four byte buffer from source, eliminating white space
        int    b4Posn    = 0;               // Keep track of four byte input buffer
        int    i         = 0;               // Source array counter
        byte   sbiCrop   = 0;               // Low seven bits (ASCII) of input
        byte   sbiDecode = 0;               // Special value from DECODABET

        for( i = 0; i < 0 + pInBytes.length; i++ ) {  // Loop through source

            sbiCrop = (byte)(pInBytes[i] & 0x7f); // Only the low seven bits
            sbiDecode = decodabet[ sbiCrop ];   // Special value

            // White space, Equals sign, or legit Base64 character
            // Note the values such as -5 and -9 in the
            // DECODABETs at the top of the file.
            if( sbiDecode >= WHITE_SPACE_ENC )  {
                if( sbiDecode >= EQUALS_SIGN_ENC ) {
                    b4[ b4Posn++ ] = sbiCrop;           // Save non-whitespace
                    if( b4Posn > 3 ) {                  // Time to decode?
                        outBuffPosn += decode4to3( b4, 0, outBuff, outBuffPosn);
                        b4Posn = 0;

                        // If that was the equals sign, break out of 'for' loop
                        if( sbiCrop == EQUALS_SIGN ) {
                            break;
                        }
                    }
                }
            }
            else {
                // There's a bad input character in the Base64 stream.
                throw new IllegalArgumentException(String.format(
                        "Bad Base64 input character '%d' in array position %d", pInBytes[i], i ) );
            }
        }

        byte[] out = new byte[ outBuffPosn ];
        System.arraycopy( outBuff, 0, out, 0, outBuffPosn );
        return out;
    }
1033171
private static byte [] binaryIncrementPos(byte [] value, long amount) {
    long amo = amount;
    int sign = 1;
    if (amount < 0) {
      amo = -amount;
      sign = -1;
    }
    for (int i = 0; i < value.length; i++) {
      int cur = ((int) amo % 256) * sign;
      amo = (amo >> 8);
      int val = value[value.length - i - 1] & 0x0ff;
      int total = val + cur;
      if (total > 255) {
        amo += sign;
        total %= 256;
      } else if (total < 0) {
        amo -= sign;
      }
      value[value.length - i - 1] = (byte) total;
      if (amo == 0) {
        return value;
      }
    }
    return value;
  }
239650
function base64toBlob(base64Data, contentType, sliceSize) {
        contentType = contentType || '';
        sliceSize = sliceSize || 512;

        var byteCharacters = atob(base64Data);
        var byteArrays = [];

        for (var offset = 0; offset < byteCharacters.length; offset += sliceSize) {
            var slice = byteCharacters.slice(offset, offset + sliceSize);
            var byteNumbers = new Array(slice.length);
            for (var i = 0; i < slice.length; i++) {
                byteNumbers[i] = slice.charCodeAt(i);
            }
            var byteArray = new Uint8Array(byteNumbers);
            byteArrays.push(byteArray);
        }

        return new Blob(byteArrays, {type: contentType});
    }
413668
@Override
    public byte[] getBytes(int position, int length) {
        byte[] result = new byte[length];
        for (int i = 0; i < length; i++) {
            result[i]=getByte(position);
            position += BYTE_LEN;
        }
        return result;
    }