io.airlift.slice.Slice.toStringAscii()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(6.9k)|赞(0)|评价(0)|浏览(91)

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

Slice.toStringAscii介绍

[英]Decodes the contents of this slice into a string using the US_ASCII character set. The low order 7 bits if each byte are converted directly into a code point for the string.
[中]使用US_ASCII字符集将该片段的内容解码为字符串。如果每个字节直接转换为字符串的代码点,则为低阶7位。

代码示例

代码示例来源:origin: prestodb/presto

private static int parseDate(Slice slice, int offset, int length)
  {
    long millis = HIVE_DATE_PARSER.parseMillis(slice.toStringAscii(offset, length));
    return toIntExact(MILLISECONDS.toDays(millis));
  }
}

代码示例来源:origin: prestodb/presto

private static double parseDouble(Slice slice, int start, int length)
      throws RcFileCorruptionException
  {
    try {
      return Double.parseDouble(slice.toStringAscii(start, length));
    }
    catch (NumberFormatException e) {
      throw new RcFileCorruptionException(e, "Invalid double value");
    }
  }
}

代码示例来源:origin: prestodb/presto

private static float parseFloat(Slice slice, int start, int length)
      throws RcFileCorruptionException
  {
    try {
      return Float.parseFloat(slice.toStringAscii(start, length));
    }
    catch (NumberFormatException e) {
      throw new RcFileCorruptionException(e, "Invalid float value");
    }
  }
}

代码示例来源:origin: prestodb/presto

@Override
  public long getLong()
  {
    long millis = FORMATTER.parseMillis(getSlice().toStringAscii());
    Type type = columnHandle.getType();
    if (type.equals(DATE)) {
      return MILLISECONDS.toDays(millis);
    }
    if (type.equals(TIMESTAMP) || type.equals(TIME)) {
      return millis;
    }
    if (type.equals(TIMESTAMP_WITH_TIME_ZONE) || type.equals(TIME_WITH_TIME_ZONE)) {
      return packDateTimeWithZone(millis, 0);
    }
    return millis;
  }
}

代码示例来源:origin: prestodb/presto

private Comparable<?> getPrestoValue(RecordCursor recordCursor, List<Column> columns, int columnId)
  {
    if (recordCursor.isNull(columnId)) {
      return null;
    }

    Column column = columns.get(columnId);
    ColumnType.Base baseType = column.getType().getBase();
    switch (baseType) {
      case IDENTIFIER:
      case INTEGER:
      case DATE:
      case TIME:
      case DECIMAL:
        return recordCursor.getLong(columnId);
      case VARCHAR:
      case CHAR:
        return recordCursor.getSlice(columnId).toStringAscii();
    }
    throw new UnsupportedOperationException(format("Unsupported TPCDS base type [%s]", baseType));
  }
}

代码示例来源:origin: prestodb/presto

ImmutableSet.of("a", "c").contains(VARCHAR.getSlice(rightPage.getBlock(0), rightPosition).toStringAscii())));

代码示例来源:origin: prestodb/presto

(leftPosition, leftPage, rightPosition, rightPage) -> VARCHAR.getSlice(rightPage.getBlock(0), rightPosition).toStringAscii().equals("a")));

代码示例来源:origin: prestodb/presto

ImmutableSet.of("a", "c").contains(VARCHAR.getSlice(rightPage.getBlock(0), rightPosition).toStringAscii())));

代码示例来源:origin: airlift/slice

/**
 * Decodes the contents of this slice into a string using the US_ASCII
 * character set.  The low order 7 bits if each byte are converted directly
 * into a code point for the string.
 */
public String toStringAscii()
{
  return toStringAscii(0, size);
}

代码示例来源:origin: io.airlift/slice

/**
 * Decodes the contents of this slice into a string using the US_ASCII
 * character set.  The low order 7 bits if each byte are converted directly
 * into a code point for the string.
 */
public String toStringAscii()
{
  return toStringAscii(0, size);
}

代码示例来源:origin: com.facebook.presto/presto-rcfile

private static int parseDate(Slice slice, int offset, int length)
  {
    long millis = HIVE_DATE_PARSER.parseMillis(slice.toStringAscii(offset, length));
    return toIntExact(MILLISECONDS.toDays(millis));
  }
}

代码示例来源:origin: com.facebook.presto/presto-rcfile

