ghosted distributed array constructor
    @param arry numpy-like array
    @param numGhosts the number of ghosts (>= 0)
508764
def gmdaArray(arry, dtype, mask=None, numGhosts=1):
    
    a = numpy.array(arry, dtype)
    res = GhostedMaskedDistArray(a.shape, a.dtype)
    res.mask = mask
    res.setNumberOfGhosts(numGhosts)
    res[:] = a
    return res
860184
public void newarray(TypeMirror type, int count) throws IOException
    {
        if (type.getKind() != TypeKind.ARRAY)
        {
            throw new IllegalArgumentException(type+" is not array");
        }
        ArrayType at = (ArrayType) type;
        iconst(count);
        TypeMirror ct = at.getComponentType();
        switch (ct.getKind())
        {
            case BOOLEAN:
                newarray(T_BOOLEAN);
                break;
            case CHAR:
                newarray(T_CHAR);
                break;
            case FLOAT:
                newarray(T_FLOAT);
                break;
            case DOUBLE:
                newarray(T_DOUBLE);
                break;
            case BYTE:
                newarray(T_BYTE);
                break;
            case SHORT:
                newarray(T_SHORT);
                break;
            case INT:
                newarray(T_INT);
                break;
            case LONG:
                newarray(T_LONG);
                break;
            case DECLARED:
            {
                DeclaredType dt = (DeclaredType) ct;
                int index = subClass.resolveClassIndex((TypeElement)dt.asElement());
                anewarray(index);
            }
                break;
            default:
                throw new IllegalArgumentException(type+" not supported");
        }
    }
860594
@Override
    public final void setDefaultLocalAddresses(List<? extends SocketAddress> localAddresses) {
        if (localAddresses == null) {
            throw new NullPointerException("localAddresses");
        }
        setDefaultLocalAddresses((Iterable<? extends SocketAddress>) localAddresses);
    }
851913
def multi_bulk(self, args):
        '''
        '''
        return null_array if args is None else b''.join(self._pack(args))
