Refine search
long linearScanByPosition0(@NotNull final Wire wire, final long toPosition, long indexOfNext, while (bytes.readPosition() <= toPosition) { WireIn.HeaderType headerType; try { if (!inclusive && toPosition == bytes.readPosition()) return i; int header = bytes.readVolatileInt(bytes.readPosition()); throw new IllegalArgumentException( "You can't know the index for an entry which hasn't been written. " + int len = Wires.lengthOf(header); assert Wires.isReady(header); bytes.readSkip(len);
long moveToEnd(final Wire wire) { Sequence sequence1 = this.sequence; if (sequence1 != null) { for (int i = 0; i < 128; i++) { long endAddress = writePosition.getVolatileValue(); if (endAddress == 0) return -1; long sequence = sequence1.getSequence(endAddress); if (sequence == Sequence.NOT_FOUND_RETRY) continue; if (sequence == Sequence.NOT_FOUND) return -1; Bytes<?> bytes = wire.bytes(); bytes.readPosition(endAddress); for (; ; ) { int header = bytes.readVolatileInt(endAddress); if (header == 0 || Wires.isNotComplete(header)) return sequence; int len = Wires.lengthOf(header) + 4; bytes.readSkip(len); endAddress += len; if (Wires.isData(header)) sequence += 1; } } } return -1; }
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); }
@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); } }
long linearScanByPosition0(@NotNull final Wire wire, final long toPosition, long indexOfNext, while (bytes.readPosition() <= toPosition) { WireIn.HeaderType headerType; try { if (!inclusive && toPosition == bytes.readPosition()) return i; int header = bytes.readVolatileInt(bytes.readPosition()); throw new IllegalArgumentException( "You can't know the index for an entry which hasn't been written. " + int len = Wires.lengthOf(header); assert Wires.isReady(header); bytes.readSkip(len);
public void alignReadPosition(Bytes entry) { long positionAddr = entry.addressForRead(entry.readPosition()); long skip = alignAddr(positionAddr, alignment) - positionAddr; if (skip > 0) entry.readSkip(skip); }
/** * converts the bytes to a ISO-8859-1 String, the end of the string is either the bytes .limit * () or a byte containing the stopByte ( which ever comes first ). If the string can be * obtained from the pool, this string is used instead. otherwise, the string is added to the * pool. * * @param bytes the bytes to convert to a string * @param length parse the string up to the length * @return the string made from bytes only ( rather than chars ) */ public String intern(@NotNull final Bytes bytes, int length) { try { int hash32 = BytesStoreHash.hash32(bytes, length); int h = hash32 & mask; String s = interner[h]; long position = bytes.readPosition(); if (BytesUtil.bytesEqual(s, bytes, position, length)) return s; int h2 = (hash32 >> shift) & mask; String s2 = interner[h2]; if (BytesUtil.bytesEqual(s2, bytes, position, length)) return s2; char[] chars = toCharArray(bytes, position, length); return interner[s == null || (s2 != null && toggle()) ? h : h2] = StringUtils.newString(chars); } finally { bytes.readSkip(length); } } }
long moveToEnd(final Wire wire) { Sequence sequence1 = this.sequence; if (sequence1 != null) { for (int i = 0; i < 128; i++) { long endAddress = writePosition.getVolatileValue(); if (endAddress == 0) return -1; long sequence = sequence1.getSequence(endAddress); if (sequence == Sequence.NOT_FOUND_RETRY) continue; if (sequence == Sequence.NOT_FOUND) return -1; Bytes<?> bytes = wire.bytes(); bytes.readPosition(endAddress); for (; ; ) { int header = bytes.readVolatileInt(endAddress); if (header == 0 || Wires.isNotComplete(header)) return sequence; int len = Wires.lengthOf(header) + 4; bytes.readSkip(len); endAddress += len; if (Wires.isData(header)) sequence += 1; } } } return -1; }
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; break; if (tester.isStopChar(c)) { bytes.readSkip(i + 1); StringUtils.setCount(appendable, i); return; break; if (tester.isStopChar(c)) { bytes.readSkip(i + 1); StringUtils.setCount(appendable, i); return; bytes.readSkip(i); if (i < len) { readUtf8_SB2(bytes, appendable, tester);
public void processReplicatedEvent(byte remoteNodeIdentifier, Bytes replicatedInputBytes) { long timestamp = replicatedInputBytes.readStopBit(); byte identifier = replicatedInputBytes.readByte(); this.initReplicationUpdate(identifier, timestamp, remoteNodeIdentifier); boolean isDeleted = replicatedInputBytes.readBoolean(); long keySize = this.m().keySizeMarshaller.readSize(replicatedInputBytes); long keyOffset = replicatedInputBytes.readPosition(); this.initInputKey(this.getInputKeyBytesAsData(replicatedInputBytes, keyOffset, keySize)); replicatedInputBytes.readSkip(keySize); if (isDeleted) { this.innerUpdateLock.lock(); this.m().remoteOperations.remove(this); } else { long valueSize = this.m().valueSizeMarshaller.readSize(replicatedInputBytes); long valueOffset = replicatedInputBytes.readPosition(); Data<V> value = this.wrapValueBytesAsData(replicatedInputBytes, valueOffset, valueSize); replicatedInputBytes.readSkip(valueSize); this.innerWriteLock.lock(); this.m().remoteOperations.put(this, value); } }
@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); } }
public void processReplicatedEvent(byte remoteNodeIdentifier, Bytes replicatedInputBytes) { long timestamp = replicatedInputBytes.readStopBit(); byte identifier = replicatedInputBytes.readByte(); ru.initReplicationUpdate(identifier, timestamp, remoteNodeIdentifier); boolean isDeleted = replicatedInputBytes.readBoolean(); long keySize = mh.m().keySizeMarshaller.readSize(replicatedInputBytes); long keyOffset = replicatedInputBytes.readPosition(); q.initInputKey(q.getInputKeyBytesAsData(replicatedInputBytes, keyOffset, keySize)); replicatedInputBytes.readSkip(keySize); if (isDeleted) { s.innerUpdateLock.lock(); mh.m().remoteOperations.remove(this); } else { long valueSize = mh.m().valueSizeMarshaller.readSize(replicatedInputBytes); long valueOffset = replicatedInputBytes.readPosition(); Data<V> value = q.wrapValueBytesAsData(replicatedInputBytes, valueOffset, valueSize); replicatedInputBytes.readSkip(valueSize); s.innerWriteLock.lock(); mh.m().remoteOperations.put(this, value); } }
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; long readPosition = bytes.readPosition(); sb.ensureCapacity(utflen); bytes.readSkip(count); setCount(sb, count); if (count < utflen) { long rp0 = bytes.readPosition(); try { parseUtf82(bytes, sb, utflen, count);
@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); } }