org.apache.jackrabbit.oak.spi.blob.BlobStore.getBlobLength()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(5.4k)|赞(0)|评价(0)|浏览(98)

本文整理了Java中org.apache.jackrabbit.oak.spi.blob.BlobStore.getBlobLength()方法的一些代码示例,展示了BlobStore.getBlobLength()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。BlobStore.getBlobLength()方法的具体详情如下:
包路径:org.apache.jackrabbit.oak.spi.blob.BlobStore
类名称:BlobStore
方法名:getBlobLength

BlobStore.getBlobLength介绍

[英]Get the length of the blob.
[中]获取水滴的长度。

代码示例

代码示例来源:origin: apache/jackrabbit-oak

@Override
public long length() {
  try {
    return blobStore.getBlobLength(blobId);
  } catch (IOException e) {
    throw new IllegalArgumentException("Invalid blob id: " + blobId, e);
  }
}

代码示例来源:origin: org.apache.sling/org.apache.sling.testing.sling-mock-oak

@Override
public long length() {
  try {
    return blobStore.getBlobLength(blobId);
  } catch (IOException e) {
    throw new IllegalArgumentException("Invalid blob id: " + blobId, e);
  }
}

代码示例来源:origin: org.apache.jackrabbit/oak-blob-plugins

@Override
public long length() {
  try {
    return blobStore.getBlobLength(blobId);
  } catch (IOException e) {
    throw new IllegalArgumentException("Invalid blob id: " + blobId, e);
  }
}

代码示例来源:origin: apache/jackrabbit-oak

@Override
  public long getBlobLength(String blobId) {
    if (store == null) {
      return -1L;
    }
    
    try {
      return store.getBlobLength(blobId);
    } catch (IOException e) {
      log.warn("Error while reading blob content", e);
    }
       return -1L;
  }
}

代码示例来源:origin: org.apache.jackrabbit/oak-blob

@Override
public long getBlobLength(String blobId) throws IOException {
  return chooseBlobStoreByBlobId(blobId).getBlobLength(blobId);
}

代码示例来源:origin: apache/jackrabbit-oak

@Override
public long getBlobLength(String blobId) throws IOException {
  return chooseBlobStoreByBlobId(blobId).getBlobLength(blobId);
}

代码示例来源:origin: org.apache.sling/org.apache.sling.testing.sling-mock-oak

@Override
public long getBlobLength(String blobId) throws IOException {
  return chooseBlobStoreByBlobId(blobId).getBlobLength(blobId);
}

代码示例来源:origin: org.apache.jackrabbit/oak-mk

public long getLength(String blobId) throws MicroKernelException {
  if (rep == null) {
    throw new IllegalStateException("this instance has already been disposed");
  }
  try {
    return rep.getBlobStore().getBlobLength(blobId);
  } catch (Exception e) {
    throw new MicroKernelException(e);
  }
}

代码示例来源:origin: apache/jackrabbit-oak

@Override
  public long length() {
    try {
      return blobStore.getBlobLength(id);
    } catch (IOException e) {
      log.error("Error in length", e);
    }
    return 0;
  }
}

代码示例来源:origin: org.apache.sling/org.apache.sling.testing.sling-mock-oak

public static byte[] readFully(BlobStore store, String id) throws IOException {
  int len = (int) store.getBlobLength(id);
  byte[] buff = new byte[len];
  BlobStoreInputStream in = new BlobStoreInputStream(store, id, 0);
  IOUtils.readFully(in, buff, 0, len);
  return buff;
}

代码示例来源:origin: apache/jackrabbit-oak

public static byte[] readFully(BlobStore store, String id) throws IOException {
  int len = (int) store.getBlobLength(id);
  byte[] buff = new byte[len];
  BlobStoreInputStream in = new BlobStoreInputStream(store, id, 0);
  IOUtils.readFully(in, buff, 0, len);
  return buff;
}

代码示例来源:origin: org.apache.jackrabbit/oak-blob

public static byte[] readFully(BlobStore store, String id) throws IOException {
  int len = (int) store.getBlobLength(id);
  byte[] buff = new byte[len];
  BlobStoreInputStream in = new BlobStoreInputStream(store, id, 0);
  IOUtils.readFully(in, buff, 0, len);
  return buff;
}

代码示例来源:origin: apache/jackrabbit-oak

@Test
public void testLength() throws IOException {
  for (String id : oldBlobIds) {
    assertEquals(LENGTH, splitBlobStore.getBlobLength(id));
  }
  for (String id : newBlobIds) {
    assertEquals(LENGTH, newBlobStore.getBlobLength(id));
    assertEquals(LENGTH, splitBlobStore.getBlobLength(id));
  }
}

代码示例来源:origin: apache/jackrabbit-oak

@Test(expected = NullPointerException.class)
public void getBlobLengthShouldAlwaysThrowAnExceptionWhenNullBlobIdIsPassed()
    throws IOException {
  given:
  {
    final BlobStore store = new LoopbackBlobStore();
    when:
    {
      store.getBlobLength(null);
    }
  }
}

代码示例来源:origin: apache/jackrabbit-oak

public long getLength(String blobId) throws DocumentStoreException {
  try {
    return nodeStore.getBlobStore().getBlobLength(blobId);
  } catch (Exception e) {
    throw new DocumentStoreException(e);
  }
}

代码示例来源:origin: apache/jackrabbit-oak

@Test
@Parameters(method = "blobIds")
public void getBlobLengthShouldAlwaysReturnRealLengthOfBlobThatWillBeReturned(
    final String blobId) throws IOException {
  given:
  {
    final BlobStore store = new LoopbackBlobStore();
    expect:
    {
      assertEquals(blobId.getBytes().length, store.getBlobLength(blobId));
    }
  }
}

代码示例来源:origin: apache/jackrabbit-oak

@Test
public void shouldReturnBlobContent() throws Exception {
  BlobStore s = mock(BlobStore.class);
  when(s.getInputStream("id")).thenReturn(new ByteArrayInputStream(new byte[]{1, 2, 3}));
  when(s.getBlobLength("id")).thenReturn(3L);
  DefaultStandbyBlobReader r = new DefaultStandbyBlobReader(s);
  assertEquals(3, r.getBlobLength("id"));
  assertArrayEquals(new byte[]{1, 2, 3}, IOUtils.toByteArray(r.readBlob("id")));
}

代码示例来源:origin: apache/jackrabbit-oak

@Test
public void shouldReturnNegativeLengthIfBlobIsUnreadable() throws Exception {
  BlobStore s = mock(BlobStore.class);
  when(s.getBlobLength("id")).thenReturn(-1L);
  DefaultStandbyBlobReader r = new DefaultStandbyBlobReader(s);
  assertEquals(-1L, r.getBlobLength("id"));
}

代码示例来源:origin: apache/jackrabbit-oak

private void testBlobIdWithLength(int blobIdLength) throws Exception {
  String blobId = Strings.repeat("x", blobIdLength);
  long blobLength = SegmentTestConstants.MEDIUM_LIMIT;
  doReturn(blobId).when(blobStore).writeBlob(any(InputStream.class));
  doReturn(blobLength).when(blobStore).getBlobLength(blobId);
  SegmentBlob blob = new SegmentBlob(blobStore, fileStore.getWriter().writeStream(newRandomInputStream(blobLength)));
  assertEquals(blobLength, blob.length());
}

相关文章