Refine search
@SuppressWarnings("unused") @UsedViaReflection SCQMeta(@NotNull WireIn wire) { this.roll = Objects.requireNonNull(wire.read(MetaDataField.roll).typedMarshallable()); this.deltaCheckpointInterval = wire.bytes().readRemaining() > 0 ? wire.read(MetaDataField.deltaCheckpointInterval).int32() : -1; // disabled. this.sourceId = wire.bytes().readRemaining() > 0 ? wire.read(MetaDataField.sourceId).int32() : 0; }
/** * used by {@link Demarshallable} * * @param wire a wire */ @SuppressWarnings("unused") @UsedViaReflection private SingleTableStore(@NotNull WireIn wire) { assert wire.startUse(); try { this.wireType = Objects.requireNonNull(wire.read(MetaDataField.wireType).object(WireType.class)); this.mappedBytes = (MappedBytes) (wire.bytes()); this.mappedFile = mappedBytes.mappedFile(); this.refCount = ReferenceCounter.onReleased(this::onCleanup); if (wire.bytes().readRemaining() > 0) { this.recovery = Objects.requireNonNull(wire.read(MetaDataField.recovery).typedMarshallable()); } else { this.recovery = new SimpleStoreRecovery(); // disabled. } if (wire.bytes().readRemaining() > 0) { this.metadata = Objects.requireNonNull(wire.read(MetaDataField.metadata).typedMarshallable()); } else { this.metadata = (T) Metadata.NoMeta.INSTANCE; } mappedWire = wireType.apply(mappedBytes); } finally { assert wire.endUse(); } }
public T intern(@NotNull Bytes cs) throws IllegalArgumentException, IORuntimeException, BufferUnderflowException { return intern((BytesStore) cs, (int) cs.readRemaining()); }
@org.jetbrains.annotations.NotNull public static char[] toCharArray(@org.jetbrains.annotations.NotNull Bytes bytes) { @org.jetbrains.annotations.NotNull final char[] chars = new char[Maths.toUInt31(bytes.readRemaining())]; for (int i = 0; i < bytes.readRemaining(); i++) { chars[i] = (char) bytes.readUnsignedByte(i + bytes.readPosition()); } return chars; }
public static BytesStore<Bytes<Void>, Void> copyOf(@NotNull Bytes bytes) { long remaining = bytes.readRemaining(); NativeBytes<Void> bytes2; try { bytes2 = Bytes.allocateElasticDirect(remaining); bytes2.write(bytes, 0, remaining); return bytes2; } catch (IllegalArgumentException | BufferOverflowException | BufferUnderflowException e) { throw new AssertionError(e); } }
@Override public boolean equals(Object obj) { if (!(obj instanceof Bytes)) return false; @NotNull Bytes b2 = (Bytes) obj; long remaining = readRemaining(); return b2.readRemaining() == remaining && equalsBytes(b2, remaining); }
@NotNull public RequestContext queryString(@NotNull String queryString) { if (queryString.isEmpty()) return this; @NotNull WireParser<Void> parser = getWireParser(); Bytes bytes = Bytes.from(queryString); @NotNull QueryWire wire = new QueryWire(bytes); while (bytes.readRemaining() > 0) parser.parseOne(wire, null); return this; }
public String intern(@NotNull final Bytes bytes) { return intern(bytes, Maths.toUInt31(bytes.readRemaining())); }
static String toString(@NotNull final Bytes<?> buffer, long maxLen) throws BufferUnderflowException { try { if (buffer.readRemaining() == 0) return ""; final long length = Math.min(maxLen + 1, buffer.readRemaining()); @NotNull final StringBuilder builder = new StringBuilder(); try { buffer.readWithLength(length, b -> { while (buffer.readRemaining() > 0) { if (builder.length() >= maxLen) { builder.append("...");
@SuppressWarnings("unused") @UsedViaReflection SCQMeta(@NotNull WireIn wire) { this.roll = Objects.requireNonNull(wire.read(MetaDataField.roll).typedMarshallable()); this.deltaCheckpointInterval = wire.bytes().readRemaining() > 0 ? wire.read(MetaDataField.deltaCheckpointInterval).int32() : -1; // disabled. this.sourceId = wire.bytes().readRemaining() > 0 ? wire.read(MetaDataField.sourceId).int32() : 0; }
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); }
/** * The buffer is not modified by this call * * @param buffer the buffer to use * @param position the position to create the string from * @param len the number of characters to show in the string * @return a string contain the text from offset {@code position} */ static String toString(@NotNull final Bytes buffer, long position, long len) throws BufferUnderflowException { final long pos = buffer.readPosition(); final long limit = buffer.readLimit(); buffer.readPositionRemaining(position, len); try { @NotNull final StringBuilder builder = new StringBuilder(); while (buffer.readRemaining() > 0) { builder.append((char) buffer.readByte()); } // remove the last comma return builder.toString(); } finally { buffer.readLimit(limit); buffer.readPosition(pos); } }
@org.jetbrains.annotations.NotNull @NotNull default S writeSome(@org.jetbrains.annotations.NotNull @NotNull Bytes bytes) { try { long length = Math.min(bytes.readRemaining(), writeRemaining()); if (length + writePosition() >= 1 << 20) length = Math.min(bytes.readRemaining(), realCapacity() - writePosition()); write(bytes, bytes.readPosition(), length); if (length == bytes.readRemaining()) { bytes.clear(); } else { bytes.readSkip(length); if (bytes.writePosition() > bytes.realCapacity() / 2) bytes.compact(); } return (S) this; } catch (BufferOverflowException | BufferUnderflowException | IllegalArgumentException e) { throw new AssertionError(e); } }
@Override @NotNull public NativeBytes writeSome(@NotNull Bytes bytes) { try { long length = Math.min(bytes.readRemaining(), writeRemaining()); if (length + writePosition() >= 1 << 20) length = Math.min(bytes.readRemaining(), realCapacity() - writePosition()); long offset = bytes.readPosition(); long position = writePosition(); ensureCapacity(position + length); optimisedWrite(bytes, offset, length); if (length == bytes.readRemaining()) { bytes.clear(); } else { bytes.readSkip(length); if (bytes.writePosition() > bytes.realCapacity() / 2) bytes.compact(); } return this; } catch (IllegalArgumentException | BufferUnderflowException | BufferOverflowException e) { throw new AssertionError(e); } }
public static void parseUtf8_SB1(@org.jetbrains.annotations.NotNull @NotNull Bytes bytes, @org.jetbrains.annotations.NotNull @NotNull StringBuilder sb, int utflen) throws UTFDataFormatRuntimeException, BufferUnderflowException { try { int count = 0; if (utflen > bytes.readRemaining()) { @org.jetbrains.annotations.NotNull final BufferUnderflowException bue = new BufferUnderflowException(); bue.initCause(new IllegalStateException("utflen: " + utflen + ", readRemaining: " + bytes.readRemaining())); throw bue;
/** * used by {@link Demarshallable} * * @param wire a wire */ @SuppressWarnings("unused") @UsedViaReflection private SingleTableStore(@NotNull WireIn wire) { assert wire.startUse(); try { this.wireType = Objects.requireNonNull(wire.read(MetaDataField.wireType).object(WireType.class)); this.mappedBytes = (MappedBytes) (wire.bytes()); this.mappedFile = mappedBytes.mappedFile(); this.refCount = ReferenceCounter.onReleased(this::onCleanup); if (wire.bytes().readRemaining() > 0) { this.recovery = Objects.requireNonNull(wire.read(MetaDataField.recovery).typedMarshallable()); } else { this.recovery = new SimpleStoreRecovery(); // disabled. } if (wire.bytes().readRemaining() > 0) { this.metadata = Objects.requireNonNull(wire.read(MetaDataField.metadata).typedMarshallable()); } else { this.metadata = (T) Metadata.NoMeta.INSTANCE; } mappedWire = wireType.apply(mappedBytes); } finally { assert wire.endUse(); } }
@NotNull public BytesTextMethodTester run() throws IOException { if (bytes.readRemaining() > 1) bytes2.comment("## End Of Message");
@org.jetbrains.annotations.NotNull public static Bytes fromHexString(@org.jetbrains.annotations.NotNull String s) { try { Bytes in = Bytes.from(s); Bytes out = Bytes.elasticByteBuffer(); OUTER: while (in.readRemaining() > 0) { in.parseHexLong(); for (int i = 0; i < 16; i++) { if (in.peekUnsignedByte() == ' ') { in.readSkip(1); if (in.peekUnsignedByte() == ' ') break OUTER; } long value = in.parseHexLong(); out.writeByte((byte) value); } if (in.readByte(in.readPosition() - 1) <= ' ') in.readSkip(-1); in.skipTo(StopCharTesters.CONTROL_STOP); } return out; } catch (BufferUnderflowException | BufferOverflowException e) { throw new AssertionError(e); } }
default void readWithLength(long length, @NotNull BytesOut<Underlying> bytesOut) throws BufferUnderflowException, IORuntimeException { if (length > readRemaining()) throw new BufferUnderflowException(); long limit0 = readLimit(); long limit = readPosition() + length; boolean lenient = lenient(); try { lenient(true); readLimit(limit); bytesOut.write(this); } finally { readLimit(limit0); readPosition(limit); lenient(lenient); } }
public VanillaIndexQueueView(@NotNull RequestContext context, @NotNull Asset asset, @NotNull QueueView<?, V> queueView) { dc.wire().consumePadding(); if (dc.wire().bytes().readRemaining() == 0) return true;