Codota Logo
PartitionSchema.getRangeSchema
Code IndexAdd Codota to your IDE (free)

How to use
getRangeSchema
method
in
org.apache.kudu.client.PartitionSchema

Best Java code snippets using org.apache.kudu.client.PartitionSchema.getRangeSchema (Showing top 14 results out of 315)

  • Common ways to obtain PartitionSchema
private void myMethod () {
PartitionSchema p =
  • Codota IconKuduTable kuduTable;kuduTable.getPartitionSchema()
  • Smart code suggestions by Codota
}
origin: prestodb/presto

private static RangeBoundValue buildRangePartitionBound(KuduTable table, byte[] rangeKey)
{
  if (rangeKey.length == 0) {
    return null;
  }
  else {
    Schema schema = table.getSchema();
    PartitionSchema partitionSchema = table.getPartitionSchema();
    PartitionSchema.RangeSchema rangeSchema = partitionSchema.getRangeSchema();
    List<Integer> rangeColumns = rangeSchema.getColumns();
    final int numColumns = rangeColumns.size();
    PartialRow bound = KeyEncoderAccessor.decodeRangePartitionKey(schema, partitionSchema, rangeKey);
    ArrayList<Object> list = new ArrayList<>();
    for (int i = 0; i < numColumns; i++) {
      Object obj = toValue(schema, bound, rangeColumns.get(i));
      list.add(obj);
    }
    return new RangeBoundValue(list);
  }
}
origin: prestodb/presto

private static List<RangePartition> getRangePartitionList(KuduTable table, long deadline)
{
  List<RangePartition> rangePartitions = new ArrayList<>();
  if (!table.getPartitionSchema().getRangeSchema().getColumns().isEmpty()) {
    try {
      Iterator var4 = table.getTabletsLocations(deadline).iterator();
      while (var4.hasNext()) {
        LocatedTablet tablet = (LocatedTablet) var4.next();
        Partition partition = tablet.getPartition();
        if (Iterators.all(partition.getHashBuckets().iterator(), Predicates.equalTo(0))) {
          RangePartition rangePartition = buildRangePartition(table, partition);
          rangePartitions.add(rangePartition);
        }
      }
    }
    catch (Exception e) {
      throw new RuntimeException(e);
    }
  }
  return rangePartitions;
}
origin: prestodb/presto

public static PartitionDesign getPartitionDesign(KuduTable table)
{
  Schema schema = table.getSchema();
  PartitionDesign partitionDesign = new PartitionDesign();
  PartitionSchema partitionSchema = table.getPartitionSchema();
  List<HashPartitionDefinition> hashPartitions = partitionSchema.getHashBucketSchemas().stream()
      .map(hashBucketSchema -> {
        HashPartitionDefinition hash = new HashPartitionDefinition();
        List<String> cols = hashBucketSchema.getColumnIds().stream()
            .map(idx -> schema.getColumnByIndex(idx).getName()).collect(toImmutableList());
        hash.setColumns(cols);
        hash.setBuckets(hashBucketSchema.getNumBuckets());
        return hash;
      }).collect(toImmutableList());
  partitionDesign.setHash(hashPartitions);
  List<Integer> rangeColumns = partitionSchema.getRangeSchema().getColumns();
  if (!rangeColumns.isEmpty()) {
    RangePartitionDefinition definition = new RangePartitionDefinition();
    definition.setColumns(rangeColumns.stream()
        .map(i -> schema.getColumns().get(i).getName())
        .collect(ImmutableList.toImmutableList()));
    partitionDesign.setRange(definition);
  }
  return partitionDesign;
}
origin: org.apache.kudu/kudu-client

/**
 * Decodes a range partition key into a partial row.
 *
 * @param schema the schema of the table
 * @param partitionSchema the partition schema of the table
 * @param buf the encoded range partition key
 * @return the decoded range key
 */
private static PartialRow decodeRangePartitionKey(Schema schema,
                         PartitionSchema partitionSchema,
                         ByteBuffer buf) {
 PartialRow row = schema.newPartialRow();
 Iterator<Integer> rangeIds = partitionSchema.getRangeSchema().getColumns().iterator();
 while (rangeIds.hasNext()) {
  int idx = schema.getColumnIndex(rangeIds.next());
  if (buf.hasRemaining()) {
   decodeColumn(buf, row, idx, !rangeIds.hasNext());
  } else {
   row.setMin(idx);
  }
 }
 if (buf.hasRemaining()) {
  throw new IllegalArgumentException("Unable to decode all partition key bytes");
 }
 return row;
}
origin: prestosql/presto

