Examples of slice()


Examples of java.nio.ByteBuffer.slice()

                    if(rs.next())
                    {
                        byte[] dataAsBytes = getBlobAsBytes(rs, 1);
                        ByteBuffer buf = ByteBuffer.wrap(dataAsBytes);
                        buf.position(1);
                        buf = buf.slice();
                        MessageMetaDataType type = MessageMetaDataTypeRegistry.fromOrdinal(dataAsBytes[0]);
                        StorableMessageMetaData metaData = type.createMetaData(buf);

                        return metaData;
                    }
View Full Code Here

Examples of java.nio.ByteBuffer.slice()

        if (valueSize == -1) {
            throw new IOException("KeyDir should not point to a tombstone");
        }
        assert(entry.remaining() == valueSize);

        return entry.slice();
    }

    /*
     * Get an iterator that populates cask entries with just enough info to reload the
     * key dir.
View Full Code Here

Examples of java.nio.ByteBuffer.slice()

             
              if(!iov[ip].hasRemaining()) { ip++; continue; }
             
              ByteBuffer o = iov[ip];
              if (o.remaining() > sizes[cnt]) {
                o = o.slice();
                o.limit((int) sizes[cnt]);
              }
             
              int bytes;
              try {
View Full Code Here

Examples of java.nio.ByteBuffer.slice()

    start = out.position();
    int bodylen = out.remaining();

    scanbit8(out);

    out = out.slice();
    out.position(out.limit());

    int code;
    if (deliver == INET_DELIVER_PORT) {
      code = inet_port_data(out);
View Full Code Here

Examples of java.nio.ByteBuffer.slice()

    }
  }

  private <T> void assertRoundTripEquality(Marshaller<T> marshaller, T value) {
    ByteBuffer bytes = marshaller.toBytes(value);
    T reconstructed = marshaller.fromBytes(bytes.slice());
    assertEquals(value, reconstructed);
    assertEquals(bytes, marshaller.toBytes(reconstructed));
  }

  /**
 
View Full Code Here

Examples of java.nio.ByteBuffer.slice()

public class KeyValueMarshallerTest extends TestCase {

  private <K, V> void assertRoundTripEquality(KeyValueMarshaller<K, V> marshaller,
      KeyValue<K, V> keyValue) {
    ByteBuffer bytes = marshaller.toBytes(keyValue);
    KeyValue<K, V> reconstructed = marshaller.fromBytes(bytes.slice());
    assertEquals(keyValue, reconstructed);
    assertEquals(bytes, marshaller.toBytes(reconstructed));
  }

  public void testThrowsCorruptDataException() {
View Full Code Here

Examples of java.nio.ByteBuffer.slice()

public class KeyValuesMarshallerTest extends TestCase {

  private <K, V> void assertRoundTripEquality(KeyValuesMarshaller<K, V> marshaller, K key,
      List<V> values) {
    ByteBuffer bytes = marshaller.toBytes(new KeyValue<>(key, values));
    KeyValue<K, Iterable<V>> reconstructed = marshaller.fromBytes(bytes.slice());
    validateEqual(key, values, reconstructed);
    reconstructed = marshaller.fromBytes(bytes.slice());
    assertEquals(bytes, marshaller.toBytes(reconstructed));
  }
View Full Code Here

Examples of java.nio.ByteBuffer.slice()

  private <K, V> void assertRoundTripEquality(KeyValuesMarshaller<K, V> marshaller, K key,
      List<V> values) {
    ByteBuffer bytes = marshaller.toBytes(new KeyValue<>(key, values));
    KeyValue<K, Iterable<V>> reconstructed = marshaller.fromBytes(bytes.slice());
    validateEqual(key, values, reconstructed);
    reconstructed = marshaller.fromBytes(bytes.slice());
    assertEquals(bytes, marshaller.toBytes(reconstructed));
  }

  private <K, V> void validateEqual(K key, List<V> values,
      KeyValue<K, ? extends Iterable<V>> reconstructed) {
View Full Code Here

Examples of java.nio.ByteBuffer.slice()

      @SuppressWarnings({"unchecked", "rawtypes"})
      ByteBuffer bytes = m.toBytes(new KeyValue(key, valueValues));
      KeyValue<KeyValue<Integer, ? extends Iterable<String>>,
          Iterable<KeyValue<Integer, ? extends Iterable<String>>>> reconstructed =
              m.fromBytes(bytes.slice());
      validateEqual(key.getKey(), keyStrings, reconstructed.getKey());

      Iterator<KeyValue<Integer, ? extends Iterable<String>>> reconValues =
          reconstructed.getValue().iterator();
      for (KeyValue<Integer, ? extends List<String>> value : valueValues) {
View Full Code Here

Examples of java.nio.ByteBuffer.slice()

    LinkedHashMap<ByteBuffer, List<ByteBuffer>> map =
        sortUntilFull(s, new StringStringGenerator(numberToWrite - 1), null);
    s = createWorker(numberToWrite);
    ByteBuffer last = map.keySet().toArray(new ByteBuffer[] {})[numberToWrite - 2];
    map = sortUntilFull(s, new StringStringGenerator(numberToWrite - 1),
        new KeyValue<>(last.slice(), ByteBuffer.allocate(StringStringGenerator.VALUE_SIZE)));
    assertTrue(s.isFull()); // Confirms the bufferCapacity setting above.
    assertEquals(numberToWrite - 1, map.size());
    String previous = "\0";
    for (ByteBuffer key : map.keySet()) {
      String string = US_ASCII.decode(key).toString();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.