246136
@SuppressWarnings("unchecked")
  public void distributedProcess(ResponseBuilder rb,
      ComponentFields mtasFields) {

    if (mtasFields.doList) {
      // compute total from shards
      HashMap<String, HashMap<String, Integer>> listShardTotals = new HashMap<>();
      for (ShardRequest sreq : rb.finished) {
        if (sreq.params.getBool(MtasSolrSearchComponent.PARAM_MTAS, false)
            && sreq.params.getBool(PARAM_MTAS_LIST, false)) {
          for (ShardResponse response : sreq.responses) {
            NamedList<Object> result = response.getSolrResponse().getResponse();
            try {
              ArrayList<NamedList<Object>> data = (ArrayList<NamedList<Object>>) result
                  .findRecursive("mtas", NAME);
              if (data != null) {
                for (NamedList<Object> dataItem : data) {
                  Object key = dataItem.get("key");
                  Object total = dataItem.get("total");
                  if ((key != null) && (key instanceof String)
                      && (total != null) && (total instanceof Integer)) {
                    if (!listShardTotals.containsKey(key)) {
                      listShardTotals.put((String) key,
                          new HashMap<String, Integer>());
                    }
                    HashMap<String, Integer> listShardTotal = listShardTotals
                        .get(key);
                    listShardTotal.put(response.getShard(), (Integer) total);
                  }
                }
              }
            } catch (ClassCastException e) {
              log.debug(e);
            }
          }
        }
      }
      // compute shard requests
      HashMap<String, ModifiableSolrParams> shardRequests = new HashMap<>();
      int requestId = 0;
      for (String field : mtasFields.list.keySet()) {
        for (ComponentList list : mtasFields.list.get(field).listList) {
          requestId++;
          if (listShardTotals.containsKey(list.key) && (list.number > 0)) {
            Integer start = list.start;
            Integer number = list.number;
            HashMap<String, Integer> totals = listShardTotals.get(list.key);
            for (int i = 0; i < rb.shards.length; i++) {
              if (number < 0) {
                break;
              }
              int subTotal = totals.get(rb.shards[i]);
              // System.out.println(i + " : " + rb.shards[i] + " : "
              // + totals.get(rb.shards[i]) + " - " + start + " " + number);
              if ((start >= 0) && (start < subTotal)) {
                ModifiableSolrParams params;
                if (!shardRequests.containsKey(rb.shards[i])) {
                  shardRequests.put(rb.shards[i], new ModifiableSolrParams());
                }
                params = shardRequests.get(rb.shards[i]);
                params.add(PARAM_MTAS_LIST + "." + requestId + "."
                    + NAME_MTAS_LIST_FIELD, list.field);
                params.add(PARAM_MTAS_LIST + "." + requestId + "."
                    + NAME_MTAS_LIST_QUERY_VALUE, list.queryValue);
                params.add(PARAM_MTAS_LIST + "." + requestId + "."
                    + NAME_MTAS_LIST_QUERY_TYPE, list.queryType);
                params.add(PARAM_MTAS_LIST + "." + requestId + "."
                    + NAME_MTAS_LIST_QUERY_PREFIX, list.queryPrefix);
                params.add(PARAM_MTAS_LIST + "." + requestId + "."
                    + NAME_MTAS_LIST_QUERY_IGNORE, list.queryIgnore);
                params.add(
                    PARAM_MTAS_LIST + "." + requestId + "."
                        + NAME_MTAS_LIST_QUERY_MAXIMUM_IGNORE_LENGTH,
                    list.queryMaximumIgnoreLength);
                int subRequestId = 0;
                for (String name : list.queryVariables.keySet()) {
                  if (list.queryVariables.get(name) == null
                      || list.queryVariables.get(name).length == 0) {
                    params.add(
                        PARAM_MTAS_LIST + "." + requestId + "."
                            + NAME_MTAS_LIST_QUERY_VARIABLE + "." + subRequestId
                            + "." + SUBNAME_MTAS_LIST_QUERY_VARIABLE_NAME,
                        name);
                    subRequestId++;
                  } else {
                    for (String value : list.queryVariables.get(name)) {
                      params.add(PARAM_MTAS_LIST + "." + requestId + "."
                          + NAME_MTAS_LIST_QUERY_VARIABLE + "." + subRequestId
                          + "." + SUBNAME_MTAS_LIST_QUERY_VARIABLE_NAME, name);
                      params.add(PARAM_MTAS_LIST + "." + requestId + "."
                          + NAME_MTAS_LIST_QUERY_VARIABLE + "." + subRequestId
                          + "." + SUBNAME_MTAS_LIST_QUERY_VARIABLE_VALUE,
                          value);
                      subRequestId++;
                    }
                  }
                }
                params.add(PARAM_MTAS_LIST + "." + requestId + "."
                    + NAME_MTAS_LIST_KEY, list.key);
                params.add(PARAM_MTAS_LIST + "." + requestId + "."
                    + NAME_MTAS_LIST_PREFIX, list.prefix);
                params.add(PARAM_MTAS_LIST + "." + requestId + "."
                    + NAME_MTAS_LIST_START, Integer.toString(start));
                params.add(
                    PARAM_MTAS_LIST + "." + requestId + "."
                        + NAME_MTAS_LIST_NUMBER,
                    Integer.toString(Math.min(number, (subTotal - start))));
                params.add(PARAM_MTAS_LIST + "." + requestId + "."
                    + NAME_MTAS_LIST_LEFT, Integer.toString(list.left));
                params.add(PARAM_MTAS_LIST + "." + requestId + "."
                    + NAME_MTAS_LIST_RIGHT, Integer.toString(list.right));
                params.add(PARAM_MTAS_LIST + "." + requestId + "."
                    + NAME_MTAS_LIST_OUTPUT, list.output);
                number -= (subTotal - start);
                start = 0;
              } else {
                start -= subTotal;
              }
            }
          }
        }
      }

      for (Entry<String, ModifiableSolrParams> entry : shardRequests
          .entrySet()) {
        ShardRequest sreq = new ShardRequest();
        sreq.shards = new String[] { entry.getKey() };
        sreq.purpose = ShardRequest.PURPOSE_PRIVATE;
        sreq.params = new ModifiableSolrParams();
        sreq.params.add(CommonParams.FQ, rb.req.getParams().getParams(CommonParams.FQ));
        sreq.params.add(CommonParams.Q, rb.req.getParams().getParams(CommonParams.Q));
        sreq.params.add(CommonParams.CACHE, rb.req.getParams().getParams(CommonParams.CACHE));
        sreq.params.add(CommonParams.ROWS, "0");
        sreq.params.add(MtasSolrSearchComponent.PARAM_MTAS, rb.req
            .getOriginalParams().getParams(MtasSolrSearchComponent.PARAM_MTAS));
        sreq.params.add(PARAM_MTAS_LIST,
            rb.req.getOriginalParams().getParams(PARAM_MTAS_LIST));
        sreq.params.add(entry.getValue());
        rb.addRequest(searchComponent, sreq);
      }
    }
  }
709597
@Override
    public void receiveUpdate(INDArray array) {
        extCounter.getAndIncrement();

        updatesLock.writeLock().lock();

        if (updates == null) {
            try (MemoryWorkspace workspace = Nd4j.getMemoryManager().scopeOutOfWorkspaces()) {
                // TODO: this one has to be HOST-only if P2P is NOT supported
                updates = Nd4j.create(array.shape(), array.ordering());
            }
        }

        hasSomething.compareAndSet(false, true);

        // if P2P is NOT supported - this call should be handled with cpu
        updates.addi(array);

        // we have to ensure, all operations were finished here
        Nd4j.getExecutioner().commit();

        updatesLock.writeLock().unlock();
    }
