Writes the current partition count and size estimates into SIZE_ESTIMATES_CF
557399
public static void updateSizeEstimates(String keyspace, String table, Map<Range<Token>, Pair<Long, Long>> estimates)
    {
        long timestamp = FBUtilities.timestampMicros();
        CFMetaData estimatesTable = CFMetaData.SizeEstimatesCf;
        Mutation mutation = new Mutation(Keyspace.SYSTEM_KS, UTF8Type.instance.decompose(keyspace));

        // delete all previous values with a single range tombstone.
        mutation.deleteRange(SIZE_ESTIMATES_CF,
                             estimatesTable.comparator.make(table).start(),
                             estimatesTable.comparator.make(table).end(),
                             timestamp - 1);

        // add a CQL row for each primary token range.
        ColumnFamily cells = mutation.addOrGet(estimatesTable);
        for (Map.Entry<Range<Token>, Pair<Long, Long>> entry : estimates.entrySet())
        {
            Range<Token> range = entry.getKey();
            Pair<Long, Long> values = entry.getValue();
            Composite prefix = estimatesTable.comparator.make(table, range.left.toString(), range.right.toString());
            CFRowAdder adder = new CFRowAdder(cells, prefix, timestamp);
            adder.add("partitions_count", values.left)
                 .add("mean_partition_size", values.right);
        }

        mutation.apply();
    }
107496
def _determine_chunk_to_make(write_dir):
    
    models = fsdb.get_models()
    # Last model is N.  N+1 (should be) training.  We should gather games for N+2.
    chunk_to_make = os.path.join(write_dir, str(
        models[-1][0] + 1) + '.tfrecord.zz')
    if not tf.gfile.Exists(chunk_to_make):
        # N+1 is missing.  Write it out ASAP
        print("Making chunk ASAP:", chunk_to_make)
        return chunk_to_make, True
    chunk_to_make = os.path.join(write_dir, str(
        models[-1][0] + 2) + '.tfrecord.zz')
    while tf.gfile.Exists(chunk_to_make):
        print("Chunk for next model ({}) already exists. Sleeping.".format(
            chunk_to_make))
        time.sleep(5 * 60)
        models = fsdb.get_models()
        chunk_to_make = os.path.join(write_dir, str(
            models[-1][0] + 2) + '.tfrecord.zz')
    print("Making chunk:", chunk_to_make)

    return chunk_to_make, False
648955
def current_batch
      start_position = output[:planned_count]
      size = start_position + batch_size > total_count ? total_count - start_position : batch_size
      batch(start_position, size)
    end
1106087
def calculate_size(uuid, partition_id, interrupt):
    
    data_size = 0
    data_size += calculate_size_str(uuid)
    data_size += INT_SIZE_IN_BYTES
    data_size += BOOLEAN_SIZE_IN_BYTES
    return data_size
1341945
def _write_mef(self, key, extlist, outfile):
        """"""
        channel = self.fv.get_channel(self.chname)
        with fits.open(outfile, mode='update') as pf:
            # Process each modified data extension
            for idx in extlist:
                k = '{0}[{1}]'.format(key, self._format_extname(idx))
                image = channel.datasrc[k]

                # Insert data and header into output HDU
                pf[idx].data = image.get_data()
                self._write_header(image, pf[idx])

            # Write history to PRIMARY
            self._write_history(key, pf['PRIMARY'])
414303
def write(self, s, size=None):
        
        self._buffer.write(s)
        self._len_changed = True
850401
def disk_partition_usage(all=False):
    '''
    
    '''
    result = disk_partitions(all)
    for partition in result:
        partition.update(disk_usage(partition['mountpoint']))
    return result
1172878
private void serializePartitionInfoToState() {
    List<PartitionDescriptor> descriptors = new ArrayList<>();

    for (DataWriter writer : partitionWriters.asMap().values()) {
      Descriptor descriptor = writer.getDataDescriptor();
      if (null == descriptor) {
        log.warn("Drop partition info as writer {} returns a null PartitionDescriptor", writer.toString());
        continue;
      }

      if (!(descriptor instanceof PartitionDescriptor)) {
        log.warn("Drop partition info as writer {} does not return a PartitionDescriptor", writer.toString());
        continue;
      }

      descriptors.add((PartitionDescriptor)descriptor);
    }

    if (descriptors.size() > 0) {
      state.setProp(getPartitionsKey(branchId), PartitionDescriptor.toPartitionJsonList(descriptors));
    } else {
      log.info("Partitions info not available. Will not serialize partitions");
    }
  }
121621
def partition_dumps(self):
        
        manifest = self.manifest_class()
        manifest_size = 0
        manifest_files = 0
        for resource in self.resources:
            manifest.add(resource)
            manifest_size += resource.length
            manifest_files += 1
            if (manifest_size >= self.max_size or
                    manifest_files >= self.max_files):
                yield(manifest)
                # Need to start a new manifest
                manifest = self.manifest_class()
                manifest_size = 0
                manifest_files = 0
        if (manifest_files > 0):
            yield(manifest)
