org.apache.jena.atlas.lib.Bytes.fromByteBuffer()方法的使用及代码示例

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

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

Bytes.fromByteBuffer介绍

[英]Decode a string into a ByteBuffer
[中]

代码示例

代码示例来源:origin: apache/jena

/**  Get data as string - convenience operation */ 
public String getString() {
  ByteBuffer bb = getBlob() ;
  if (bb == null )
    return null ;
  int x = bb.position() ;
  String s = Bytes.fromByteBuffer(bb) ;
  bb.position(x) ;
  return s ;
}

代码示例来源:origin: org.seaborne.mantis/dboe-trans-data

/**  Get data as string - convenience operation */ 
public String getString() {
  ByteBuffer bb = getBlob() ;
  if (bb == null )
    return null ;
  int x = bb.position() ;
  String s = Bytes.fromByteBuffer(bb) ;
  bb.position(x) ;
  return s ;
}

代码示例来源:origin: org.apache.jena/jena-dboe-trans-data

/**  Get data as string - convenience operation */ 
public String getString() {
  ByteBuffer bb = getBlob() ;
  if (bb == null )
    return null ;
  int x = bb.position() ;
  String s = Bytes.fromByteBuffer(bb) ;
  bb.position(x) ;
  return s ;
}

代码示例来源:origin: apache/jena

/** Decode a string into a ByteBuffer */
public static String fromByteBuffer(ByteBuffer bb)
{
  //return BlockUTF8.toString(bb) ;
  // To be removed (Dec 2011)
  CharsetDecoder dec = Chars.allocDecoder();
  String x = fromByteBuffer(bb, dec) ;
  Chars.deallocDecoder(dec) ;
  return x ;
}

代码示例来源:origin: apache/jena

public String read(long id)
{
  ByteBuffer bb = file.read(id) ;
  String x = Bytes.fromByteBuffer(bb) ;
  x = decompress(x) ;
  return x ;
}

代码示例来源:origin: org.apache.jena/jena-base

/** Decode a string into a ByteBuffer */
public static String fromByteBuffer(ByteBuffer bb)
{
  //return BlockUTF8.toString(bb) ;
  // To be removed (Dec 2011)
  CharsetDecoder dec = Chars.allocDecoder();
  String x = fromByteBuffer(bb, dec) ;
  Chars.deallocDecoder(dec) ;
  return x ;
}

代码示例来源:origin: org.apache.clerezza.ext/org.apache.jena.jena-arq

/** Decode a string into a ByteBuffer */
public static String fromByteBuffer(ByteBuffer bb)
{
  //return BlockUTF8.toString(bb) ;
  // To be removed (Dec 2011)
  CharsetDecoder dec = Chars.allocDecoder();
  String x = fromByteBuffer(bb, dec) ;
  Chars.deallocDecoder(dec) ;
  return x ;
}

代码示例来源:origin: org.seaborne.mantis/dboe-base

public String read(long id)
{
  ByteBuffer bb = file.read(id) ;
  String x = Bytes.fromByteBuffer(bb) ;
  x = decompress(x) ;
  return x ;
}

代码示例来源:origin: apache/jena

public void dump(DumpHandler handler)
{
  long fileIdx = 0 ;
  while ( true )
  {
    ByteBuffer bb = file.read(fileIdx) ;
    String str = Bytes.fromByteBuffer(bb) ;
    handler.handle(fileIdx, str) ;
    fileIdx = fileIdx + bb.limit() + 4 ;
    if ( fileIdx >= file.length() )
      break ;
  }
}

代码示例来源:origin: org.seaborne.mantis/dboe-base

public void dump(DumpHandler handler)
{
  long fileIdx = 0 ;
  while ( true )
  {
    ByteBuffer bb = file.read(fileIdx) ;
    String str = Bytes.fromByteBuffer(bb) ;
    handler.handle(fileIdx, str) ;
    fileIdx = fileIdx + bb.limit() + 4 ;
    if ( fileIdx >= file.position() )
      break ;
  }
}

代码示例来源:origin: apache/jena

private static void codec(String str)
{
  ByteBuffer bb = ByteBuffer.allocate(16) ; 
  Bytes.toByteBuffer(str, bb) ;
  bb.flip() ;
  String str2 = Bytes.fromByteBuffer(bb) ;
  assertEquals(str, str2) ;
}

代码示例来源:origin: org.seaborne.mantis/dboe-trans-data

private static String readOne(Transactional transactional, TransObjectFile transObjectFile, long posn) {
  return Txn.calculateRead(transactional, ()->{
    ByteBuffer bb = transObjectFile.read(posn) ;
    return Bytes.fromByteBuffer(bb) ;
  }) ;
}

代码示例来源:origin: org.seaborne.mantis/dboe-trans-data

@Test public void transObjectFile_4() {
    String str1 = "Test4" ; 
    String str2 = "TheNext" ;
    long x1 = writeOne(transactional, transObjectFile, str1) ;
    ByteBuffer bb = str2bb(str2) ;
    long x2 = baseObjectFile.write(bb) ;
    baseObjectFile.sync();
    long x3 = Txn.calculateRead(transactional, ()->transObjectFile.length()) ;
    assertEquals(x2, x3);
    assertNotEquals(x3, baseObjectFile.length());

    // Fake recovery.
    ByteBuffer bbj = ByteBuffer.allocate(2*Long.BYTES) ;
    bbj.putLong(x3) ;
    bbj.putLong(0) ;
    bbj.rewind() ;
    journal.write(JournalEntryType.REDO, transObjectFile.getComponentId(), bbj) ;
    journal.writeJournal(JournalEntry.COMMIT) ;
    // Recovery.
    //transObjectFile.recover(bb);
    TransactionalBase transBase = (TransactionalBase)TransactionalFactory.createTransactional(journal, transObjectFile) ;
    ByteBuffer bb1 = Txn.calculateRead(transBase, ()->transObjectFile.read(x3)) ;
    String s1 = Bytes.fromByteBuffer(bb1) ;
    assertEquals(str2, s1);
    // Woot!
    transBase.getTxnMgr().shutdown();
  }
}

相关文章