@NotNull @Override public ListIterator<E> listIterator(int index) { throw new UnsupportedOperationException(); }
@NotNull @SuppressWarnings("ConstantConditions") final ValueIn valueIn = inWire.readEventName(eventName); @NotNull final ValueOut valueOut = out.writeEventName(CoreFields.reply); valueOut.sequence(v -> underlyingCollection.forEach(e -> toWire.accept(v, e))); return; Jvm.warn().on(getClass(), e); assert outWire.startUse(); try { @NotNull final Bytes<?> outBytes = outWire.bytes(); long len = outBytes.writePosition(); if (len >= SIZE_OF_SIZE) { String s = Wires.fromSizePrefixedBlobs((Wire) outWire);
@NotNull @Override public final T read(@NotNull Bytes in, long size, @Nullable T using) { if (using == null) using = createInstance(); using.bytesStore(in.bytesStore(), in.readPosition(), size); return using; } }
@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; }
@NotNull @Override public T read(Bytes in, @Nullable T using) { try { return (T) new ObjectInputStream(in.inputStream()).readObject(); } catch (IOException | ClassNotFoundException e) { throw new RuntimeException(e); } }
@NotNull @Override public Double read(@NotNull Bytes in, long size, @Nullable Double using) { return in.readDouble(); }
@Nullable ScanResult moveToIndex0(@NotNull final ExcerptContext ec, final long index) { return null; @NotNull final LongArrayValues array1 = arrayForAddress(wire, secondaryAddress); long secondaryOffset = toAddress1(index); ec.wire().bytes().readPositionUnlimited(fromAddress); return ScanResult.FOUND; } else {
private static void readUtf8_SB1( @org.jetbrains.annotations.NotNull @NotNull Bytes bytes, @org.jetbrains.annotations.NotNull @NotNull StringBuilder appendable, @org.jetbrains.annotations.NotNull @NotNull StopCharTester tester) throws IOException, BufferUnderflowException { @org.jetbrains.annotations.Nullable NativeBytesStore nb = (NativeBytesStore) bytes.bytesStore(); int i = 0, len = Maths.toInt32(bytes.readRemaining()); long address = nb.address + nb.translate(bytes.readPosition()); @org.jetbrains.annotations.Nullable Memory memory = nb.memory; if (Jvm.isJava9Plus()) { int appendableLength = appendable.capacity(); for (; i < len && i < appendableLength; i++) {
public static void parse8bit_SB1(@org.jetbrains.annotations.NotNull @NotNull Bytes bytes, @org.jetbrains.annotations.NotNull @NotNull StringBuilder sb, int utflen) throws BufferUnderflowException { if (utflen > bytes.readRemaining()) throw new BufferUnderflowException(); @Nullable NativeBytesStore nbs = (NativeBytesStore) bytes.bytesStore(); long offset = bytes.readPosition(); int count = BytesInternal.parse8bit_SB1(offset, nbs, sb, utflen); bytes.readSkip(count); }
private void onRead0(@NotNull DocumentContext inDc, @NotNull WireOut out, @NotNull WireIn in) { if (!YamlLogging.showHeartBeats()) { prevLogMessage.append(currentLogMessage); currentLogMessage.setLength(0); logToBuffer(in, currentLogMessage, in.bytes().readPosition() - 4); } else { Jvm.debug().on(getClass(), "received data:\n" + in.bytes().toHexString()); @NotNull Consumer<WireType> wireTypeConsumer = wt -> { wireType(wt); checkWires(in.bytes(), out.bytes(), wireType()); @Nullable Map<String, UserStat> userMonitoringMap = getMonitoringMap(); if (userMonitoringMap != null) { UserStat userStat = userMonitoringMap.get(sessionDetails.userId()); Jvm.warn().on(getClass(), in.readingPeekYaml() + "/n" + in.bytes().toDebugString(), e);
private void writeToFile(@NotNull Path path, @NotNull BytesStore value) { BytesStore<?, ByteBuffer> writingBytes; if (value.underlyingObject() instanceof ByteBuffer) { Buffers b = Buffers.BUFFERS.get(); Bytes<ByteBuffer> valueBuffer = b.valueBuffer; valueBuffer.clear(); valueBuffer.write(value); writingBytes = valueBuffer; @NotNull File tmpFile = new File(file.getParentFile(), "." + file.getName() + "." + System.nanoTime()); try (@NotNull FileChannel fc = new FileOutputStream(tmpFile).getChannel()) { @Nullable ByteBuffer byteBuffer = writingBytes.underlyingObject(); byteBuffer.position(0); byteBuffer.limit((int) writingBytes.readLimit()); Jvm.debug().on(getClass(), "Unable to rename file " + fse); try { Thread.sleep(i * i * 2);
@NotNull public Bytes acquireBytesForWrite(long position) throws IOException, IllegalStateException, IllegalArgumentException { @Nullable MappedBytesStore mbs = acquireByteStore(position); @NotNull Bytes bytes = mbs.bytesForWrite(); bytes.writePosition(position); mbs.release(); return bytes; }
private void readMarshallable(String path, @NotNull WireIn wire) { @NotNull StringBuilder name = new StringBuilder(); while (!wire.isEmpty()) { @NotNull ValueIn in = wire.read(name); long pos = wire.bytes().readPosition(); @NotNull String path2 = path + "/" + name; if (wire.getValueIn().isTyped()) { wire.bytes().readPosition(pos); @Nullable Object o = in.typedMarshallable(); installableMap.put(path2, (Installable) o); } else { in.marshallable(w -> this.readMarshallable(path2, w)); } } }
/** * Convenience method so you don't need to release the BytesStore */ @NotNull public Bytes acquireBytesForRead(long position) throws IOException, IllegalStateException, IllegalArgumentException { @Nullable MappedBytesStore mbs = acquireByteStore(position); Bytes bytes = mbs.bytesForRead(); bytes.readPositionUnlimited(position); mbs.release(); return bytes; }
@Override public long recoverAndWriteHeader(@NotNull Wire wire, long timeoutMS, final LongValue lastPosition, Sequence sequence) throws UnrecoverableTimeoutException { Bytes<?> bytes = wire.bytes(); long offset = bytes.writePosition(); int num = bytes.readVolatileInt(offset); final long targetHeaderNumber = wire.headerNumber() + 1; String msgStart = "Unable to write a header at header number: 0x" + Long.toHexString(targetHeaderNumber) + " position: " + offset; if (Wires.isNotComplete(num)) { if (bytes instanceof MappedBytes) { MappedBytes mb = (MappedBytes) bytes; sizeToSkip = Maths.toUInt31(mb.mappedFile().overlapSize() / 2); long pos = bytes.writePosition(); try { bytes.writeSkip(4); final String debugMessage = "!! Skipped due to recovery of locked header !! By thread " + Thread.currentThread().getName() + ", pid " + OS.getProcessId(); wire.getValueOut().text(debugMessage); final StringWriter stackVisitor = new StringWriter(); new RuntimeException().printStackTrace(new PrintWriter(stackVisitor));