Scale all data  0 to 1

@param schema the schema of the data to scale
@param data   the data to scale
@return the normalized ata
559218
public static JavaRDD<List<Writable>> normalize(Schema schema, JavaRDD<List<Writable>> data,
                    List<String> skipColumns) {
        return normalize(schema, data, 0, 1, skipColumns);
    }
1177053
public static int recordSize(Schema sch) {
		int pos = 0;
		for (String fldname : sch.fields())
			pos += Page.maxSize(sch.type(fldname));
		return pos < MIN_REC_SIZE ? MIN_REC_SIZE : pos;
	}
906835
protected static <A> double[] computeNormalizedRanks(final NumberArrayAdapter<?, A> adapter, final A data, int len) {
    // Sort the objects:
    int[] s1 = sortedIndex(adapter, data, len);
    final double norm = .5 / (len - 1);
    double[] ret = new double[len];
    for(int i = 0; i < len;) {
      final int start = i++;
      final double val = adapter.getDouble(data, s1[start]);
      while(i < len && adapter.getDouble(data, s1[i]) <= val) {
        i++;
      }
      final double score = (start + i - 1) * norm;
      for(int j = start; j < i; j++) {
        ret[s1[j]] = score;
      }
    }
    return ret;
  }
762381
public static Schema toDatavecSchema(org.apache.arrow.vector.types.pojo.Schema schema) {
        Schema.Builder schemaBuilder = new Schema.Builder();
        for (int i = 0; i < schema.getFields().size(); i++) {
            schemaBuilder.addColumn(metaDataFromField(schema.getFields().get(i)));
        }
        return schemaBuilder.build();
    }
780179
def prepare_bytes_decimal(data, schema):
    """"""
    if not isinstance(data, decimal.Decimal):
        return data
    scale = schema.get('scale', 0)

    # based on https://github.com/apache/avro/pull/82/

    sign, digits, exp = data.as_tuple()

    if -exp > scale:
        raise ValueError(
            'Scale provided in schema does not match the decimal')
    delta = exp + scale
    if delta > 0:
        digits = digits + (0,) * delta

    unscaled_datum = 0
    for digit in digits:
        unscaled_datum = (unscaled_datum * 10) + digit

    bits_req = unscaled_datum.bit_length() + 1

    if sign:
        unscaled_datum = (1 << bits_req) - unscaled_datum

    bytes_req = bits_req // 8
    padding_bits = ~((1 << bits_req) - 1) if sign else 0
    packed_bits = padding_bits | unscaled_datum

    bytes_req += 1 if (bytes_req << 3) < bits_req else 0

    tmp = MemoryIO()

    for index in range(bytes_req - 1, -1, -1):
        bits_to_write = packed_bits >> (8 * index)
        tmp.write(mk_bits(bits_to_write & 0xff))

    return tmp.getvalue()
1374062
@Override
  public double[] projectRelativeDataToScaledSpace(double[] data) {
    final int dim = data.length;
    double[] dst = new double[dim];
    for(int d = 0; d < dim; d++) {
      dst[d] = scales[d].getRelativeScaled(data[d]);
    }
    return dst;
  }
676913
public Object getResult(AverageData data) {
        return data.count == 0 ? BigDecimal.ZERO : data.total.divide(BigDecimal.valueOf( data.count ), RoundingMode.HALF_EVEN );
    }
323027
public void setSchema(java.util.Collection<SchemaAttributeType> schema) {
        if (schema == null) {
            this.schema = null;
            return;
        }

        this.schema = new java.util.ArrayList<SchemaAttributeType>(schema);
    }
875467
public static DataQualityAnalysis analyzeQuality(final Schema schema, final JavaRDD<List<Writable>> data) {
        int nColumns = schema.numColumns();
        List<QualityAnalysisState> states = data.aggregate(null,
                new BiFunctionAdapter<>(new QualityAnalysisAddFunction(schema)),
                new BiFunctionAdapter<>(new QualityAnalysisCombineFunction()));

        List<ColumnQuality> list = new ArrayList<>(nColumns);

        for (QualityAnalysisState qualityState : states) {
            list.add(qualityState.getColumnQuality());
        }
        return new DataQualityAnalysis(schema, list);
    }
409724
protected static <A> int[] discretize(NumberArrayAdapter<?, A> adapter, A data, final int len, final int bins) {
    double min = adapter.getDouble(data, 0), max = min;
    for(int i = 1; i < len; i++) {
      double v = adapter.getDouble(data, i);
      if(v < min) {
        min = v;
      }
      else if(v > max) {
        max = v;
      }
    }
    final double scale = (max > min) ? bins / (max - min) : 1;
    int[] discData = new int[len];
    for(int i = 0; i < len; i++) {
      int bin = (int) Math.floor((adapter.getDouble(data, i) - min) * scale);
      discData[i] = bin < 0 ? 0 : bin >= bins ? bins - 1 : bin;
    }
    return discData;
  }
490083
public static byte[] increment(final byte[] data) {
		for (int i = 0; i < data.length && (data[i] += (byte)1) == 0; ++i);
		return data;
	}
620070
@Override
  public double[] projectDataToScaledSpace(double[] data) {
    final int dim = data.length;
    double[] dst = new double[dim];
    for(int d = 0; d < dim; d++) {
      dst[d] = scales[d].getScaled(data[d]);
    }
    return dst;
  }
79773
public final DataHasher addData(byte[] data) {
        Util.notNull(data, "Date");

        return addData(data, 0, data.length);
    }
424084
public int getAccessor(JMFSchema schema) {
    for (Accessor acc = accessor; acc != null; acc = acc.next)
      if (schema == acc.schema)
        return acc.accessor;
    return -1;
  }
1000943
public static BIG hashModOrder(byte[] data) {
        HASH256 hash = new HASH256();
        for (byte b : data) {
            hash.process(b);
        }

        byte[] hasheddata = hash.hash();

        BIG ret = BIG.fromBytes(hasheddata);
        ret.mod(IdemixUtils.GROUP_ORDER);

        return ret;
    }
794307
public void setSchema(String schema)
   {
      if (schema.charAt(schema.length() - 1) != '.')
      {
         schema = schema + '.';
      }
      m_schema = schema;
   }
982602
@Benchmark
  @BenchmarkMode(Mode.AverageTime)
  @OutputTimeUnit(TimeUnit.NANOSECONDS)
  public Map<String, AttributeValue> createAttributeMap(Data data) {
    Map<String, AttributeValue> attributeMap = new HashMap<>(data.size);
    for (int i = 0; i < data.size; i++) {
      attributeMap.put(data.attributeKeys[i], data.attributeValues[i]);
    }
    return attributeMap;
  }