private static double parseDouble(Slice slice, int start, int length)
      throws RcFileCorruptionException
  {
    try {
      return Double.parseDouble(slice.toStringAscii(start, length));
    }
    catch (NumberFormatException e) {
      throw new RcFileCorruptionException(e, "Invalid double value");
    }
  }
}

代码示例来源:origin: com.facebook.presto/presto-rcfile

private static float parseFloat(Slice slice, int start, int length)
      throws RcFileCorruptionException
  {
    try {
      return Float.parseFloat(slice.toStringAscii(start, length));
    }
    catch (NumberFormatException e) {
      throw new RcFileCorruptionException(e, "Invalid float value");
    }
  }
}

代码示例来源:origin: prestosql/presto

private static int parseDate(Slice slice, int offset, int length)
  {
    long millis = HIVE_DATE_PARSER.parseMillis(slice.toStringAscii(offset, length));
    return toIntExact(MILLISECONDS.toDays(millis));
  }
}

代码示例来源:origin: prestosql/presto

private static double parseDouble(Slice slice, int start, int length)
      throws RcFileCorruptionException
  {
    try {
      return Double.parseDouble(slice.toStringAscii(start, length));
    }
    catch (NumberFormatException e) {
      throw new RcFileCorruptionException(e, "Invalid double value");
    }
  }
}

代码示例来源:origin: prestosql/presto

private static float parseFloat(Slice slice, int start, int length)
      throws RcFileCorruptionException
  {
    try {
      return Float.parseFloat(slice.toStringAscii(start, length));
    }
    catch (NumberFormatException e) {
      throw new RcFileCorruptionException(e, "Invalid float value");
    }
  }
}

代码示例来源:origin: prestosql/presto

@Override
  public long getLong()
  {
    long millis = FORMATTER.parseMillis(getSlice().toStringAscii());
    Type type = columnHandle.getType();
    if (type.equals(DATE)) {
      return MILLISECONDS.toDays(millis);
    }
    if (type.equals(TIMESTAMP) || type.equals(TIME)) {
      return millis;
    }
    if (type.equals(TIMESTAMP_WITH_TIME_ZONE) || type.equals(TIME_WITH_TIME_ZONE)) {
      return packDateTimeWithZone(millis, 0);
    }
    return millis;
  }
}

代码示例来源:origin: io.prestosql/presto-tpcds

private Comparable<?> getPrestoValue(RecordCursor recordCursor, List<Column> columns, int columnId)
  {
    if (recordCursor.isNull(columnId)) {
      return null;
    }

    Column column = columns.get(columnId);
    ColumnType.Base baseType = column.getType().getBase();
    switch (baseType) {
      case IDENTIFIER:
      case INTEGER:
      case DATE:
      case TIME:
      case DECIMAL:
        return recordCursor.getLong(columnId);
      case VARCHAR:
      case CHAR:
        return recordCursor.getSlice(columnId).toStringAscii();
    }
    throw new UnsupportedOperationException(format("Unsupported TPCDS base type [%s]", baseType));
  }
}

代码示例来源:origin: com.facebook.presto/presto-tpcds

private Comparable<?> getPrestoValue(RecordCursor recordCursor, List<Column> columns, int columnId)
  {
    if (recordCursor.isNull(columnId)) {
      return null;
    }

    Column column = columns.get(columnId);
    ColumnType.Base baseType = column.getType().getBase();
    switch (baseType) {
      case IDENTIFIER:
      case INTEGER:
      case DATE:
      case TIME:
      case DECIMAL:
        return recordCursor.getLong(columnId);
      case VARCHAR:
      case CHAR:
        return recordCursor.getSlice(columnId).toStringAscii();
    }
    throw new UnsupportedOperationException(format("Unsupported TPCDS base type [%s]", baseType));
  }
}

代码示例来源:origin: prestosql/presto

private Comparable<?> getPrestoValue(RecordCursor recordCursor, List<Column> columns, int columnId)
  {
    if (recordCursor.isNull(columnId)) {
      return null;
    }

    Column column = columns.get(columnId);
    ColumnType.Base baseType = column.getType().getBase();
    switch (baseType) {
      case IDENTIFIER:
      case INTEGER:
      case DATE:
      case TIME:
      case DECIMAL:
        return recordCursor.getLong(columnId);
      case VARCHAR:
      case CHAR:
        return recordCursor.getSlice(columnId).toStringAscii();
    }
    throw new UnsupportedOperationException(format("Unsupported TPCDS base type [%s]", baseType));
  }
}

相关文章