@Nullable @Override public Object defaultValue() { throw new IORuntimeException("field " + name() + " required"); } }
@NotNull @Override @SuppressWarnings("rawtypes") public BytesRef read(Bytes in, long size, @Nullable BytesRef using) { if (size < 0L || size > (long) Integer.MAX_VALUE) { throw new IORuntimeException("byte[] size should be non-negative int, " + size + " given. Memory corruption?"); } int arrayLength = (int) size; if (using == null) { using = new BytesRef(new byte[arrayLength]); } else if (using.bytes.length < arrayLength) { using.bytes = new byte[arrayLength]; } in.read(using.bytes, 0, arrayLength); using.offset = 0; using.length = arrayLength; return using; }
"Unable to move to sourceIndex %s in queue %s", Long.toHexString(sourceIndex), this.queue.fileAbsolutePath()); throw new IORuntimeException(errorMessage + extraInfo(tailer, messageHistory)); "No readable document found at sourceIndex %s in queue %s", Long.toHexString(sourceIndex + 1), this.queue.fileAbsolutePath()); throw new IORuntimeException(errorMessage + extraInfo(tailer, messageHistory));
@Override public long index() throws IORuntimeException { if (this.wire.headerNumber() == Long.MIN_VALUE) { try { wire.headerNumber(queue.rollCycle().toIndex(cycle, store.lastSequenceNumber(StoreAppender.this))); long headerNumber0 = wire.headerNumber(); assert (((AbstractWire) this.wire).isInsideHeader()); return isMetaData() ? headerNumber0 : headerNumber0 + 1; } catch (IOException e) { throw new IORuntimeException(e); } } return isMetaData() ? Long.MIN_VALUE : this.wire.headerNumber() + 1; }
throw new IORuntimeException(e);
try { ... } catch (IOException ioex) { throw new IORuntimeException(ioex); }
@NotNull @Override public byte[] uncompress(@NotNull byte[] bytes) throws IORuntimeException { try { return org.xerial.snappy.Snappy.uncompress(bytes); } catch (IOException e) { throw new IORuntimeException(e); } }
@NotNull @Override public InputStream decompressingStream(InputStream input) throws IORuntimeException { try { return new SnappyInputStream(input); } catch (IOException e) { throw new IORuntimeException(e); } }
@Override public InetSocketAddress getLocalAddress() throws IORuntimeException { try { return (InetSocketAddress) socketChannel.getLocalAddress(); } catch (IOException e) { throw new IORuntimeException(e); } }
@Override public InetSocketAddress getLocalAddress() throws IORuntimeException { try { return (InetSocketAddress) socketChannel.getLocalAddress(); } catch (IOException e) { throw new IORuntimeException(e); } }
default byte[] uncompress(@NotNull byte[] bytes) throws IORuntimeException { @NotNull ByteArrayOutputStream baos = new ByteArrayOutputStream(); try (InputStream input = decompressingStream(new ByteArrayInputStream(bytes))) { @NotNull byte[] buf = new byte[512]; for (int len; (len = input.read(buf)) > 0; ) baos.write(buf, 0, len); } catch (IOException e) { throw new IORuntimeException(e); } return baos.toByteArray(); }
@Nullable @Override public Object defaultValue() { throw new IORuntimeException("field " + name() + " required"); } }
@Override public InetSocketAddress getRemoteAddress() throws IORuntimeException { try { return (InetSocketAddress) socketChannel.getRemoteAddress(); } catch (IOException e) { throw new IORuntimeException(e); } }
@Override public InetSocketAddress getRemoteAddress() throws IORuntimeException { try { return (InetSocketAddress) socketChannel.getRemoteAddress(); } catch (IOException e) { throw new IORuntimeException(e); } }
@NotNull @Override public byte[] read(@NotNull Bytes in, long size, @Nullable byte[] using) { if (size < 0L || size > (long) Integer.MAX_VALUE) { throw new IORuntimeException("byte[] size should be non-negative int, " + size + " given. Memory corruption?"); } int arrayLength = (int) size; if (using == null || arrayLength != using.length) using = new byte[arrayLength]; in.read(using); return using; }
public static void appendBytesFromStart(@org.jetbrains.annotations.NotNull Bytes bytes, long startPosition, @org.jetbrains.annotations.NotNull StringBuilder sb) { try { BytesInternal.parse8bit(startPosition, bytes, sb, (int) (bytes.readPosition() - startPosition)); sb.append('\u2016'); sb.append(bytes); } catch (IOException e) { throw new IORuntimeException(e); } }
default void uncompress(@NotNull BytesIn from, @NotNull BytesOut to) throws IORuntimeException { try (InputStream input = decompressingStream(from.inputStream())) { to.copyFrom(input); } catch (IOException e) { throw new IORuntimeException(e); } }
default boolean read8bit(@NotNull StringBuilder sb) throws IORuntimeException, BufferUnderflowException { sb.setLength(0); long len0 = BytesInternal.readStopBit(this); if (len0 == -1) return false; int len = Maths.toUInt31(len0); try { AppendableUtil.parse8bit(this, sb, len); } catch (IOException e) { throw new IORuntimeException(e); } return true; }
default <ACS extends Appendable & CharSequence> boolean read8bit(@NotNull ACS sb) throws IORuntimeException, IllegalArgumentException, BufferUnderflowException { AppendableUtil.setLength(sb, 0); long len0 = BytesInternal.readStopBit(this); if (len0 == -1) return false; int len = Maths.toUInt31(len0); try { AppendableUtil.parse8bit(this, sb, len); } catch (IOException e) { throw new IORuntimeException(e); } return true; }
MappedUniqueMicroTimeProvider() { try { file = MappedFile.mappedFile(OS.TMP + "/.time-stamp.dat", OS.pageSize(), 0); bytes = file.acquireBytesForWrite(0); bytes.append8bit("&TSF\nTime stamp file uses for sharing a unique id\n"); BytesUtil.unregister(bytes); } catch (IOException ioe) { throw new IORuntimeException(ioe); } }