1047021
public static SparseTensor empty(List<Integer> dimensionNumbers, List<Integer> dimensionSizes) {
    return empty(Ints.toArray(dimensionNumbers), Ints.toArray(dimensionSizes));
  }
159563
private static Object createAndPopulateVarArgsArray(Class<?> varArgsType, int varArgsStartPosition,
                                                        Object... arguments) {
        Object arrayInstance = Array.newInstance(varArgsType, arguments.length - varArgsStartPosition);
        for (int i = varArgsStartPosition; i < arguments.length; i++) {
            Array.set(arrayInstance, i - varArgsStartPosition, arguments[i]);
        }
        return arrayInstance;
    }
875022
private static <T extends Comparable<? super T>> void heapify(T[] arr) {
        int n = arr.length;
        for (int i = n / 2 - 1; i >= 0; i--)
            SortUtils.siftDown(arr, i, n - 1);
    }
388288
def gmdaOnes(shape, dtype, mask=None, numGhosts=1):
    
    res = GhostedMaskedDistArray(shape, dtype)
    res.mask = mask
    res.setNumberOfGhosts(numGhosts)
    res[:] = 1
    return res
893420
@Override
    public void synchronizeHostData(DataBuffer buffer) {
        // we don't want non-committed ops left behind
        //Nd4j.getExecutioner().push();

        // we don't synchronize constant buffers, since we assume they are always valid on host side
        if (buffer.isConstant() || buffer.dataType() == DataType.UTF8) {
            return;
        }

        // we actually need synchronization only in device-dependant environment. no-op otherwise
        if (memoryHandler.isDeviceDependant()) {
            val point = getAllocationPoint(buffer.getTrackingPoint());
            if (point == null)
                throw new RuntimeException("AllocationPoint is NULL");
            memoryHandler.synchronizeThreadDevice(Thread.currentThread().getId(), memoryHandler.getDeviceId(), point);
        }
    }
766180
@SafeVarargs
    public static <E> List<E> asList(E[]... arrs) {
        int size = 0;
        for (E[] arr : arrs) {
            if (arr == null) {
                throw new IllegalArgumentException("Null arrays not allowed");
            }
            size += arr.length;
        }
        List<E> result = new ArrayList<>(size);
        addAll(result, arrs);
        return result;
    }
70338
@Override
    public void onNDArray(INDArray arr) {
        try (AeronNDArrayPublisher publisher = AeronNDArrayPublisher.builder().streamId(streamId).ctx(aeronContext)
                        .channel(masterUrl).build()) {
            publisher.publish(arr);
            log.debug("NDArray PublishingListener publishing to channel " + masterUrl + ":" + streamId);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }


    }
211451
def gdaOnes(shape, dtype, numGhosts=1):
    
    res = GhostedDistArray(shape, dtype)
    res.setNumberOfGhosts(numGhosts)
    res[:] = 1
    return res
4722
public static void assertArraySize(int size, double[] array, Supplier<String> errmsg){
		if(array.length != size){
			throw new IllegalArgumentException(errmsg.get());
		}
	}
797667
public static Guid fromByteArrays(byte[]... byteArrays) throws IOException {
    if (byteArrays == null || byteArrays.length == 0) {
      throw new IOException("Attempting to compute guid for an empty array.");
    }

    if (byteArrays.length == 1) {
      return new Guid(byteArrays[0]);
    }
    byte[] tmp = new byte[0];
    for (byte[] arr : byteArrays) {
      tmp = ArrayUtils.addAll(tmp, arr);
    }
    return new Guid(tmp);
  }
1001754
public static void main(String[] args)
    {
        if (args.length==0 || args.length>2)
        {
            System.err.println
                ("\nUsage - java org.browsermob.proxy.jetty.http.HttpServer [<addr>:]<port>");
            System.err.println
                ("\nUsage - java org.browsermob.proxy.jetty.http.HttpServer -r [savefile]");
            System.err.println
                ("  Serves files from '.' directory");
            System.err.println
                ("  Dump handler for not found requests");
            System.err.println
                ("  Default port is 8080");
            System.exit(1);
        }
        
        try{
            
            if (args.length==1)
            {
                // Create the server
                HttpServer server = new HttpServer();
                
                // Default is no virtual host
                String host=null;
                HttpContext context = server.getContext(host,"/");
                context.setResourceBase(".");
                context.addHandler(new ResourceHandler());
                context.addHandler(new DumpHandler());
                context.addHandler(new NotFoundHandler());

                InetAddrPort address = new InetAddrPort(args[0]);
                server.addListener(address);

                server.start();
            }
            else
            {
                Resource resource = Resource.newResource(args[1]);
                ObjectInputStream in = new ObjectInputStream(resource.getInputStream());
                HttpServer server = (HttpServer)in.readObject();
                in.close();
                server.start();
            }
            
        }
        catch (Exception e)
        {
            log.warn(LogSupport.EXCEPTION,e);
        }
    }