private static List<RangePartition> getRangePartitionList(KuduTable table, long deadline)
{
  List<RangePartition> rangePartitions = new ArrayList<>();
  if (!table.getPartitionSchema().getRangeSchema().getColumns().isEmpty()) {
    try {
      Iterator var4 = table.getTabletsLocations(deadline).iterator();
      while (var4.hasNext()) {
        LocatedTablet tablet = (LocatedTablet) var4.next();
        Partition partition = tablet.getPartition();
        if (Iterators.all(partition.getHashBuckets().iterator(), Predicates.equalTo(0))) {
          RangePartition rangePartition = buildRangePartition(table, partition);
          rangePartitions.add(rangePartition);
        }
      }
    }
    catch (Exception e) {
      throw new RuntimeException(e);
    }
  }
  return rangePartitions;
}
origin: MartinWeindel/presto-kudu

private static List<RangePartition> getRangePartitionList(KuduTable table, long deadline) {
  List<RangePartition> rangePartitions = new ArrayList();
  if (!table.getPartitionSchema().getRangeSchema().getColumns().isEmpty()) {
    try {
      Iterator var4 = table.getTabletsLocations(deadline).iterator();
      while (var4.hasNext()) {
        LocatedTablet tablet = (LocatedTablet) var4.next();
        Partition partition = tablet.getPartition();
        if (Iterators.all(partition.getHashBuckets().iterator(), Predicates.equalTo(0))) {
          RangePartition rangePartition = buildRangePartition(table, partition);
          rangePartitions.add(rangePartition);
        }
      }
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
  }
  return rangePartitions;
}
origin: org.apache.kudu/kudu-client

                      byte[] lowerBound,
                      byte[] upperBound) {
if (partitionSchema.getRangeSchema().getColumns().isEmpty() &&
  partitionSchema.getHashBucketSchemas().isEmpty()) {
 assert lowerBound.length == 0 && upperBound.length == 0;
if (partitionSchema.getRangeSchema().getColumns().size() > 0) {
 if (!hashBuckets.isEmpty()) {
  sb.append(", ");
 for (int id : partitionSchema.getRangeSchema().getColumns()) {
  idxs.add(schema.getColumnIndex(id));
origin: prestosql/presto

private static RangeBoundValue buildRangePartitionBound(KuduTable table, byte[] rangeKey)
{
  if (rangeKey.length == 0) {
    return null;
  }
  else {
    Schema schema = table.getSchema();
    PartitionSchema partitionSchema = table.getPartitionSchema();
    PartitionSchema.RangeSchema rangeSchema = partitionSchema.getRangeSchema();
    List<Integer> rangeColumns = rangeSchema.getColumns();
    final int numColumns = rangeColumns.size();
    PartialRow bound = KeyEncoderAccessor.decodeRangePartitionKey(schema, partitionSchema, rangeKey);
    ArrayList<Object> list = new ArrayList<>();
    for (int i = 0; i < numColumns; i++) {
      Object obj = toValue(schema, bound, rangeColumns.get(i));
      list.add(obj);
    }
    return new RangeBoundValue(list);
  }
}
origin: MartinWeindel/presto-kudu

private static RangeBoundValue buildRangePartitionBound(KuduTable table, byte[] rangeKey) throws Exception {
  if (rangeKey.length == 0) {
    return null;
  } else {
    Schema schema = table.getSchema();
    PartitionSchema partitionSchema = table.getPartitionSchema();
    PartitionSchema.RangeSchema rangeSchema = partitionSchema.getRangeSchema();
    List<Integer> rangeColumns = rangeSchema.getColumns();
    final int numColumns = rangeColumns.size();
    PartialRow bound = KeyEncoderAccessor.decodeRangePartitionKey(schema, partitionSchema, rangeKey);
    RangeBoundValue value = new RangeBoundValue();
    ArrayList<Object> list = new ArrayList<>();
    for (int i = 0; i < numColumns; i++) {
      Object obj = toValue(schema, bound, rangeColumns.get(i));
      list.add(obj);
    }
    value.setValues(list);
    return value;
  }
}
origin: org.apache.kudu/kudu-client

Schema schema = table.getSchema();
PartitionSchema partitionSchema = table.getPartitionSchema();
PartitionSchema.RangeSchema rangeSchema = partitionSchema.getRangeSchema();
for (int id : partitionSchema.getRangeSchema().getColumns()) {
 idxs.add(schema.getColumnIndex(id));
origin: MartinWeindel/presto-kudu

public static PartitionDesign getPartitionDesign(KuduTable table) {
  Schema schema = table.getSchema();
  PartitionDesign partitionDesign = new PartitionDesign();
  PartitionSchema partitionSchema = table.getPartitionSchema();
  List<HashPartitionDefinition> hashPartitions = partitionSchema.getHashBucketSchemas().stream()
      .map(hashBucketSchema -> {
        HashPartitionDefinition hash = new HashPartitionDefinition();
        List<String> cols = hashBucketSchema.getColumnIds().stream()
            .map(idx -> schema.getColumnByIndex(idx).getName()).collect(toImmutableList());
        hash.setColumns(cols);
        hash.setBuckets(hashBucketSchema.getNumBuckets());
        return hash;
      }).collect(toImmutableList());
  partitionDesign.setHash(hashPartitions);
  List<Integer> rangeColumns = partitionSchema.getRangeSchema().getColumns();
  if (!rangeColumns.isEmpty()) {
    RangePartitionDefinition definition = new RangePartitionDefinition();
    definition.setColumns(rangeColumns.stream()
        .map(i -> schema.getColumns().get(i).getName())
        .collect(ImmutableList.toImmutableList()));
    partitionDesign.setRange(definition);
  }
  return partitionDesign;
}
origin: prestosql/presto

public static PartitionDesign getPartitionDesign(KuduTable table)
{
  Schema schema = table.getSchema();
  PartitionDesign partitionDesign = new PartitionDesign();
  PartitionSchema partitionSchema = table.getPartitionSchema();
  List<HashPartitionDefinition> hashPartitions = partitionSchema.getHashBucketSchemas().stream()
      .map(hashBucketSchema -> {
        HashPartitionDefinition hash = new HashPartitionDefinition();
        List<String> cols = hashBucketSchema.getColumnIds().stream()
            .map(idx -> schema.getColumnByIndex(idx).getName()).collect(toImmutableList());
        hash.setColumns(cols);
        hash.setBuckets(hashBucketSchema.getNumBuckets());
        return hash;
      }).collect(toImmutableList());
  partitionDesign.setHash(hashPartitions);
  List<Integer> rangeColumns = partitionSchema.getRangeSchema().getColumns();
  if (!rangeColumns.isEmpty()) {
    RangePartitionDefinition definition = new RangePartitionDefinition();
    definition.setColumns(rangeColumns.stream()
        .map(i -> schema.getColumns().get(i).getName())
        .collect(ImmutableList.toImmutableList()));
    partitionDesign.setRange(definition);
  }
  return partitionDesign;
}
origin: org.apache.kudu/kudu-client

/**
 * Encodes the provided row into a partition key according to the partition schema.
 *
 * @param row the row to encode
 * @param partitionSchema the partition schema describing the table's partitioning
 * @return an encoded partition key
 */
public static byte[] encodePartitionKey(PartialRow row, PartitionSchema partitionSchema) {
 ByteVec buf = ByteVec.create();
 if (!partitionSchema.getHashBucketSchemas().isEmpty()) {
  for (final HashBucketSchema hashSchema : partitionSchema.getHashBucketSchemas()) {
   encodeHashBucket(getHashBucket(row, hashSchema), buf);
  }
 }
 encodeColumns(row, partitionSchema.getRangeSchema().getColumns(), buf);
 return buf.toArray();
}
origin: org.apache.kudu/kudu-client

Schema schema = scanner.table.getSchema();
PartitionSchema partitionSchema = scanner.table.getPartitionSchema();
PartitionSchema.RangeSchema rangeSchema = partitionSchema.getRangeSchema();
Map<String, KuduPredicate> predicates = scanner.predicates;
org.apache.kudu.clientPartitionSchemagetRangeSchema

Popular methods of PartitionSchema

  • getHashBucketSchemas
  • <init>
    Creates a new partition schema from the range and hash bucket schemas.
  • isSimpleRangePartitioning
    Returns true if the partition schema if the partition schema does not include any hash components, a
  • encodePartitionKey
    Returns the encoded partition key of the row.

Popular in Java

  • Reactive rest calls using spring rest template
  • putExtra (Intent)
  • getExternalFilesDir (Context)
  • scheduleAtFixedRate (ScheduledExecutorService)
    Creates and executes a periodic action that becomes enabled first after the given initial delay, and
  • HttpServer (com.sun.net.httpserver)
    This class implements a simple HTTP server. A HttpServer is bound to an IP address and port number a
  • InetAddress (java.net)
    This class represents an Internet Protocol (IP) address. An IP address is either a 32-bit or 128-bit
  • Socket (java.net)
    Provides a client-side TCP socket.
  • SocketTimeoutException (java.net)
    This exception is thrown when a timeout expired on a socket read or accept operation.
  • Iterator (java.util)
    An iterator over a collection. Iterator takes the place of Enumeration in the Java Collections Frame
  • Scheduler (org.quartz)
    This is the main interface of a Quartz Scheduler. A Scheduler maintains a registery of org.quartz
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now