143115
def write_how_many(self, file):
        
        report = CaseReport(self.case)

        # Map component labels to attribute names
        components = [("Bus", "n_buses"), ("Generator", "n_generators"),
            ("Committed Generator", "n_online_generators"),
            ("Load", "n_loads"), ("Fixed Load", "n_fixed_loads"),
            ("Despatchable Load", "n_online_vloads"), ("Shunt", "n_shunts"),
            ("Branch", "n_branches"), ("Transformer", "n_transformers"),
            ("Inter-tie", "n_interties"), ("Area", "n_areas")
        ]

        # Column 1 width
        longest = max([len(c[0]) for c in components])

        col1_header = "Object"
        col1_width = longest
        col2_header = "Quantity"
        col2_width = len(col2_header)

        # Row separator
        sep = "="*col1_width + " " + "="*col2_width + "\n"

        # Row headers
        file.write(sep)

        file.write(col1_header.center(col1_width))
        file.write(" ")
        file.write("%s\n" % col2_header.center(col2_width))

        file.write(sep)

        # Rows
        for label, attr in components:
            col2_value = str(getattr(report, attr))
            file.write("%s %s\n" %
                (label.ljust(col1_width), col2_value.rjust(col2_width)))
        else:
            file.write(sep)
            file.write("\n")

        del report
825297
def thread_partition_array(x):
    ""
    n_threads = get_threadpool_size()
    if len(x.shape) > 1:
        maxind = x.shape[1]
    else:
        maxind = x.shape[0]
    bounds = np.array(np.linspace(0, maxind, n_threads + 1), dtype='int')
    cmin = bounds[:-1]
    cmax = bounds[1:]
    return cmin, cmax
615274
def do_capacity(self, line):
        ""
        table, line = self.get_table_params(line)
        args = self.getargs(line)

        read_units = int(args[0])
        write_units = int(args[1])

        desc = table.describe()
        prov = desc['Table']['ProvisionedThroughput']

        current_read, current_write = prov['ReadCapacityUnits'], prov['WriteCapacityUnits']
        if read_units < current_read or write_units < current_write:
            print "%s: updating capacity to %d read units, %d write units" % (table.table_name, read_units, write_units)
            print ""
            if not table.update(throughput={'read': read_units, 'write': write_units}):
                print "update failed"
            else:
                self.do_refresh(table.table_name)

        else:
            print "%s: current capacity is %d read units, %d write units" % (table.table_name, current_read, current_write)
            # we can only double the current value at each call
            while current_read < read_units or current_write < write_units:
                if (read_units - current_read) > current_read:
                    current_read *= 2
                else:
                    current_read = read_units

                if (write_units - current_write) > current_write:
                    current_write *= 2
                else:
                    current_write = write_units

                print "%s: updating capacity to %d read units, %d write units" % (table.table_name, current_read, current_write)
                if not table.update({'read': current_read, 'write': current_write}):
                    print ""
                    print "update failed"
                    print ""
                    break
                else:
                    print ""
                    self.do_refresh(table.table_name)
                    print ""
67679
def show_big_file(dir_path, threshold):
        
        fc = FileCollection.from_path_by_size(dir_path, min_size=threshold)
        fc.sort_by("size_on_disk")
        
        lines = list()
        lines.append("Results:")
        for winfile in fc.iterfiles():
            lines.append("  %s - %s" % 
                         (string_SizeInBytes(winfile.size_on_disk), winfile))
        lines.append("Above are files' size greater than %s." % 
              string_SizeInBytes(threshold))
        text = "\n".join(lines)
        print(text)
        with open("__show_big_file__.log", "wb") as f:
            f.write(text.encode("utf-8"))
476881
def get_partition_count(context, default=0):
    
    if not is_ar(context):
        return default

    parent = context.getParentAnalysisRequest()

    if not parent:
        return default

    return len(parent.getDescendants())
632768
static <T> int listSizeInBytes(Buffer.Writer<T> writer, List<T> values) {
    int sizeInBytes = 5;
    for (int i = 0, length = values.size(); i < length; i++) {
      sizeInBytes += writer.sizeInBytes(values.get(i));
    }
    return sizeInBytes;
  }
82967
def dump(self, fh, value, context=None):
		
		
		value = self.dumps(value)
		fh.write(value)
		return len(value)
595140
def __load_partition_entries(self, fd, bs):
        

        fd.seek(self.header.part_lba * bs)
        for p in range(0, self.header.num_partitions):
            data = fd.read(self.header.part_size)
            entry = GptPartitionEntry(data)
            if entry.type_guid != uuid.UUID(
                '{00000000-0000-0000-0000-000000000000}'
            ):
                self.__partition_entries.append(entry)
            else:
                # stop loading on empty partition entry
                break