Get a thread-local record input for the supplied DataInput.
@param inp data input stream
@return binary record input corresponding to the supplied DataInput.
760356
public static BinaryRecordInput get(DataInput inp) {
    BinaryRecordInput bin = (BinaryRecordInput) bIn.get();
    bin.setDataInput(inp);
    return bin;
  }
652259
public static <B extends Buffer> Input<B> fromSource(
            ManagedBuffer<B> buffer, boolean endOfRecord) {
        return new Input<>(buffer, endOfRecord);
    }
369277
public static String getInput(String prompt) {
        System.out.print(prompt);

        try {
            BufferedReader in =
                new BufferedReader(new InputStreamReader(System.in));
            return in.readLine();
        } catch(IOException e) {
            return null;
        }
    }
955843
protected @CheckForNull T get(@Nonnull String key, boolean createIfNotExist, P createParams) throws IOException {
        while(true) {
            totalQuery.incrementAndGet();
            Object value = core.get(key);

            if(value instanceof SoftReference) {
                SoftReference<T> wfp = (SoftReference<T>) value;
                T t = wfp.get();
                if(t!=null) {
                    cacheHit.incrementAndGet();
                    return t;  // found it
                }
                weakRefLost.incrementAndGet();
            }
            if(value instanceof Loading) {
                // another thread is loading it. get the value from there.
                T t = ((Loading<T>)value).get();
                if(t!=null || !createIfNotExist)
                    return t;   // found it (t!=null) or we are just 'get' (!createIfNotExist)
            }

            // the fingerprint doesn't seem to be loaded thus far, so let's load it now.
            // the care needs to be taken that other threads might be trying to do the same.
            Loading<T> l = new Loading<>();
            if(value==null ? core.putIfAbsent(key,l)!=null : !core.replace(key,value,l)) {
                // the value has changed since then. another thread is attempting to do the same.
                // go back to square 1 and try it again.
                continue;
            }

            T t = null;
            try {
                t = load(key);
                if(t==null && createIfNotExist) {
                    t = create(key,createParams);    // create the new data
                    if(t==null)
                        throw new IllegalStateException("Bug in the derived class"); // bug in the derived classes
                }
            } catch(IOException e) {
                loadFailure.incrementAndGet();
                throw e;
            } finally {
                // let other threads know that the value is available now.
                // when the original thread failed to load, this should set it to null.
                l.set(t);
            }

            // the map needs to be updated to reflect the result of loading
            if(t!=null)
                core.put(key, new SoftReference<>(t));
            else
                core.remove(key);

            return t;
        }

    }
288965
public static int getNumParametersForInvocation(InvokeInstruction inv, ConstantPoolGen cpg) {
        SignatureParser sigParser = new SignatureParser(inv.getSignature(cpg));
        return sigParser.getNumParameters();
    }
1227261
public static BinaryRecordOutput get(DataOutput out) {
    BinaryRecordOutput bout = (BinaryRecordOutput) bOut.get();
    bout.setDataOutput(out);
    return bout;
  }
221490
public INDArray[] output(INDArray[] input, INDArray[] inputMasks){
        Nd4j.getExecutioner().commit(); //Commit before passing input to other thread

        // basically, depending on model type we either throw stuff to specific model, or wait for batch
        BasicInferenceObserver observer = new BasicInferenceObserver();
        InferenceObservable observable;

        if (inferenceMode == InferenceMode.SEQUENTIAL) {
            observable = new BasicInferenceObservable(input, inputMasks);
            observable.addObserver(observer);
            try {
                observables.put(observable);
            } catch (InterruptedException e) {
                Thread.currentThread().interrupt();
                throw new RuntimeException(e);
            }
        } else {
            observable = provider.setInput(observer, input, inputMasks);
        }

        try {
            // submit query to processing
            // and block until Observable returns
            //observer.wait();

            observer.waitTillDone();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }

        return observable.getOutput();
    }
85072
public StreamRecord<T> getStreamRecord() {
		StreamRecord<T> streamRecord = new StreamRecord<>(value);
		if (hasTimestamp) {
			streamRecord.setTimestamp(timestamp);
		}
		return streamRecord;
	}
420703
@Override
  public void readFrom(StreamInput in) throws IOException {
    super.readFrom(in);

    routing = in.readOptionalString();
    preference = in.readOptionalString();

    if (in.readBoolean()) {
      querySource = in.readBytesReference();
    } else {
      querySource = null;
    }

    if (in.readBoolean()) {
      types = in.readStringArray();
    }

    field = in.readString();
    nowInMillis = in.readVLong();

    if (in.readBoolean()) {
      ordering = Ordering.values()[in.readVInt()];
    }

    if (in.readBoolean()) {
      maxTermsPerShard = in.readVInt();
    }

    if (in.readBoolean()) {
      termsEncoding = TermsEncoding.values()[in.readVInt()];
    }

    if (in.readBoolean()) {
      expectedTerms = in.readVLong();
    }
  }
759641
protected P upConvertPayload(GenericRecord inputRecord) throws DataConversionException {
    try {
      Schema payloadSchema = getPayloadSchema(inputRecord);
      // Set writer schema
      latestPayloadReader.setSchema(payloadSchema);

      byte[] payloadBytes = getPayloadBytes(inputRecord);
      Decoder decoder = DecoderFactory.get().binaryDecoder(payloadBytes, null);

      // 'latestPayloadReader.read' will convert the record from 'payloadSchema' to the latest payload schema
      return latestPayloadReader.read(null, decoder);
    } catch (Exception e) {
      throw new DataConversionException(e);
    }
  }
1023662
public static Class<? extends CobolTypeFinder> getInputRecordMatcher(Configuration conf) {
      return conf.getClass(CONF_INPUT_RECORD_MATCHER_CLASS, null, CobolTypeFinder.class);
    }
376210
public static byte[] readLine(InputStream in) throws IOException {
		int BUFF_LENGTH = 256;
		byte[] buf = new byte[BUFF_LENGTH];

		int i = 0;
		int loops = 0;
		int ch = 0;

		while (true) {
			ch = in.read();
			if (ch < 0) {
				break;
			}
			loops++;

			// skip a leading LF's
			if (loops == 1 && ch == LF) {
				continue;
			}

			if (ch == CR || ch == LF) {
				break;
			}

			if (i >= buf.length) {
				byte[] oldBuf = buf;
				buf = new byte[oldBuf.length + BUFF_LENGTH];
				System.arraycopy(oldBuf, 0, buf, 0, oldBuf.length);
			}
			buf[i++] = (byte) ch;
		}

		if (ch == -1 && i == 0) {
			return null;
		}

		// skip a trailing LF if it exists
		if (ch == CR && in.available() >= 1 && in.markSupported()) {
			in.mark(1);
			ch = in.read();
			if (ch != LF) {
				in.reset();
			}
		}

		byte[] oldBuf = buf;
		buf = new byte[i];
		System.arraycopy(oldBuf, 0, buf, 0, i);

		return buf;
	}
268722
public static Iterable<VcfRecord> records(final InputStream inputStream) throws IOException {
        checkNotNull(inputStream);
        try (BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream))) {
            return records(reader);
        }
    }
1247027
@Override
    protected InjectionPoint getInjectionPoint(InvokeInstruction invoke, ConstantPoolGen cpg,
                                               InstructionHandle handle) {
        assert invoke != null && cpg != null;

        //ByteCode.printOpCode(invoke,cpg);

        if(CIPHER_GET_INSTANCE.matches(invoke,cpg)) {
            return new InjectionPoint(new int[]{0}, getBugPattern());
        }
        else if(CIPHER_GET_INSTANCE_PROVIDER.matches(invoke,cpg)) {
            return new InjectionPoint(new int[]{1}, getBugPattern());
        }
        else if(KEYGENERATOR_GET_INSTANCE.matches(invoke,cpg)) {
            return new InjectionPoint(new int[]{0}, getBugPattern());
        }
        else if(KEYGENERATOR_GET_INSTANCE_PROVIDER.matches(invoke,cpg)) {
            return new InjectionPoint(new int[]{1}, getBugPattern());
        }
        return InjectionPoint.NONE;
    }
630750
public static void copyThread(InputStream in, OutputStream out)
    {
        try{
            instance().run(new Job(in,out));
        }
        catch(InterruptedException e)
        {
            log.warn(LogSupport.EXCEPTION,e);
        }
    }
24989
public static Pair<String, String> readStringPair(DataInputStream in) {
    Pair<String, String> p = new Pair<String, String>();
    try {
      p.first = in.readUTF();
      p.second = in.readUTF();
    } catch (Exception e) {
      e.printStackTrace();
    }
    return p;
  }
935146
private ByteBuffer submitBuffer(ByteBuffer in) {
        ByteBuffer out = in.asReadOnlyBuffer();
        in.position(in.limit());
        return out;
    }